diff --git a/VERSION b/VERSION index ceab6e11ece0bcec917c12e11d350946f085d549..0c62199f16ac1e2d7f7ae75b420c1231325dff4e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1 \ No newline at end of file +0.2.1 diff --git a/libldevice.spec b/libldevice.spec index 91d17461db2517750eaf656ff7c9d53133d99b9d..b75c9657b88d788cc6558aaf960f1add20ad4ddc 100644 --- a/libldevice.spec +++ b/libldevice.spec @@ -1,13 +1,14 @@ Name: libldevice -Version: 0.1 +Version: 0.2.1 Release: 1%{?dist} Summary: A library that collecting device infomation License: LGPL v3 -URL: https://www.opencloudos.org -Source0: %{name}-%{version}.tar.xz +URL: https://gitee.com/OpenCloudOS/libldevice +Source0: https://gitee.com/OpenCloudOS/libldevice/archive/refs/tags/%{name}-%{version}.tar.gz # Dependencies +BuildRequires: meson BuildRequires: openssl-devel BuildRequires: libcurl-devel BuildRequires: systemd-devel @@ -69,6 +70,7 @@ fi %files %license LICENSE %doc README +%{_bindir}/ldevice %{_libdir}/libldevice.so.0 /usr/lib/license/libsystemactivation.so %{_unitdir}/libldevice.service diff --git a/meson.build b/meson.build index c3d98cd4eae02c383d6c22fbc6fd68cabe6ef286..61b3a99b8ba73fb164a3dfa11f96bb3e87e443f7 100644 --- a/meson.build +++ b/meson.build @@ -1,21 +1,31 @@ -project('libldevice', 'c', version: '0.1') +project('libldevice', 'c', version: '0.2.1', license: 'LGPL V3') # Use dependency function to check for libraries libcrypto_dep = dependency('openssl', modules: 'crypto', required: true) libcurl_dep = dependency('libcurl', required: true) libudev_dep = dependency('libudev', required: true) -# Specify your source code files -src = files('ldevice.c') +src_dir = 'src' +inc_dir = include_directories(src_dir) # Specify shared_library -mylib = shared_library( - 'ldevice', - src, +libldevice = shared_library( + 'ldevice', + sources: ['src/ldevice.c'], + include_directories: [inc_dir], dependencies: [libcrypto_dep, libcurl_dep, libudev_dep], version: '0', - install: true, # this makes Meson install the library + install: true +) + +# Specify executable program +executable( + 'ldevice', + sources: ['src/main.c'], + include_directories: [inc_dir], + link_with: libldevice, + install: true ) # Add installation instruction for header file -install_headers('ldevice.h') # This will install headers to /usr/local/include +install_headers('src/ldevice.h') diff --git a/ldevice.c b/src/ldevice.c similarity index 100% rename from ldevice.c rename to src/ldevice.c diff --git a/ldevice.h b/src/ldevice.h similarity index 93% rename from ldevice.h rename to src/ldevice.h index 080455c7ce50782f9503247466ee8369aed668c4..6f995f8fe406051c02df763050c04bc7c76dea87 100644 --- a/ldevice.h +++ b/src/ldevice.h @@ -16,6 +16,8 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ +#ifndef LDEVICE_H +#define LDEVICE_H /* * get Linux distribution type, like "OpenCloudOS" @@ -62,6 +64,11 @@ const char* system_get_cpu(); const char* system_get_mac(); +/* + * get blkid of filesystem +*/ +const char* system_get_blkid(); + /* * get the disk's uuid * if there are more than 1 disk, only get the disk @@ -73,3 +80,5 @@ const char* system_get_disk_uuid(); * get the license token */ const char* system_get_token(); + +#endif diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000000000000000000000000000000000000..ec2fa8fc8ca10411c376bcd1538257be4d839f84 --- /dev/null +++ b/src/main.c @@ -0,0 +1,28 @@ +#include +#include "ldevice.h" + +int main() { + int tag = system_get_tag(); + + const char *name = system_get_name(); + + int active = system_is_active(); + + const char* osversion = system_get_osversion(); + + const char* uuid = system_get_uuid(); + + const char* cpu = system_get_cpu(); + + const char* mac = system_get_mac(); + + const char* blkid = system_get_blkid(); + + const char* disk = system_get_disk_uuid(); + + const char* token = system_get_token(); + + printf("tag: %d\nname: %s\nactive: %d\nosversion: %s\nuuid: %s\ncpu: %s\nmac: %s\nblkid: %s\ndisk: %s\ntoken: %s\n", tag, name, active, osversion, uuid, cpu, mac, blkid, disk, token); + + return 0; +} \ No newline at end of file diff --git a/test.c b/src/test.c similarity index 100% rename from test.c rename to src/test.c