Fix I/O plugin watcher, load plugins earlier to enable a new early hook!

Restructure start by calling the plugin loader earlier. This makes it
possible to run hooks even earlier.  This also adds a new hook:
HOOK_ROOTFS_UP which runs as soon as the system root (/) is available.

Another very notable change is the slow refactor of helpers.c into a finit
helper library called libite.so (-lite). This is a light-weight

Also, lots of misc. fixes all over the place. Signal handling still really
needs to be looked into once more!

Makefile:
        Add dependency handling for parallell build
        Add libite library

ChangeLog:
        Update with new 1.4 release. There is a lot of fixes!

libite/:
        Collection of utility functions and C library extensions for
        finit & its plugins

reboot.c:
        New reboot tool. Simply sends SIGINT to PID 1

finit.h:
        Cleanup old LISTEN_INITCTL define, code is in an optional plugin now

finit.c:
        Let mdev/udev run *after* cls()
        Add useful debug statement for /proc/cmdline
        Earlier plugin load => new early hook point
        Show OK/FAIL for total plugin load, not for each plugin => speedup

helpers.h:
        Rename syslog macros to prevent common name clashes (DEBUG/ERROR)
        Add __FILE__ to _e(), _d() and _pe() macros

helpers.c:
        In ifconfig() the addr and mask arguments are now optional
        The copyfile() has been moved to libite.so
        Temporarily remove const directive from some functions to build
        Use DFLSIG() macro in run_getty() to simplify code

plugin.h:
        Add new HOOK_ROOTFS_UP hook

plugin.c:
        Fix init_plugins() to actually register the plugin's I/O fd
        Skip verbose listing of all plugins in plugin_load_all()

svc.c:
        svc_start(): Dito

plugins/Makefile:
        Inherit CFLAGS and LDFLAGS, but make sure to filter out -rdynamic
        from LDFLAGS, it's used by the daemon, only

plugins/initctl.c:
        New includes after helpers.h refactor

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2012-10-02 08:25:50 +02:00
1 parent c002b5301f
commit 65c9e7ebc6
22 files changed
+1324 -111

No files matched your search

+26 -17
View File
@@ -26,14 +26,15 @@
uninstall-exec uninstall-data uninstall-dev
# Top directory for building complete system, fall back to this directory
ROOTDIR ?= $(shell pwd)
ROOTDIR = $(shell pwd)
#VERSION ?= $(shell git tag -l | tail -1)
VERSION ?= 1.4
EXEC = finit
PKG = $(EXEC)-$(VERSION)
DEV = $(EXEC)-dev
NAME = finit
PKG = $(NAME)-$(VERSION)
DEV = $(NAME)-dev
ARCHIVE = $(PKG).tar.xz
EXEC = finit reboot
HEADERS = plugin.h svc.h helpers.h
DISTFILES = LICENSE README ChangeLog finit.conf services
OBJS = finit.o conf.o helpers.o sig.o svc.o plugin.o
@@ -45,7 +46,8 @@ DEPS = $(addprefix .,$(SRCS:.c=.d))
prefix ?= /usr
sysconfdir ?= /etc
sbindir ?= /sbin
plugindir ?= /lib/finit/plugins
libdir ?= /lib
plugindir ?= $(libdir)/finit/plugins
incdir = $(prefix)/include/finit
datadir = $(prefix)/share/doc/finit
mandir = $(prefix)/share/man/man8
@@ -58,22 +60,28 @@ FINIT_RCSD ?= $(sysconfdir)/finit.d
CFLAGS += -W -Wall -Werror -Os
# Disable annoying gcc warning for "warn_unused_result", see GIT 37af997
CPPFLAGS += -U_FORTIFY_SOURCE
CPPFLAGS += -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_GNU_SOURCE
CPPFLAGS += -Ilibite -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_GNU_SOURCE
CPPFLAGS += -DVERSION=\"$(VERSION)\" -DWHOAMI=\"`whoami`@`hostname`\"
CPPFLAGS += -DFINIT_FIFO=\"$(FINIT_FIFO)\" -DFINIT_CONF=\"$(FINIT_CONF)\"
CPPFLAGS += -DFINIT_RCSD=\"$(FINIT_RCSD)\" -DPLUGIN_PATH=\"$(plugindir)\"
LDFLAGS += -rdynamic
LDLIBS += -ldl
LDFLAGS += -rdynamic -L$(ROOTDIR)/libite
DEPLIBS = libite/libite.so
LDLIBS += -ldl -lite
include common.mk
export plugindir ROOTDIR CPPFLAGS
export libdir plugindir incdir ROOTDIR CPPFLAGS LDFLAGS LDLIBS
all: Makefile $(EXEC)
all: $(DEPLIBS) $(EXEC)
$(MAKE) -C plugins $@
$(DEPLIBS): Makefile
$(MAKE) -C libite all
$(OBJS): Makefile
$(EXEC): $(OBJS)
finit: $(OBJS) $(DEPLIBS)
reboot: reboot.o $(DEPLIBS)
install-exec: all
@$(INSTALL) -d $(DESTDIR)$(FINIT_RCSD)
@@ -82,6 +90,7 @@ install-exec: all
printf " INSTALL $(DESTDIR)$(sbindir)/$$file\n"; \
$(STRIPINST) $$file $(DESTDIR)$(sbindir)/$$file; \
done
$(MAKE) -C libite install-exec
$(MAKE) -C plugins install
install-data:
@@ -98,6 +107,7 @@ install-dev:
printf " INSTALL $(DESTDIR)$(incdir)/$$file\n"; \
$(INSTALL) -m 0644 $$file $(DESTDIR)$(incdir)/$$file; \
done
$(MAKE) -C libite install-dev install-exec
install: install-exec install-data install-dev
@@ -108,6 +118,7 @@ uninstall-exec:
done
-@rmdir $(DESTDIR)$(sbindir) 2>/dev/null
-@rmdir $(DESTDIR)$(FINIT_RCSD) 2>/dev/null
$(MAKE) -C libite uninstall
$(MAKE) -C plugins uninstall
uninstall-data:
@@ -119,20 +130,18 @@ uninstall-data:
-@rmdir $(DESTDIR)$(datadir)
uninstall-dev:
-@for file in $(HEADERS); do \
printf " REMOVE $(DESTDIR)$(incdir)/$$file\n"; \
rm $(DESTDIR)$(incdir)/$$file 2>/dev/null; \
done
-@rmdir $(DESTDIR)$(incdir)
-@$(RM) -rf $(DESTDIR)$(incdir)
uninstall: uninstall-exec uninstall-data uninstall-dev
clean:
-@$(RM) $(OBJS) $(DEPS) $(EXEC)
$(MAKE) -C libite $@
$(MAKE) -C plugins $@
distclean: clean
-@$(RM) $(JUNK) unittest *.o
-@$(RM) $(JUNK) unittest *.o .*.d
$(MAKE) -C libite $@
$(MAKE) -C plugins $@
dist: