All our binaries are now mulicalls into rc, which makes our on disk size

a lot smaller.
This commit is contained in:
Roy Marples 2007-07-31 16:05:56 +00:00
parent 02fcdeede4
commit c674026f9e
12 changed files with 124 additions and 89 deletions

View File

@ -1,6 +1,11 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2
31 Jul 2007; Roy Marples <uberlord@gentoo.org>:
All our binaries are now mulicalls into rc, which makes our on disk size
a lot smaller.
23 Jul 2007; Roy Marples <uberlord@gentoo.org>:
appending noinitd=xdm will skip the xdm service when first booting, #181858.

View File

@ -30,12 +30,12 @@ LIBEINFOOBJS= libeinfo.o
LIBRCSOVER = 0
LIBRCSO = librc.so.$(LIBRCSOVER)
LIBRCOBJS= librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o
LIBRCOBJS= librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o \
env-update.o fstabinfo.o mountinfo.o \
rc-depend.o rc-status.o runscript.o start-stop-daemon.o
LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO)
BIN_TARGETS = rc-status
SBIN_TARGETS = env-update rc rc-update runscript start-stop-daemon
PRIV_BIN_TARGETS = fstabinfo mountinfo rc-depend
SBIN_TARGETS = rc
SYS_WHITELIST = env_whitelist
TARGET = $(LIB_TARGETS) $(BIN_TARGETS) $(SBIN_TARGETS) $(PRIV_BIN_TARGETS)
@ -51,8 +51,11 @@ RCLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
mark_service_stopping mark_service_stopped \
mark_service_inactive mark_service_wasinactive \
mark_service_coldplugged \
get_options save_options rc-abort \
is_runlevel_start is_runlevel_stop service_started_daemon
get_options save_options rc-abort rc-depend \
is_runlevel_start is_runlevel_stop service_started_daemon \
fstabinfo mountinfo
BINLINKS = rc-status
SBINLINKS = env-update rc-update runscript start-stop-daemon
# Quick hack to make my life easier on BSD and Linux
ifeq ($(OS),)
@ -129,7 +132,7 @@ start-stop-daemon: LDLIBS += $(LDLIBS_SSD)
start-stop-daemon: $(LIBEINFOSO) $(LIBRCSO) start-stop-daemon.o
links: rc
for x in $(RCLINKS) $(RCPRIVLINKS); do ln -sf rc $$x; done
for x in $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS); do ln -sf rc $$x; done
install: $(TARGET)
install -m 0755 -d $(DESTDIR)/$(LIB)
@ -139,14 +142,14 @@ install: $(TARGET)
install -m 0755 -d $(DESTDIR)/usr/include
install -m 0644 einfo.h rc.h $(DESTDIR)/usr/include
install -m 0755 -d $(DESTDIR)/bin
install -m 0755 $(BIN_TARGETS) $(DESTDIR)/bin
install -m 0755 -d $(DESTDIR)/sbin
install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin
ln -sf rc-update $(DESTDIR)/sbin/update-rc
install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/conf.d
install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(LIB)/rcscripts/conf.d
install -m 0755 -d $(DESTDIR)/$(LIB)/rcscripts/bin
install -m 0755 $(PRIV_BIN_TARGETS) $(DESTDIR)/$(LIB)/rcscripts/bin
for x in $(BINLINKS); do ln -sf $(DESTDIR)/sbin/rc $(DESTDIR)/bin/$$x; done
for x in $(SBINLINKS); do ln -sf $(DESTDIR)/sbin/rc $(DESTDIR)/sbin/$$x; done
for x in $(RCLINKS); do ln -sf $(DESTDIR)/sbin/rc $(DESTDIR)/$(LIB)/rcscripts/bin/$$x; done
if test "$(HAVE_PAM)" != "" ; then \
install -m 0755 -d $(DESTDIR)/etc/pam.d ; \
@ -154,7 +157,7 @@ install: $(TARGET)
fi
clean:
rm -f $(TARGET) $(RCLINKS) $(RCPRIVLINKS)
rm -f $(TARGET) $(BINLINKS) $(SBINLINKS) $(RCLINKS) $(RCPRIVLINKS)
rm -f *.o *~ *.core *.so .depend
-include .depend

View File

