mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-05-05 20:36:40 +02:00
testing/ledmon: new aport
This commit is contained in:
parent
cddecd662a
commit
ffdd8b27f2
218
testing/ledmon/10-musl-build.patch
Normal file
218
testing/ledmon/10-musl-build.patch
Normal file
@ -0,0 +1,218 @@
|
||||
--- a/src/ledctl.c
|
||||
+++ b/src/ledctl.c
|
||||
@@ -214,15 +214,11 @@
|
||||
*
|
||||
* This is internal function of ledctl utility. The function cleans up a memory
|
||||
* allocated for the application and closes all opened handles. This function is
|
||||
- * design to be registered as on_exit() handler function.
|
||||
+ * design to be registered as atexit() handler function.
|
||||
*
|
||||
- * @param[in] status exit status of the ledctl application.
|
||||
- * @param[in] ignored function ignores this argument.
|
||||
- *
|
||||
* @return The function does not return a value.
|
||||
*/
|
||||
-static void _ledctl_fini(int status __attribute__ ((unused)),
|
||||
- void *ignore __attribute__ ((unused)))
|
||||
+static void _ledctl_fini(void)
|
||||
{
|
||||
sysfs_reset();
|
||||
list_erase(&ibpi_list);
|
||||
@@ -948,7 +944,7 @@
|
||||
* @brief Application's entry point.
|
||||
*
|
||||
* This is the entry point of ledctl utility. This function does all the work.
|
||||
- * It allocates and initializes all used structures. Registers on_exit()
|
||||
+ * It allocates and initializes all used structures. Registers atexit()
|
||||
* handlers.
|
||||
* Then the function parses command line options and commands given and scans
|
||||
* sysfs tree for controllers, block devices and RAID devices. If no error is
|
||||
@@ -983,7 +979,7 @@
|
||||
status = _init_ledctl_conf();
|
||||
if (status != LEDCTL_STATUS_SUCCESS)
|
||||
return status;
|
||||
- if (on_exit(_ledctl_fini, progname))
|
||||
+ if (atexit(_ledctl_fini))
|
||||
exit(LEDCTL_STATUS_ONEXIT_ERROR);
|
||||
slot_request_init(&slot_req);
|
||||
status = _cmdline_parse(argc, argv, &slot_req);
|
||||
--- a/src/ledmon.c
|
||||
+++ b/src/ledmon.c
|
||||
@@ -58,6 +58,19 @@
|
||||
#include "vmdssd.h"
|
||||
|
||||
/**
|
||||
+ * This macro is the alternative way to get exit status
|
||||
+ * in atexit() callback function
|
||||
+ */
|
||||
+#define EXIT(x) ((exit)(exit_status = (x)))
|
||||
+
|
||||
+static int exit_status;
|
||||
+
|
||||
+/**
|
||||
+ * Flag to print exit status
|
||||
+ */
|
||||
+static int ignore;
|
||||
+
|
||||
+/**
|
||||
* @brief List of active block devices.
|
||||
*
|
||||
* This list holds all block devices attached to supported storage controllers.
|
||||
@@ -151,20 +164,16 @@
|
||||
*
|
||||
* This is internal function of monitor service. It is used to finalize daemon
|
||||
* process i.e. free allocated memory, unlock and remove pidfile and close log
|
||||
- * file and syslog. The function is registered as on_exit() handler.
|
||||
+ * file and syslog. The function is registered as atexit() handler.
|
||||
*
|
||||
- * @param[in] status The function ignores this parameter.
|
||||
- * @param[in] program_name The name of the binary file. This argument
|
||||
- * is passed via on_exit() function.
|
||||
- *
|
||||
* @return The function does not return a value.
|
||||
*/
|
||||
-static void _ledmon_fini(int __attribute__ ((unused)) status, void *program_name)
|
||||
+static void _ledmon_fini(void)
|
||||
{
|
||||
sysfs_reset();
|
||||
list_erase(&ledmon_block_list);
|
||||
log_close();
|
||||
- pidfile_remove(program_name);
|
||||
+ pidfile_remove(progname);
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
@@ -207,30 +216,25 @@
|
||||
*
|
||||
* This is internal function of monitor service. It is used to report an exit
|
||||
* status of the monitor service. The message is logged in to syslog and to log
|
||||
- * file. The function is registered as on_exit() hander.
|
||||
+ * file. The function is registered as atexit() hander.
|
||||
*
|
||||
- * @param[in] status Status given in the last call to exit()
|
||||
- * function.
|
||||
- * @param[in] arg Argument passed to on_exit().
|
||||
- *
|
||||
* @return The function does not return a value.
|
||||
*/
|
||||
-static void _ledmon_status(int status, void *arg)
|
||||
+static void _ledmon_status(void)
|
||||
{
|
||||
int log_level;
|
||||
char message[4096];
|
||||
- int ignore = *((int *)arg);
|
||||
|
||||
if (ignore)
|
||||
return;
|
||||
|
||||
- if (status == LEDMON_STATUS_SUCCESS)
|
||||
+ if (exit_status == LEDMON_STATUS_SUCCESS)
|
||||
log_level = LOG_LEVEL_INFO;
|
||||
else
|
||||
log_level = LOG_LEVEL_ERROR;
|
||||
|
||||
snprintf(message, sizeof(message), "exit status is %s.",
|
||||
- ledmon_strstatus(status));
|
||||
+ ledmon_strstatus(exit_status));
|
||||
|
||||
if (get_log_fd() >= 0)
|
||||
_log(log_level, message);
|
||||
@@ -364,10 +368,10 @@
|
||||
break;
|
||||
case 'h':
|
||||
_ledmon_help();
|
||||
- exit(EXIT_SUCCESS);
|
||||
+ EXIT(EXIT_SUCCESS);
|
||||
case 'v':
|
||||
_ledmon_version();
|
||||
- exit(EXIT_SUCCESS);
|
||||
+ EXIT(EXIT_SUCCESS);
|
||||
case ':':
|
||||
case '?':
|
||||
return LEDMON_STATUS_CMDLINE_ERROR;
|
||||
@@ -890,14 +894,13 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
ledmon_status_code_t status = LEDMON_STATUS_SUCCESS;
|
||||
- static int ignore;
|
||||
|
||||
setup_options(&longopt, &shortopt, possible_params,
|
||||
possible_params_size);
|
||||
set_invocation_name(argv[0]);
|
||||
openlog(progname, LOG_PID | LOG_PERROR, LOG_DAEMON);
|
||||
|
||||
- if (on_exit(_ledmon_status, &ignore))
|
||||
+ if (atexit(_ledmon_status))
|
||||
return LEDMON_STATUS_ONEXIT_ERROR;
|
||||
|
||||
if (_cmdline_parse_non_daemonise(argc, argv) != LEDMON_STATUS_SUCCESS)
|
||||
@@ -935,18 +938,18 @@
|
||||
|
||||
if (pid < 0) {
|
||||
log_debug("main(): fork() failed (errno=%d).", errno);
|
||||
- exit(EXIT_FAILURE);
|
||||
+ EXIT(EXIT_FAILURE);
|
||||
}
|
||||
if (pid > 0) {
|
||||
ignore = 1; /* parent: don't print exit status */
|
||||
- exit(EXIT_SUCCESS);
|
||||
+ EXIT(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
pid_t sid = setsid();
|
||||
|
||||
if (sid < 0) {
|
||||
log_debug("main(): setsid() failed (errno=%d).", errno);
|
||||
- exit(EXIT_FAILURE);
|
||||
+ EXIT(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
_close_parent_fds();
|
||||
@@ -960,16 +963,16 @@
|
||||
|
||||
if (chdir("/") < 0) {
|
||||
log_debug("main(): chdir() failed (errno=%d).", errno);
|
||||
- exit(EXIT_FAILURE);
|
||||
+ EXIT(EXIT_FAILURE);
|
||||
}
|
||||
if (pidfile_create(progname)) {
|
||||
log_debug("main(): pidfile_creat() failed.");
|
||||
- exit(EXIT_FAILURE);
|
||||
+ EXIT(EXIT_FAILURE);
|
||||
}
|
||||
_ledmon_setup_signals();
|
||||
|
||||
- if (on_exit(_ledmon_fini, progname))
|
||||
- exit(LEDMON_STATUS_ONEXIT_ERROR);
|
||||
+ if (atexit(_ledmon_fini))
|
||||
+ EXIT(LEDMON_STATUS_ONEXIT_ERROR);
|
||||
list_init(&ledmon_block_list, (item_free_t)block_device_fini);
|
||||
sysfs_init();
|
||||
log_info("monitor service has been started...");
|
||||
@@ -987,5 +990,5 @@
|
||||
}
|
||||
ledmon_remove_shared_conf();
|
||||
stop_udev_monitor();
|
||||
- exit(EXIT_SUCCESS);
|
||||
+ EXIT(EXIT_SUCCESS);
|
||||
}
|
||||
--- a/src/utils.h
|
||||
+++ b/src/utils.h
|
||||
@@ -22,6 +22,7 @@
|
||||
#define _UTILS_H_INCLUDED_
|
||||
|
||||
#include <getopt.h>
|
||||
+#include <sys/types.h>
|
||||
#include "config_file.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdint.h"
|
||||
--- a/src/utils.c
|
||||
+++ b/src/utils.c
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
-#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
42
testing/ledmon/APKBUILD
Normal file
42
testing/ledmon/APKBUILD
Normal file
@ -0,0 +1,42 @@
|
||||
# Contributor: Steve McMaster <code@mcmaster.io>
|
||||
# Maintainer: Steve McMaster <code@mcmaster.io>
|
||||
pkgname=ledmon
|
||||
pkgver=0.97
|
||||
pkgrel=0
|
||||
pkgdesc="Enclosure LED Utilities"
|
||||
url="https://github.com/intel/ledmon"
|
||||
arch="all"
|
||||
# Provided tests expect to run on a host with supported hardware
|
||||
options="!check"
|
||||
license="GPL-2.0-only"
|
||||
makedepends="automake autoconf eudev-dev linux-headers pciutils-dev sg3_utils-dev"
|
||||
source="$pkgname-$pkgver.tar.gz::https://github.com/intel/ledmon/archive/v$pkgver.tar.gz
|
||||
10-musl-build.patch
|
||||
"
|
||||
subpackages="$pkgname-doc"
|
||||
|
||||
prepare() {
|
||||
default_prepare
|
||||
autoreconf -vif
|
||||
}
|
||||
|
||||
build() {
|
||||
./configure \
|
||||
--build=$CBUILD \
|
||||
--host=$CHOST \
|
||||
--prefix=/usr \
|
||||
--sysconfdir=/etc \
|
||||
--mandir=/usr/share/man \
|
||||
--localstatedir=/var \
|
||||
--disable-static
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
make DESTDIR="$pkgdir" install
|
||||
}
|
||||
|
||||
sha512sums="
|
||||
7a8f6c6f7cbaa10ae17ee60c2dfbce4100524b9b85fdc01a139f1fd2a33779348845df29b93f6c2cbabed4fa92a2a17a80636c2658e13507743bd2242fc08914 ledmon-0.97.tar.gz
|
||||
0ad5de757b34fb9f7264091cfdeb3ebd6cb66c1dbe31ebf423573027b065376b075f824eaaf20d79295605e5f671cca0ab17a0da4afeb131dd91a38a6841f098 10-musl-build.patch
|
||||
"
|
||||
Loading…
x
Reference in New Issue
Block a user