Skip to content

Commit

Permalink
Rewrite the core parts in C. We now provide librc so other programs can
Browse files Browse the repository at this point in the history
query runlevels, services and state without using bash. We also provide
libeinfo so other programs can easily use our informational functions.

As such, we have dropped the requirement of using bash as the init script
shell. We now use /bin/sh and have strived to make the scripts as portable
as possible. Shells that work are bash and dash. busybox works provided
you disable s-s-d. If you have WIPE_TMP set to yes in conf.d/bootmisc you
should disable find too.
zsh and ksh do not work at this time.

Networking support is currently being re-vamped also as it was heavily bash
array based. As such, a new config format is available like so
config_eth0="1.2.3.4/24 5.6.7.8/16"
or like so
config_eth0="'1.2.3.4 netmask 255.255.255.0' '5.6.7.8 netmask 255.255.0.0'"

We will still support the old bash array format provided that /bin/sh IS
a link it bash.

ChangeLog for baselayout-1 can be found in our SVN repo.
  • Loading branch information
rsmarples committed Apr 5, 2007
0 parents commit 5af58b4
Show file tree
Hide file tree
Showing 169 changed files with 20,917 additions and 0 deletions.
1 change: 1 addition & 0 deletions COPYRIGHT
@@ -0,0 +1 @@
Copyright 1996-2007 Gentoo Foundation
26 changes: 26 additions & 0 deletions ChangeLog
@@ -0,0 +1,26 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2

05 Apr 2007; Roy Marples <uberlord@gentoo.org>:

Rewrite the core parts in C. We now provide librc so other programs can
query runlevels, services and state without using bash. We also provide
libeinfo so other programs can easily use our informational functions.

As such, we have dropped the requirement of using bash as the init script
shell. We now use /bin/sh and have strived to make the scripts as portable
as possible. Shells that work are bash and dash. busybox works provided
you disable s-s-d. If you have WIPE_TMP set to yes in conf.d/bootmisc you
should disable find too.
zsh and ksh do not work at this time.

Networking support is currently being re-vamped also as it was heavily bash
array based. As such, a new config format is available like so
config_eth0="1.2.3.4/24 5.6.7.8/16"
or like so
config_eth0="'1.2.3.4 netmask 255.255.255.0' '5.6.7.8 netmask 255.255.0.0'"

We will still support the old bash array format provided that /bin/sh IS
a link it bash.

ChangeLog for baselayout-1 can be found in our SVN repo.
108 changes: 108 additions & 0 deletions Makefile
@@ -0,0 +1,108 @@
# baselayout Makefile
# Copyright 2006-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
#
# We've moved the installation logic from Gentoo ebuild into a generic
# Makefile so that the ebuild is much smaller and more simple.
# It also has the added bonus of being easier to install on systems
# without an ebuild style package manager.

SUBDIRS = conf.d etc init.d man net sh share src

NAME = baselayout
#VERSION = 2.0.0_alpha1
VERSION = 1.13.99

PKG = $(NAME)-$(VERSION)

ARCH = x86
ifeq ($(OS),)
OS=$(shell uname -s)
ifneq ($(OS),Linux)
OS=BSD
endif
endif

BASE_DIRS = /$(LIB)/rcscripts/init.d /$(LIB)/rcscripts/tmp
KEEP_DIRS = /boot /home /mnt /root \
/usr/local/bin /usr/local/sbin /usr/local/share/doc /usr/local/share/man \
/var/lock /var/run

ifeq ($(OS),Linux)
KEEP_DIRS += /dev /sys
NET_LO = net.lo
endif
ifneq ($(OS),Linux)
NET_LO = net.lo0
endif

TOPDIR = .
include $(TOPDIR)/default.mk

install::
# These dirs may not exist from prior versions
for x in $(BASE_DIRS) ; do \
$(INSTALL_DIR) $(DESTDIR)$$x || exit $$? ; \
touch $(DESTDIR)$$x/.keep || exit $$? ; \
done
# Don't install runlevels if they already exist
if ! test -d $(DESTDIR)/etc/runlevels ; then \
(cd runlevels; $(MAKE) install) ; \
test -d runlevels.$(OS) && (cd runlevels.$(OS); $(MAKE) install) ; \
$(INSTALL_DIR) $(DESTDIR)/etc/runlevels/single || exit $$? ; \
$(INSTALL_DIR) $(DESTDIR)/etc/runlevels/nonetwork || exit $$? ; \
fi
ln -snf ../../$(LIB)/rcscripts/sh/net.sh $(DESTDIR)/etc/init.d/$(NET_LO) || exit $$?
ln -snf ../../$(LIB)/rcscripts/sh/functions.sh $(DESTDIR)/etc/init.d || exit $$?
# Handle lib correctly
if test $(LIB) != "lib" ; then \
sed -i'.bak' -e 's,/lib/,/$(LIB)/,g' $(DESTDIR)/$(LIB)/rcscripts/sh/functions.sh || exit $$? ; \
rm -f $(DESTDIR)/$(LIB)/rcscripts/sh/functions.sh.bak ; \
fi

.PHONY: all clean install

