diff options
Diffstat (limited to 'package/base-files')
26 files changed, 417 insertions, 0 deletions
diff --git a/package/base-files/Config.in b/package/base-files/Config.in new file mode 100644 index 000000000..8312e2ee2 --- /dev/null +++ b/package/base-files/Config.in @@ -0,0 +1,16 @@ +config ADK_PACKAGE_BASE_FILES + prompt "base-files........................... basic filesystem layout" + bool + default y + help + Basic filesystem layout. + +config ADK_PACKAGE_CONFIG_IN_ETC + prompt ".config in /etc...................... include gzipped version of .config in image" + bool + default y + help + Copy the configuration file (.config) to the image. The + file will be found in /etc/adkconfig.gz. This takes about + 7kBytes of file system space. From this file you can always rebuild + the image from source. diff --git a/package/base-files/Makefile b/package/base-files/Makefile new file mode 100644 index 000000000..8d07473d7 --- /dev/null +++ b/package/base-files/Makefile @@ -0,0 +1,72 @@ +# $Id$ +#- +# This file is part of the OpenADK project. OpenADK is copyrighted +# material, please see the LICENCE file in the top-level directory. + +include $(TOPDIR)/rules.mk +include $(TOPDIR)/mk/rootfs.mk + +PKG_NAME:= base-files +PKG_VERSION:= 1.0 +PKG_RELEASE:= 5 +WRKDIST= ${WRKDIR}/base-files +NO_DISTFILES:= 1 +ifeq ($(CPU_ARCH),x86_64) +PKG_ID= x86-64-${FS} +else +PKG_ID= ${DEVICE}-${FS} +endif +WRKDIR= ${WRKDIR_BASE}/w-${PKG_NAME}-${PKG_VERSION}-${PKG_RELEASE}-${PKG_ID} +ICONTROL_BASE_FILES= ipkg/base-files.control +ICONTROL_ADDON_BASE_FILES= "Package: base-files-${PKG_ID}" + +include $(TOPDIR)/mk/package.mk + +$(eval $(call PKG_template,BASE_FILES,base-files-${PKG_ID},${PKG_VERSION}-${PKG_RELEASE},${ARCH})) + +do-install: + $(CP) ./files/* $(IDIR_BASE_FILES) + $(CP) $(TOPDIR)/target/$(DEVICE)/files/* $(IDIR_BASE_FILES) + typeset -i REV; \ + if fgrep xml .svn/entries >/dev/null 2>&1; then \ + let REV="$$(sed -n '/revision=/s/^.*"\([0-9]*\)".*$$/\1/p' \ + .svn/entries)"; \ + else \ + let REV="$$(head -n 4 .svn/entries | tail -1)"; \ + fi; ${SED} 's,$$R,'$$REV,g $(IDIR_BASE_FILES)/etc/banner + $(SED) 's,@TARGET@,$(DEVICE),g' $(IDIR_BASE_FILES)/etc/ipkg.conf + $(SED) 's,@VERSION@,$(ADK_VERSION),g' $(IDIR_BASE_FILES)/etc/ipkg.conf + echo /bin/sh >${IDIR_BASE_FILES}/etc/shells + echo /bin/ash >>${IDIR_BASE_FILES}/etc/shells +ifneq (${ADK_PACKAGE_BASH},) + echo /bin/bash >>${IDIR_BASE_FILES}/etc/shells +endif +ifneq (${ADK_PACKAGE_MKSH},) + echo /bin/mksh >>${IDIR_BASE_FILES}/etc/shells +endif +ifneq (${ADK_PACKAGE_ZSH},) + echo /bin/zsh >>${IDIR_BASE_FILES}/etc/shells +endif + mkdir -p $(IDIR_BASE_FILES)/dev + mkdir -p $(IDIR_BASE_FILES)/boot + mkdir -p $(IDIR_BASE_FILES)/root + mkdir -p $(IDIR_BASE_FILES)/sys + mkdir -p $(IDIR_BASE_FILES)/etc/crontabs + mkdir -p $(IDIR_BASE_FILES)/mnt + mkdir -p $(IDIR_BASE_FILES)/proc + mkdir -p $(IDIR_BASE_FILES)/tmp + mkdir -p $(IDIR_BASE_FILES)/usr/lib + mkdir -p $(IDIR_BASE_FILES)/usr/bin + chmod 755 $(IDIR_BASE_FILES)/lib/mdev/init + ln -sf ../tmp/resolv.conf $(IDIR_BASE_FILES)/etc/resolv.conf + ln -sf ../proc/mounts $(IDIR_BASE_FILES)/etc/mtab + rm -rf $(IDIR_BASE_FILES)/var + ln -sf tmp $(IDIR_BASE_FILES)/var + -find $(IDIR_BASE_FILES) -type d -name CVS | xargs rm -rf + -find $(IDIR_BASE_FILES) -type d -name .svn | xargs rm -rf + -find $(IDIR_BASE_FILES) -name '.#*' | xargs rm -f +ifneq (${ADK_PACKAGE_CONFIG_IN_ETC},) + gzip -9c ${TOPDIR}/.config >$(IDIR_BASE_FILES)/etc/adkconfig.gz +endif + +include ${TOPDIR}/mk/pkg-bottom.mk diff --git a/package/base-files/files/etc/banner b/package/base-files/files/etc/banner new file mode 100644 index 000000000..bdee76e22 --- /dev/null +++ b/package/base-files/files/etc/banner @@ -0,0 +1,3 @@ + + Linux created with OpenADK + --- build from revision $R --- diff --git a/package/base-files/files/etc/functions.sh b/package/base-files/files/etc/functions.sh new file mode 100644 index 000000000..4d225b882 --- /dev/null +++ b/package/base-files/files/etc/functions.sh @@ -0,0 +1,79 @@ +# newline +N=" +" + +append() { + local var="$1" + local value="$2" + local sep="${3:- }" + + eval "export -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\"" +} + +load_modules() { + (sed "s,^[^#][^[:space:]]*,insmod /lib/modules/$(uname -r)/&.ko," $* | sh 2>&- || :) +} + +user_exists() { + grep -q "^$1:" $IPKG_INSTROOT/etc/passwd 2>&- +} + +group_exists() { + grep -q "^$1:" $IPKG_INSTROOT/etc/group 2>&- +} + +service_exists() { + grep -q "^$1[[:space:]]*$2" $IPKG_INSTROOT/etc/services 2>&- +} + +rcconf_exists() { + grep -q "^#*$1=" $IPKG_INSTROOT/etc/rc.conf 2>&- +} + +add_user() { + user_exists $1 || { + echo "adding user $1 to /etc/passwd" + echo "$1:x:$2:${3:-$2}:$1:${4:-/tmp}:${5:-/bin/false}" \ + >>$IPKG_INSTROOT/etc/passwd + } +} + +add_group() { + group_exists $1 || { + echo "adding group $1 to /etc/group" + echo "$1:x:$2:$3" >>$IPKG_INSTROOT/etc/group + } +} + +add_service() { + service_exists $1 $2 || { + echo "adding service $1 to /etc/services" + printf '%s\t%s\n' "$1" "$2" >>$IPKG_INSTROOT/etc/services + } +} + +add_rcconf() { + rcconf_exists ${2-$1} || { + echo "adding service ${2-$1} to /etc/rc.conf" + printf '%s\t\t# %s\n' "${2:-$1}=${3:-NO}" "$1" \ + >>$IPKG_INSTROOT/etc/rc.conf + } +} + +get_next_uid() { + uid=1 + while grep "^[^:]*:[^:]*:$uid:" $IPKG_INSTROOT/etc/passwd \ + >/dev/null 2>&1; do + let uid++ + done + echo $uid +} + +get_next_gid() { + gid=1 + while grep "^[^:]*:[^:]*:$gid:" $IPKG_INSTROOT/etc/group \ + >/dev/null 2>&1; do + let gid++ + done + echo $gid +} diff --git a/package/base-files/files/etc/group b/package/base-files/files/etc/group new file mode 100644 index 000000000..1f444a8bf --- /dev/null +++ b/package/base-files/files/etc/group @@ -0,0 +1,3 @@ +root:x:0: +admin:x:100: +nogroup:x:65534: diff --git a/package/base-files/files/etc/hosts b/package/base-files/files/etc/hosts new file mode 100644 index 000000000..87d837fc7 --- /dev/null +++ b/package/base-files/files/etc/hosts @@ -0,0 +1,2 @@ +::1 localhost +127.0.0.1 localhost diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot new file mode 100644 index 000000000..c81d7ea65 --- /dev/null +++ b/package/base-files/files/etc/init.d/boot @@ -0,0 +1,27 @@ +#!/bin/sh +#FWINIT 10 +[[ $1 = autostart ]] || exit 0 + +. /etc/functions.sh + +mkdir -p /var/log +mkdir -p /var/run +touch /var/log/lastlog +touch /var/log/wtmp +ln -s /var/tmp /tmp + +echo 0 > /proc/sys/kernel/printk + +HOSTNAME= +[[ -s /etc/hostname ]] && HOSTNAME=$(cat /etc/hostname) +HOSTNAME=${HOSTNAME%%.*} +echo ${HOSTNAME:=linux} >/proc/sys/kernel/hostname + +chown 0:0 /tmp; chmod 1777 /tmp + +load_modules /etc/modules +for f in /etc/modules.d/*; do + [[ -e $f ]] && load_modules /etc/modules.d/* + break +done +exit 0 diff --git a/package/base-files/files/etc/init.d/done b/package/base-files/files/etc/init.d/done new file mode 100644 index 000000000..018d52a43 --- /dev/null +++ b/package/base-files/files/etc/init.d/done @@ -0,0 +1,4 @@ +#!/bin/sh +#FWINIT 98 +[[ $1 = autostart ]] && sysctl -p >&- +exit 0 diff --git a/package/base-files/files/etc/init.d/rcK b/package/base-files/files/etc/init.d/rcK new file mode 100755 index 000000000..3cf210fa7 --- /dev/null +++ b/package/base-files/files/etc/init.d/rcK @@ -0,0 +1,21 @@ +#!/bin/sh +export PATH=/bin:/sbin:/usr/bin:/usr/sbin +busybox reboot -d 60 -f & # just in caseā¦ +{ + [[ -f /proc/diag/led/power ]] && echo f >/proc/diag/led/power + test -e /etc/rc.shutdown && (/bin/sh /etc/rc.shutdown) 2>&1 + grep '^#FWINIT ' /etc/init.d/* | \ + sort -rnk2 | \ + while read line; do + shebang=$(sed -n '1s/^#![ ]*//p' ${line%%:*}) + case $shebang in + *[\ \ ]*) shebang=\'$(echo X"$shebang" | sed \ + -e 's/^X//' -e "s/'/'\\\\''/g" \ + -e 's/^\([^ ][^ ]*\)[ ]*$/\1/' \ + -e 's/^\([^ ][^ ]*\)[ ][ ]*\(..*\)$/\1 \2/' \ + -e 's/^\([^ ][^ ]*\) /\1'\'' '\''/')\' ;; + esac + ${shebang:-/bin/sh} ${line%%:*} autostop 2>&1 + done + [[ -f /proc/diag/led/power ]] && echo 0 >/proc/diag/led/power +} | logger -s -p 6 -t '' diff --git a/package/base-files/files/etc/init.d/rcS b/package/base-files/files/etc/init.d/rcS new file mode 100755 index 000000000..f9c47e425 --- /dev/null +++ b/package/base-files/files/etc/init.d/rcS @@ -0,0 +1,10 @@ +#!/bin/sh +export PATH=/bin:/sbin:/usr/bin:/usr/sbin +{ + grep '^#FWINIT ' /etc/init.d/* | \ + sort -nk2 | \ + while read line; do + /bin/sh ${line%%:*} autostart 2>&1 + done + test -e /etc/init.d/boot.local && (/bin/sh /etc/init.d/boot.local) 2>&1 +} | logger -s -p 6 -t '' & diff --git a/package/base-files/files/etc/inittab b/package/base-files/files/etc/inittab new file mode 100644 index 000000000..960ea77d8 --- /dev/null +++ b/package/base-files/files/etc/inittab @@ -0,0 +1,4 @@ +::sysinit:/etc/init.d/rcS +::shutdown:/etc/init.d/rcK +ttyS0::respawn:/sbin/getty -i -L ttyS0 115200 vt100 + diff --git a/package/base-files/files/etc/ipkg.conf b/package/base-files/files/etc/ipkg.conf new file mode 100644 index 000000000..6f3a8be2d --- /dev/null +++ b/package/base-files/files/etc/ipkg.conf @@ -0,0 +1,3 @@ +src openadk http://waldemar-brodkorb.de/openadk/downloads/@TARGET@/packages +dest root / +dest ram /tmp diff --git a/package/base-files/files/etc/mdev.conf b/package/base-files/files/etc/mdev.conf new file mode 100644 index 000000000..61b818523 --- /dev/null +++ b/package/base-files/files/etc/mdev.conf @@ -0,0 +1,11 @@ +tun 0:0 660 >net/tun +null 0:0 777 +zero 0:0 666 +console 0:0 0600 +kmem 0:0 000 +mem 0:0 0640 +port 0:0 0640 +ptmx 0:0 666 +tty 0:0 0660 +ttyS* 0:0 640 +.* 0:0 644 @/lib/mdev/init diff --git a/package/base-files/files/etc/modules b/package/base-files/files/etc/modules new file mode 100644 index 000000000..014f40f2b --- /dev/null +++ b/package/base-files/files/etc/modules @@ -0,0 +1 @@ +# add modules to load on startup here diff --git a/package/base-files/files/etc/network/interfaces b/package/base-files/files/etc/network/interfaces new file mode 100644 index 000000000..f1bd92ed2 --- /dev/null +++ b/package/base-files/files/etc/network/interfaces @@ -0,0 +1,2 @@ +auto lo +iface lo inet loopback diff --git a/package/base-files/files/etc/passwd b/package/base-files/files/etc/passwd new file mode 100644 index 000000000..87eee84af --- /dev/null +++ b/package/base-files/files/etc/passwd @@ -0,0 +1,3 @@ +root:x:0:0:root:/root:/bin/sh +admin:x:100:100:admin:/tmp:/bin/sh +nobody:*:65534:65534:nobody:/var:/bin/false diff --git a/package/base-files/files/etc/profile b/package/base-files/files/etc/profile new file mode 100644 index 000000000..55002b01f --- /dev/null +++ b/package/base-files/files/etc/profile @@ -0,0 +1,12 @@ +export PATH=/bin:/sbin:/usr/bin:/usr/sbin +if [[ $(id -u) = 0 ]]; then + export PS1='# ' +else + export PS1='$ ' +fi +export HOME=/tmp +cat /etc/banner 2>&- +[ -x /usr/bin/less ] || alias less=more +[ -x /usr/bin/vim ] || alias vim=vi +[ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; } +[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 /lib/ld.so "$@"; } diff --git a/package/base-files/files/etc/protocols b/package/base-files/files/etc/protocols new file mode 100644 index 000000000..dfe58ed22 --- /dev/null +++ b/package/base-files/files/etc/protocols @@ -0,0 +1,45 @@ +ip 0 IP +icmp 1 ICMP +igmp 2 IGMP +ggp 3 GGP +ipencap 4 IP-ENCAP +st 5 ST +tcp 6 TCP +egp 8 EGP +igp 9 IGP +pup 12 PUP +udp 17 UDP +hmp 20 HMP +xns-idp 22 XNS-IDP +rdp 27 RDP +iso-tp4 29 ISO-TP4 +xtp 36 XTP +ddp 37 DDP +idpr-cmtp 38 IDPR-CMTP +ipv6 41 IPv6 +ipv6-route 43 IPv6-Route +ipv6-frag 44 IPv6-Frag +idrp 45 IDRP +rsvp 46 RSVP +gre 47 GRE +esp 50 IPSEC-ESP +ah 51 IPSEC-AH +skip 57 SKIP +ipv6-icmp 58 IPv6-ICMP +ipv6-nonxt 59 IPv6-NoNxt +ipv6-opts 60 IPv6-Opts +rspf 73 RSPF CPHB +vmtp 81 VMTP +eigrp 88 EIGRP +ospf 89 OSPFIGP +ax.25 93 AX.25 +ipip 94 IPIP +etherip 97 ETHERIP +encap 98 ENCAP +pim 103 PIM +ipcomp 108 IPCOMP +vrrp 112 VRRP +l2tp 115 L2TP +isis 124 ISIS +sctp 132 SCTP +fc 133 FC diff --git a/package/base-files/files/etc/rc.conf b/package/base-files/files/etc/rc.conf new file mode 100644 index 000000000..024007589 --- /dev/null +++ b/package/base-files/files/etc/rc.conf @@ -0,0 +1,3 @@ +# set variables service=YES|NO (YES to enable, NO to disable) +# set variables service_flags="X" (NO to disable the service) +# note: for flags, X can be empty diff --git a/package/base-files/files/etc/shadow b/package/base-files/files/etc/shadow new file mode 100644 index 000000000..3683d71ea --- /dev/null +++ b/package/base-files/files/etc/shadow @@ -0,0 +1,3 @@ +root:$1$8sJkb6fV$46vEIu5ntmbUuljmr55zY/:14191:0::::: +admin:$1$8sJkb6fV$46vEIu5ntmbUuljmr55zY/:14191:0::::: +nobody:*:9797:0::::: diff --git a/package/base-files/files/etc/sysctl.conf b/package/base-files/files/etc/sysctl.conf new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/package/base-files/files/etc/sysctl.conf diff --git a/package/base-files/files/init b/package/base-files/files/init new file mode 100755 index 000000000..567993cbb --- /dev/null +++ b/package/base-files/files/init @@ -0,0 +1,18 @@ +#!/bin/sh +export PATH=/bin:/sbin:/usr/bin:/usr/sbin +mount -nt proc proc /proc +mount -o nosuid,nodev,noexec -t sysfs sysfs /sys +mount none /tmp -t tmpfs -o size=2M +mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777 +mount -o nosuid,size=64k,mode=0755 -t tmpfs mdev /dev +mkdir /dev/pts /dev/shm +mount -o nosuid,noexec -t devpts devpts /dev/pts +exec 0<>/dev/console >&0 2>&0 +echo >/dev/mdev.seq +echo "/sbin/mdev" >/proc/sys/kernel/hotplug +mdev -s +mount -o remount,rw / +cat /etc/.rnd >/dev/urandom 2>&1 +[ -f /etc/fstab ] && mount -a +[ -x /sbin/cfgfs ] && { cfgfs setup; mount -o remount,ro /;} +exec /sbin/init diff --git a/package/base-files/files/lib/mdev/init b/package/base-files/files/lib/mdev/init new file mode 100644 index 000000000..d2ae13e9c --- /dev/null +++ b/package/base-files/files/lib/mdev/init @@ -0,0 +1,21 @@ +#!/bin/sh +if [ "$ACTION" == "add" ];then + if [ "$DEVPATH" == "/bus/usb" ];then + mount -t usbfs usbfs /proc/bus/usb + fi +fi +if [ "$SUBSYSTEM" == "firmware" ];then + logger "Firmware load for $FIRMWARE requested" + if [ "$ACTION" == "add" ];then + if [ -e "/lib/firmware/$FIRMWARE" ];then + logger "Firmware loading ..." + echo 1 > /sys$DEVPATH/loading + cat "/lib/firmware/$FIRMWARE" > /sys$DEVPATH/data + echo 0 > /sys$DEVPATH/loading + logger "finished." + else + logger "Firmware file $FIRMWARE not found" + echo -1 > /sys$DEVPATH/loading + fi + fi +fi diff --git a/package/base-files/files/usr/share/udhcpc/default.script b/package/base-files/files/usr/share/udhcpc/default.script new file mode 100755 index 000000000..02e4a7a3c --- /dev/null +++ b/package/base-files/files/usr/share/udhcpc/default.script @@ -0,0 +1,38 @@ +#!/bin/sh +if [[ -z $1 ]]; then + echo "Error: should be run by udhcpc" + exit 1 +fi + +RESOLV_CONF=/tmp/resolv.conf + +case $1 in +(deconfig) + ip addr flush $interface + ;; +(renew|bound) + ip addr add $ip/${mask:-24} brd + dev $interface + + if [[ -n $router ]]; then + echo "deleting routers" + while ip route del default >&- 2>&-; do :; done + + for i in $router; do + echo "adding router $i" + ip route add to default via $i + done + fi + + echo -n >$RESOLV_CONF + ${domain:+echo search $domain} >>$RESOLV_CONF + for i in $dns; do + echo "adding dns $i" + echo "nameserver $i" >>$RESOLV_CONF + done + + # user rules + [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user +;; +esac + +exit $? diff --git a/package/base-files/ipkg/base-files.conffiles b/package/base-files/ipkg/base-files.conffiles new file mode 100644 index 000000000..2495e2ee4 --- /dev/null +++ b/package/base-files/ipkg/base-files.conffiles @@ -0,0 +1,13 @@ +/etc/banner +/etc/group +/etc/hosts +/etc/ipkg.conf +/etc/modules +/etc/passwd +/etc/profile +/etc/protocols +/etc/sysctl.conf +/etc/network/interfaces +/etc/rc.conf +/etc/sysctl.conf +/etc/shadow diff --git a/package/base-files/ipkg/base-files.control b/package/base-files/ipkg/base-files.control new file mode 100644 index 000000000..00e2d7746 --- /dev/null +++ b/package/base-files/ipkg/base-files.control @@ -0,0 +1,3 @@ +Priority: base +Section: base +Description: basic filesystem structure and scripts |