| 1 | #!/bin/bash | 
|---|
| 2 |  | 
|---|
| 3 | # cross-lfs native sysvinit build | 
|---|
| 4 | # ------------------------------- | 
|---|
| 5 | # $LastChangedBy$ | 
|---|
| 6 | # $LastChangedDate$ | 
|---|
| 7 | # $LastChangedRevision$ | 
|---|
| 8 | # $HeadURL$ | 
|---|
| 9 | # | 
|---|
| 10 |  | 
|---|
| 11 | cd ${SRC} | 
|---|
| 12 | LOG=sysvinit-native.log | 
|---|
| 13 |  | 
|---|
| 14 | set_libdirname | 
|---|
| 15 | setup_multiarch | 
|---|
| 16 |  | 
|---|
| 17 | unpack_tarball sysvinit-${SYSVINIT_VER} && | 
|---|
| 18 | cd ${PKGDIR} | 
|---|
| 19 |  | 
|---|
| 20 | # TODO: add some logic around this... | 
|---|
| 21 | #       this needs to be tracked | 
|---|
| 22 | case ${SYSVINIT_VER} in | 
|---|
| 23 | 2.85 ) | 
|---|
| 24 | apply_patch sysvinit-2.85-proclen-1 | 
|---|
| 25 | ;; | 
|---|
| 26 | esac | 
|---|
| 27 |  | 
|---|
| 28 | # From LFS CVS | 
|---|
| 29 | cp src/init.c src/init.c-ORIG && | 
|---|
| 30 | sed 's/Sending processes/Sending processes started by init/g' \ | 
|---|
| 31 | src/init.c-ORIG > src/init.c | 
|---|
| 32 |  | 
|---|
| 33 | # Modify Makefile | 
|---|
| 34 | test -f src/Makefile-ORIG || | 
|---|
| 35 | cp src/Makefile src/Makefile-ORIG | 
|---|
| 36 |  | 
|---|
| 37 | # 1: Add -pipe to CFLAGS ( default optimization is -O2 ) | 
|---|
| 38 | # 2: Also change BIN_OWNER and BIN_GROUP from "root" to 0 | 
|---|
| 39 | # 3: Modify instructions using chown $(BIN_COMBO) to do a | 
|---|
| 40 | #    chown $(BIN_OWNER) and a chgrp $(BIN_GROUP) instead | 
|---|
| 41 | # 4: makefile works with /dev/initctl, NOT $(ROOT)/dev/initctl | 
|---|
| 42 | #    change this so it operates on our target root, NOT the hosts | 
|---|
| 43 | # 5: alter mknod of $(ROOT)/dev/initctl to not set mode while creating the fifo | 
|---|
| 44 | #    instead set mode with chmod. | 
|---|
| 45 |  | 
|---|
| 46 | sed -e 's@^CFLAGS.*-O2@& -pipe@g' \ | 
|---|
| 47 | -e 's@root@0@g' \ | 
|---|
| 48 | -e 's@chown $(BIN_COMBO) \(.*\)@chown $(BIN_OWNER) \1 ;chgrp $(BIN_GROUP) \1@g' \ | 
|---|
| 49 | -e 's@/dev/initctl@$(ROOT)&@g' \ | 
|---|
| 50 | -e 's@\(mknod \)-m \([0-9]* \)\(.* \)p@\1\3p; chmod \2\3@g' \ | 
|---|
| 51 | src/Makefile-ORIG > src/Makefile | 
|---|
| 52 |  | 
|---|
| 53 |  | 
|---|
| 54 | max_log_init Sysvinit ${SYSVINIT_VER} "native (shared)" ${BUILDLOGS} ${LOG} | 
|---|
| 55 | make -C src CC="${CC-gcc} ${ARCH_CFLAGS}" LDFLAGS="-s"  \ | 
|---|
| 56 | >> ${LOGFILE} 2>&1 && | 
|---|
| 57 | echo " o Build OK" && | 
|---|
| 58 |  | 
|---|
| 59 | mkdir -p /usr/share/man/man{1,5,8} | 
|---|
| 60 |  | 
|---|
| 61 | min_log_init ${INSTLOGS} && | 
|---|
| 62 | make -C src install \ | 
|---|
| 63 | >> ${LOGFILE} 2>&1 && | 
|---|
| 64 | echo " o ALL OK" || barf | 
|---|
| 65 |  | 
|---|
| 66 | # If we already have an /etc/inittab, move it out the way | 
|---|
| 67 | test -f /etc/inittab && | 
|---|
| 68 | mv /etc/inittab /etc/inittab-${DATE} | 
|---|
| 69 |  | 
|---|
| 70 | cat > /etc/inittab << "EOF" | 
|---|
| 71 | # Begin /etc/inittab | 
|---|
| 72 |  | 
|---|
| 73 | id:3:initdefault: | 
|---|
| 74 |  | 
|---|
| 75 | si::sysinit:/etc/rc.d/init.d/rc sysinit | 
|---|
| 76 |  | 
|---|
| 77 | l0:0:wait:/etc/rc.d/init.d/rc 0 | 
|---|
| 78 | l1:S1:wait:/etc/rc.d/init.d/rc 1 | 
|---|
| 79 | l2:2:wait:/etc/rc.d/init.d/rc 2 | 
|---|
| 80 | l3:3:wait:/etc/rc.d/init.d/rc 3 | 
|---|
| 81 | l4:4:wait:/etc/rc.d/init.d/rc 4 | 
|---|
| 82 | l5:5:wait:/etc/rc.d/init.d/rc 5 | 
|---|
| 83 | l6:6:wait:/etc/rc.d/init.d/rc 6 | 
|---|
| 84 |  | 
|---|
| 85 | ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now | 
|---|
| 86 |  | 
|---|
| 87 | su:S016:once:/sbin/sulogin | 
|---|
| 88 | EOF | 
|---|
| 89 |  | 
|---|
| 90 | # Check if we are using DEVFS or not before creating getty entries | 
|---|
| 91 | # If we are using DEVFS need to specify vc/x NOT ttyx | 
|---|
| 92 | tty_string="tty" | 
|---|
| 93 | test Y = "${DEVFS}" && | 
|---|
| 94 | tty_string="vc/" | 
|---|
| 95 |  | 
|---|
| 96 | for vc_no in 1 2 3 4 5 6 ; do | 
|---|
| 97 | echo "${vc_no}:2345:respawn:/sbin/agetty ${tty_string}${vc_no} 9600" \ | 
|---|
| 98 | >> ${LFS}/etc/inittab | 
|---|
| 99 | done | 
|---|
| 100 |  | 
|---|
| 101 | echo -e "\n# End /etc/inittab" >> ${LFS}/etc/inittab | 
|---|
| 102 |  | 
|---|