@ -22,6 +22,7 @@
#include <string.h>
#include <unistd.h>
#include "builtins.h"
#include "einfo.h"
#include "rc.h"
#include "rc-misc.h"
@ -82,7 +83,7 @@ static struct option longopts[] = {
};
#include "_usage.c"
int main (int argc, char **argv)
int env_update (int argc, char **argv)
{
char **files = rc_ls_dir (NULL, ENVDIR, 0);
char *file;

View File

@ -41,6 +41,7 @@
#define ENT_PASS(_ent) ent->fs_passno
#endif
#include "builtins.h"
#include "einfo.h"
#ifdef HAVE_GETMNTENT
@ -68,7 +69,7 @@ static struct option longopts[] = {
};
#include "_usage.c"
int main (int argc, char **argv)
int fstabinfo (int argc, char **argv)
{
#ifdef HAVE_GETMNTENT
FILE *fp;

View File

@ -27,6 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include "builtins.h"
#include "einfo.h"
#include "rc.h"
#include "rc-misc.h"
@ -175,7 +176,7 @@ static struct option longopts[] = {
};
#include "_usage.c"
int main (int argc, char **argv)
int mountinfo (int argc, char **argv)
{
int i;
regex_t *fstype_regex = NULL;

View File

@ -13,12 +13,13 @@
#include <stdlib.h>
#include <string.h>
#include "builtins.h"
#include "einfo.h"
#include "rc.h"
#include "rc-misc.h"
#include "strlist.h"
int main (int argc, char **argv)
int rc_depend (int argc, char **argv)
{
char **types = NULL;
char **services = NULL;

View File

@ -31,4 +31,48 @@
/* Good defaults just incase user has none set */
#define RC_NET_FS_LIST_DEFAULT "afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs"
/* RC utility functions.
Although not directly related to RC in general, they are used by RC
itself and the supporting applications. */
void *rc_xcalloc (size_t n, size_t size);
void *rc_xmalloc (size_t size);
void *rc_xrealloc (void *ptr, size_t size);
char *rc_xstrdup (const char *str);
/* Concat paths adding '/' if needed. */
char *rc_strcatpaths (const char *path1, const char *paths, ...) SENTINEL;
bool rc_is_env (const char *variable, const char *value);
bool rc_exists (const char *pathname);
bool rc_is_file (const char *pathname);
bool rc_is_link (const char *pathname);
bool rc_is_dir (const char *pathname);
bool rc_is_exec (const char *pathname);
#define RC_LS_INITD 0x01
char **rc_ls_dir (char **list, const char *dir, int options);
bool rc_rm_dir (const char *pathname, bool top);
/* Config file functions */
char **rc_get_list (char **list, const char *file);
char **rc_get_config (char **list, const char *file);
char *rc_get_config_entry (char **list, const char *entry);
/* Make an environment list which filters out all unwanted values
and loads it up with our RC config */
char **rc_filter_env (void);
char **rc_config_env (char **env);
/* Handy functions for dealing with string arrays of char ** */
char **rc_strlist_add (char **list, const char *item);
char **rc_strlist_addu (char **list, const char *item);
char **rc_strlist_addsort (char **list, const char *item);
char **rc_strlist_addsortc (char **list, const char *item);
char **rc_strlist_addsortu (char **list, const char *item);
char **rc_strlist_delete (char **list, const char *item);
char **rc_strlist_join (char **list1, char **list2);
void rc_strlist_reverse (char **list);
void rc_strlist_free (char **list);
#endif

View File

@ -5,19 +5,20 @@
Released under the GPLv2
*/
#define APPLET "rc-status"
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "builtins.h"
#include "einfo.h"
#include "rc.h"
#include "rc-misc.h"
#include "strlist.h"
#define APPLET "rc-status"
static void print_level (char *level)
{
printf ("Runlevel: %s%s%s\n",
@ -55,7 +56,7 @@ static void print_service (char *service)
#include "_usage.h"
#define getoptstring "alsu" getoptstring_COMMON
const struct option longopts[] = {
static const struct option longopts[] = {
{"all", 0, NULL, 'a'},
{"list", 0, NULL, 'l'},
{"servicelist", 0, NULL, 's'},
@ -65,7 +66,7 @@ const struct option longopts[] = {
};
#include "_usage.c"
int main (int argc, char **argv)
int rc_status (int argc, char **argv)
{
char **levels = NULL;
char **services = NULL;

View File

@ -30,6 +30,7 @@
#include <termios.h>
#include <unistd.h>
#include "builtins.h"
#include "einfo.h"
#include "rc.h"
#include "rc-misc.h"
@ -82,35 +83,37 @@ static pidlist_t *service_pids = NULL;
static void cleanup (void)
{
pidlist_t *pl = service_pids;
if (applet && strcmp (applet, "rc") == 0) {
pidlist_t *pl = service_pids;
rc_plugin_unload ();
rc_plugin_unload ();
if (! rc_in_plugin && termios_orig) {
tcsetattr (fileno (stdin), TCSANOW, termios_orig);
free (termios_orig);
}
if (! rc_in_plugin && termios_orig) {
tcsetattr (fileno (stdin), TCSANOW, termios_orig);
free (termios_orig);
}
while (pl) {
pidlist_t *p = pl->next;
free (pl);
pl = p;
}
while (pl) {
pidlist_t *p = pl->next;
free (pl);
pl = p;
}
rc_strlist_free (env);
rc_strlist_free (newenv);
rc_strlist_free (coldplugged_services);
rc_strlist_free (stop_services);
rc_strlist_free (start_services);
rc_free_deptree (deptree);
rc_strlist_free (types);
rc_strlist_free (env);
rc_strlist_free (newenv);
rc_strlist_free (coldplugged_services);
rc_strlist_free (stop_services);
rc_strlist_free (start_services);
rc_free_deptree (deptree);
rc_strlist_free (types);
/* Clean runlevel start, stop markers */
if (! rc_in_plugin) {
if (rc_is_dir (RC_SVCDIR "softscripts.new"))
rc_rm_dir (RC_SVCDIR "softscripts.new", true);
if (rc_is_dir (RC_SVCDIR "softscripts.old"))
rc_rm_dir (RC_SVCDIR "softscripts.old", true);
/* Clean runlevel start, stop markers */
if (! rc_in_plugin) {
if (rc_is_dir (RC_SVCDIR "softscripts.new"))
rc_rm_dir (RC_SVCDIR "softscripts.new", true);
if (rc_is_dir (RC_SVCDIR "softscripts.old"))
rc_rm_dir (RC_SVCDIR "softscripts.old", true);
}
}
free (applet);
@ -695,12 +698,30 @@ int main (int argc, char **argv)
char pidstr[6];
int opt;
atexit (cleanup);
if (argv[0])
applet = rc_xstrdup (basename (argv[0]));
if (! applet)
eerrorx ("arguments required");
/* These used to be programs in their own right, so we shouldn't
* touch argc or argv for them */
if (strcmp (applet, "env-update") == 0)
exit (env_update (argc, argv));
else if (strcmp (applet, "fstabinfo") == 0)
exit (fstabinfo (argc, argv));
else if (strcmp (applet, "mountinfo") == 0)
exit (mountinfo (argc, argv));
else if (strcmp (applet, "rc-depend") == 0)
exit (rc_depend (argc, argv));
else if (strcmp (applet, "rc-status") == 0)
exit (rc_status (argc, argv));
else if (strcmp (applet, "runscript") == 0)
exit (runscript (argc, argv));
else if (strcmp (applet, "start-stop-daemon") == 0)
exit (start_stop_daemon (argc, argv));
argc--;
argv++;
@ -739,8 +760,6 @@ int main (int argc, char **argv)
if (strcmp (applet, "rc" ) != 0)
eerrorx ("%s: unknown applet", applet);
atexit (cleanup);
/* Change dir to / to ensure all scripts don't use stuff in pwd */
chdir ("/");

View File

@ -164,48 +164,5 @@ typedef enum
* they wish. At this time we only support the setting of one env var. */
extern FILE *rc_environ_fd;
/* RC utility functions.
Although not directly related to RC in general, they are used by RC
itself and the supporting applications. */
void *rc_xcalloc (size_t n, size_t size);
void *rc_xmalloc (size_t size);
void *rc_xrealloc (void *ptr, size_t size);
char *rc_xstrdup (const char *str);
/* Concat paths adding '/' if needed. */
char *rc_strcatpaths (const char *path1, const char *paths, ...) SENTINEL;
bool rc_is_env (const char *variable, const char *value);
bool rc_exists (const char *pathname);
bool rc_is_file (const char *pathname);
bool rc_is_link (const char *pathname);
bool rc_is_dir (const char *pathname);
bool rc_is_exec (const char *pathname);
#define RC_LS_INITD 0x01
char **rc_ls_dir (char **list, const char *dir, int options);
bool rc_rm_dir (const char *pathname, bool top);
/* Config file functions */
char **rc_get_list (char **list, const char *file);
char **rc_get_config (char **list, const char *file);
char *rc_get_config_entry (char **list, const char *entry);
/* Make an environment list which filters out all unwanted values
and loads it up with our RC config */
char **rc_filter_env (void);
char **rc_config_env (char **env);
/* Handy functions for dealing with string arrays of char ** */
char **rc_strlist_add (char **list, const char *item);
char **rc_strlist_addu (char **list, const char *item);
char **rc_strlist_addsort (char **list, const char *item);
char **rc_strlist_addsortc (char **list, const char *item);
char **rc_strlist_addsortu (char **list, const char *item);
char **rc_strlist_delete (char **list, const char *item);
char **rc_strlist_join (char **list1, char **list2);
void rc_strlist_reverse (char **list);
void rc_strlist_free (char **list);
#endif

View File

@ -24,6 +24,7 @@
#include <string.h>
#include <unistd.h>
#include "builtins.h"
#include "einfo.h"
#include "rc.h"
#include "rc-misc.h"
@ -977,7 +978,7 @@ static struct option longopts[] = {
};
// #include "_usage.c"
int main (int argc, char **argv)
int runscript (int argc, char **argv)
{
int i;
bool deps = true;

View File

@ -40,6 +40,7 @@
static struct pam_conv conv = { NULL, NULL} ;
#endif
#include "builtins.h"
#include "einfo.h"
#include "rc.h"
#include "rc-misc.h"
@ -475,7 +476,7 @@ static void handle_signal (int sig)
errno = serrno;
}
int main (int argc, char **argv)
int start_stop_daemon (int argc, char **argv)
{
int devnull_fd = -1;