From 00b18e05a92516a89dd045cf59a63035d5aa3198 Mon Sep 17 00:00:00 2001
From: xiaoji <345865759@163.com>
Date: Wed, 5 Jun 2024 16:42:23 +0800
Subject: [PATCH] small fix
---
VERSION | 2 +-
libldevice.spec | 8 +++++---
meson.build | 26 ++++++++++++++++++--------
ldevice.c => src/ldevice.c | 0
ldevice.h => src/ldevice.h | 9 +++++++++
src/main.c | 28 ++++++++++++++++++++++++++++
test.c => src/test.c | 0
7 files changed, 61 insertions(+), 12 deletions(-)
rename ldevice.c => src/ldevice.c (100%)
rename ldevice.h => src/ldevice.h (93%)
create mode 100644 src/main.c
rename test.c => src/test.c (100%)
diff --git a/VERSION b/VERSION
index ceab6e1..0c62199 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 91d1746..b75c965 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 c3d98cd..61b3a99 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 080455c..6f995f8 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 0000000..ec2fa8f
--- /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
--
Gitee