layout:
# Create base filesytem layout
for x in $(KEEP_DIRS) ; do \
$(INSTALL_DIR) $(DESTDIR)$$x || exit $$? ; \
touch $(DESTDIR)$$x/.keep || exit $$? ; \
done
# Special dirs
install -m 0700 -d $(DESTDIR)/root || exit $$?
touch $(DESTDIR)/root/.keep || exit $$?
install -m 1777 -d $(DESTDIR)/var/tmp || exit $$?
touch $(DESTDIR)/var/tmp/.keep || exit $$?
install -m 1777 -d $(DESTDIR)/tmp || exit $$?
touch $(DESTDIR)/tmp/.keep || exit $$?
# FHS compatibility symlinks stuff
ln -snf /var/tmp $(DESTDIR)/usr/tmp || exit $$?
ln -snf share/man $(DESTDIR)/usr/local/man || exit $$?

distcheck:
if test -d .svn ; then \
svnfiles=`svn status 2>&1 | egrep -v '^(U|P)'` ; \
if test "x$$svnfiles" != "x" ; then \
echo "Refusing to package tarball until svn is in sync:" ; \
echo "$$svnfiles" ; \
echo "make distforce to force packaging" ; \
exit 1 ; \
fi \
fi

distforce:
install -d /tmp/$(PKG)
cp -PRp . /tmp/$(PKG)
`which find` /tmp/$(PKG) -depth -path "*/.svn/*" -delete
`which find` /tmp/$(PKG) -depth -path "*/.svn" -delete
rm -rf /tmp/$(PKG)/src/core /tmp/$(PKG)/po
$(MAKE) -C /tmp/$(PKG) clean
sed -i'.bak' -e '/-Wl,-rpath ./ s/^/#/g' /tmp/$(PKG)/src/Makefile
rm -f /tmp/$(PKG)/src/Makefile.bak
tar -C /tmp -cvjpf /tmp/$(PKG).tar.bz2 $(PKG)
rm -Rf /tmp/$(PKG)
du /tmp/$(PKG).tar.bz2

dist: distcheck distforce

# vim: set ts=4 :
53 changes: 53 additions & 0 deletions STYLE
@@ -0,0 +1,53 @@
This is the rc-scripts style manual. It governs the coding style
of rc-scripts. Everything here might as well have been spoken by
God. If you find any issues, please talk to base-system@gentoo.org
or #gentoo-base on irc.freenode.net.

#############
# VARIABLES #
#############
- User Variables -
Variables must always be enclosed by {}
e.g. ${foo} ${bar}
- Internal Shell Variables -
Do not use {} with internal variables unless appropriate
e.g. case $1 in
e.g. foo=$IFS
e.g. echo "blah${1}123"
- Assigning with Quotes -
When assigning to a variable from another variable, you should
not need quotes. However, you do when assigning from a subshell.
e.g. foo=${bar}
e.g. foo="$(uname -a)"

#########
# TESTS #
#########
- Brackets -
Always use the [ ... ] form instead of [[ ... ]] as the later only really
works in bash, and we should support as many shells as we can.
- Quoting -
When dealing with strings, you should quote both sides.

###############
# CODE BLOCKS #
###############
- Structure -
Use the more compact form
e.g. if ... ; then
e.g. while ... ; do
Do not use the older form
e.g. if ...
then
- Functions -
Use the more compact form
e.g. foo() {
Do not lead with 'function '
e.g. function foo() {

############
# COMMENTS #
############
- General -
Try to include a comment block before sections
of code to explain what you're attempting
5 changes: 5 additions & 0 deletions conf.d.BSD/Makefile
@@ -0,0 +1,5 @@
DIR = /etc/conf.d
FILES = localmount net.example wireless.example

TOPDIR = ..
include $(TOPDIR)/default.mk
31 changes: 31 additions & 0 deletions conf.d.BSD/localmount
@@ -0,0 +1,31 @@
# /etc/conf.d/localmount

# Kernel core dump options for FreeBSD kernel.
# Unless you're a FreeBSD kernel developer or driver writer then this won't
# be of any interest to you at all.

# The following options allow to configure the kernel's core dump
# facilities. Please read
# http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/kerneldebug.html
# for more information about Kernel core dumps and kernel debugging.

# KERNEL_DUMP_DEVICE variable is used to specify which device will be
# used by the kernel to write the dump down. This has to be a swap
# partition, and has to be at least big enough to contain the whole
# physical memory (see hw.physmem sysctl(8) variable).
# When the variable is commented out, no core dump will be enabled for
# the kernel.
#KERNEL_DUMP_DEVICE="/dev/ad0s1b"

# KERNEL_DUMP_DIR variable is used to tell savecore(8) utility where
# to save the kernel core dump once it's restored from the dump
# device. If unset, /var/crash will be used, as the default of
# FreeBSD.
#KERNEL_DUMP_DIR="/var/crash"

# KERNEL_DUMP_COMPRESS variable decide whether to compress with
# gzip(1) the dump or leave it of its original size (the size of the
# physical memory present on the system). If set to yes, the -z option
# will be passed to savecore(8) that will proceed on compressing the
# dump.
#KERNEL_DUMP_COMPRESS="no"

0 comments on commit 5af58b4

Please sign in to comment.