This option allows NickelMenu to be uninstalled by deleting the config dir.
This commit is contained in:
24
.drone.yml
24
.drone.yml
@@ -11,8 +11,18 @@ steps:
|
|||||||
when:
|
when:
|
||||||
event: [push, pull_request, tag]
|
event: [push, pull_request, tag]
|
||||||
commands:
|
commands:
|
||||||
|
- make clean
|
||||||
- make all koboroot
|
- make all koboroot
|
||||||
- mkdir out && mv KoboRoot.tgz src/libnm.so out/
|
- mkdir out && mv KoboRoot.tgz src/libnm.so out/
|
||||||
|
- name: build-NM_UNINSTALL_CONFIGDIR
|
||||||
|
image: docker.io/geek1011/nickeltc:1.0
|
||||||
|
when:
|
||||||
|
event: [push, pull_request, tag]
|
||||||
|
commands:
|
||||||
|
- make clean
|
||||||
|
- make all koboroot NM_UNINSTALL_CONFIGDIR=1
|
||||||
|
- mkdir out/with-NM_UNINSTALL_CONFIGDIR && mv KoboRoot.tgz src/libnm.so out/with-NM_UNINSTALL_CONFIGDIR/
|
||||||
|
depends_on: [build]
|
||||||
- name: test-syms
|
- name: test-syms
|
||||||
image: golang:1.14
|
image: golang:1.14
|
||||||
when:
|
when:
|
||||||
@@ -30,9 +40,9 @@ steps:
|
|||||||
access_key: nickelmenu
|
access_key: nickelmenu
|
||||||
secret_key: {from_secret: S3_SECRET_NICKELMENU}
|
secret_key: {from_secret: S3_SECRET_NICKELMENU}
|
||||||
target: artifacts/build/${DRONE_BUILD_NUMBER}
|
target: artifacts/build/${DRONE_BUILD_NUMBER}
|
||||||
source: out/*
|
source: out/**/*
|
||||||
strip_prefix: out/
|
strip_prefix: out/
|
||||||
depends_on: [build]
|
depends_on: [build, build-NM_UNINSTALL_CONFIGDIR]
|
||||||
- name: upload-tag
|
- name: upload-tag
|
||||||
image: plugins/s3
|
image: plugins/s3
|
||||||
when:
|
when:
|
||||||
@@ -42,11 +52,9 @@ steps:
|
|||||||
access_key: nickelmenu
|
access_key: nickelmenu
|
||||||
secret_key: {from_secret: S3_SECRET_NICKELMENU}
|
secret_key: {from_secret: S3_SECRET_NICKELMENU}
|
||||||
target: artifacts/tag/${DRONE_TAG}
|
target: artifacts/tag/${DRONE_TAG}
|
||||||
source: out/*
|
source: out/**/*
|
||||||
strip_prefix: out/
|
strip_prefix: out/
|
||||||
when:
|
depends_on: [build, build-NM_UNINSTALL_CONFIGDIR]
|
||||||
event: [tag]
|
|
||||||
depends_on: [build]
|
|
||||||
- name: upload-commit
|
- name: upload-commit
|
||||||
image: plugins/s3
|
image: plugins/s3
|
||||||
when:
|
when:
|
||||||
@@ -57,6 +65,6 @@ steps:
|
|||||||
access_key: nickelmenu
|
access_key: nickelmenu
|
||||||
secret_key: {from_secret: S3_SECRET_NICKELMENU}
|
secret_key: {from_secret: S3_SECRET_NICKELMENU}
|
||||||
target: artifacts/commit/${DRONE_COMMIT}
|
target: artifacts/commit/${DRONE_COMMIT}
|
||||||
source: out/*
|
source: out/**/*
|
||||||
strip_prefix: out/
|
strip_prefix: out/
|
||||||
depends_on: [build]
|
depends_on: [build, build-NM_UNINSTALL_CONFIGDIR]
|
||||||
|
|||||||
9
Makefile
9
Makefile
@@ -43,7 +43,14 @@ override LDFLAGS += -Wl,--no-undefined -Wl,-rpath,/usr/local/Kobo -Wl,-rpath,/u
|
|||||||
NM_VERSION := $(shell git describe --tags --always --dirty)
|
NM_VERSION := $(shell git describe --tags --always --dirty)
|
||||||
# Only use it if we got something useful out of git describe...
|
# Only use it if we got something useful out of git describe...
|
||||||
ifdef NM_VERSION
|
ifdef NM_VERSION
|
||||||
override CPPFLAGS += -DNM_VERSION='"$(NM_VERSION)"'
|
override CPPFLAGS += -DNM_VERSION='"$(NM_VERSION)"'
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(NM_UNINSTALL_CONFIGDIR),1)
|
||||||
|
$(info -- NM_UNINSTALL_CONFIGDIR... enabled)
|
||||||
|
override CPPFLAGS += -DNM_UNINSTALL_CONFIGDIR
|
||||||
|
else
|
||||||
|
$(info -- NM_UNINSTALL_CONFIGDIR... disabled)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,6 @@
|
|||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#ifndef NM_CONFIG_DIR
|
|
||||||
#define NM_CONFIG_DIR "/mnt/onboard/.adds/nm"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef NM_CONFIG_MAX_MENU_ITEMS_PER_MENU
|
|
||||||
#define NM_CONFIG_MAX_MENU_ITEMS_PER_MENU 50
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NM_CONFIG_TYPE_MENU_ITEM = 1,
|
NM_CONFIG_TYPE_MENU_ITEM = 1,
|
||||||
NM_CONFIG_TYPE_GENERATOR = 2,
|
NM_CONFIG_TYPE_GENERATOR = 2,
|
||||||
|
|||||||
@@ -7,6 +7,14 @@ extern "C" {
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
|
||||||
|
#ifndef NM_CONFIG_DIR
|
||||||
|
#define NM_CONFIG_DIR "/mnt/onboard/.adds/nm"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NM_CONFIG_MAX_MENU_ITEMS_PER_MENU
|
||||||
|
#define NM_CONFIG_MAX_MENU_ITEMS_PER_MENU 50
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct nm_config_t nm_config_t;
|
typedef struct nm_config_t nm_config_t;
|
||||||
|
|
||||||
// nm_config_parse parses the configuration files in /mnt/onboard/.adds/nm.
|
// nm_config_parse parses the configuration files in /mnt/onboard/.adds/nm.
|
||||||
|
|||||||
20
src/init.c
20
src/init.c
@@ -22,6 +22,13 @@ __attribute__((constructor)) void nm_init() {
|
|||||||
char *err;
|
char *err;
|
||||||
|
|
||||||
NM_LOG("version: " NM_VERSION);
|
NM_LOG("version: " NM_VERSION);
|
||||||
|
#ifdef NM_UNINSTALL_CONFIGDIR
|
||||||
|
NM_LOG("feature: NM_UNINSTALL_CONFIGDIR: true");
|
||||||
|
#else
|
||||||
|
NM_LOG("feature: NM_UNINSTALL_CONFIGDIR: false");
|
||||||
|
#endif
|
||||||
|
NM_LOG("config dir: %s", NM_CONFIG_DIR);
|
||||||
|
|
||||||
NM_LOG("init: creating failsafe");
|
NM_LOG("init: creating failsafe");
|
||||||
nm_failsafe_t *fs;
|
nm_failsafe_t *fs;
|
||||||
if (!(fs = nm_failsafe_create(&err)) && err) {
|
if (!(fs = nm_failsafe_create(&err)) && err) {
|
||||||
@@ -31,13 +38,22 @@ __attribute__((constructor)) void nm_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NM_LOG("init: checking for uninstall flag");
|
NM_LOG("init: checking for uninstall flag");
|
||||||
if (!access("/mnt/onboard/.adds/nm/uninstall", F_OK)) {
|
if (!access(NM_CONFIG_DIR "/uninstall", F_OK)) {
|
||||||
NM_LOG("init: flag found, uninstalling");
|
NM_LOG("init: flag found, uninstalling");
|
||||||
nm_failsafe_uninstall(fs);
|
nm_failsafe_uninstall(fs);
|
||||||
unlink("/mnt/onboard/.adds/nm/uninstall");
|
unlink(NM_CONFIG_DIR "/uninstall");
|
||||||
goto stop;
|
goto stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NM_UNINSTALL_CONFIGDIR
|
||||||
|
NM_LOG("init: NM_UNINSTALL_CONFIGDIR: checking if config dir exists");
|
||||||
|
if (access(NM_CONFIG_DIR, F_OK) && errno == ENOENT) {
|
||||||
|
NM_LOG("init: config dir does not exist, uninstalling");
|
||||||
|
nm_failsafe_uninstall(fs);
|
||||||
|
goto stop;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
NM_LOG("init: parsing config");
|
NM_LOG("init: parsing config");
|
||||||
size_t items_n;
|
size_t items_n;
|
||||||
nm_menu_item_t **items;
|
nm_menu_item_t **items;
|
||||||
|
|||||||
Reference in New Issue
Block a user