[c5c522c] | 1 | #!/bin/bash |
---|
| 2 | #NOBUILDROOT |
---|
| 3 | #DEP:busybox |
---|
| 4 | #DEP:xfsprogs |
---|
| 5 | #DEP:linux |
---|
| 6 | #DEP:linux_src |
---|
| 7 | #DEP:lvm2 |
---|
| 8 | #DEP:pciutils |
---|
| 9 | #DEP:udev |
---|
| 10 | #DEP:hotplug |
---|
| 11 | #DEP:multipath_tools |
---|
| 12 | #DEP:splashutils |
---|
| 13 | #DEP:syn3splash |
---|
| 14 | #DEP:drbd8 |
---|
| 15 | #DEP:drbd_utils |
---|
| 16 | ##DEP:drv_r1000 |
---|
| 17 | #DEP:drv_e1000e |
---|
| 18 | ##DEP:drv_e1000 |
---|
| 19 | #DEP:synwatchdog |
---|
| 20 | #DEP:v86d |
---|
| 21 | #DEP:open_vm_tools |
---|
| 22 | #DEP:initrd_scripts |
---|
| 23 | #DEP:util_linux |
---|
| 24 | #DEP:linkbeep |
---|
| 25 | #DEP:firmware |
---|
| 26 | #DEP:fping |
---|
| 27 | #DEP:network_scripts |
---|
[5fedc40] | 28 | #DEP:kmod |
---|
| 29 | |
---|
[c5c522c] | 30 | |
---|
| 31 | ##DEP:drv_3w_sas |
---|
| 32 | ##DEP:drv_r8168 |
---|
| 33 | ##DEP:drv_r8169 |
---|
| 34 | |
---|
| 35 | ##DEP:cmospwd |
---|
| 36 | |
---|
| 37 | #uitgeschakeld, ivm compile problemen: |
---|
| 38 | ##DEP:drv_viafb |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | CWD=`pwd` |
---|
[5fedc40] | 42 | INITROOT=/tmp/initrd.tmp |
---|
[c5c522c] | 43 | |
---|
| 44 | rm -r $INITROOT &>/dev/null |
---|
| 45 | mkdir $INITROOT || exit 1 |
---|
| 46 | export ROOT=$INITROOT |
---|
| 47 | |
---|
| 48 | ##############base packages er in |
---|
| 49 | installpkg `../../findpkg busybox` || exit 1 |
---|
| 50 | installpkg `../../findpkg glibc_solibs` || exit 1 |
---|
| 51 | installpkg `../../findpkg mdadm` || exit 1 |
---|
| 52 | installpkg `../../findpkg udev` || exit 1 |
---|
| 53 | installpkg `../../findpkg multipath_tools` || exit 1 |
---|
| 54 | installpkg `../../findpkg e2fsprogs` || exit 1 |
---|
| 55 | installpkg `../../findpkg lvm2` || exit 1 |
---|
| 56 | installpkg `../../findpkg drbd8` || exit 1 |
---|
| 57 | installpkg `../../findpkg drbd_utils` || exit 1 |
---|
| 58 | installpkg `../../findpkg xfsprogs` || exit 1 |
---|
| 59 | installpkg `../../findpkg linux` || exit 1 |
---|
| 60 | installpkg `../../findpkg synwatchdog` || exit 1 |
---|
| 61 | installpkg `../../findpkg util_linux` || exit 1 |
---|
| 62 | installpkg `../../findpkg linkbeep` || exit 1 |
---|
| 63 | installpkg `../../findpkg firmware` || exit 1 |
---|
| 64 | |
---|
| 65 | installpkg `../../findpkg fping` || exit 1 |
---|
| 66 | installpkg `../../findpkg network_scripts` || exit 1 #for fping |
---|
| 67 | mv $INITROOT/etc/protocols.new $INITROOT/etc/protocols || exit 1 |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | #installpkg `../../findpkg hwsetup` || exit 1 |
---|
| 71 | #installpkg `../../findpkg hwdata` || exit 1 |
---|
| 72 | #pci utils NA hwdata, omdat deze nieuwe pci.ids heeft op dit moment |
---|
| 73 | #installpkg `../../findpkg pciutils` || exit 1 |
---|
| 74 | |
---|
| 75 | #strip drivers from native kernel |
---|
| 76 | #bepaalde modules zijn niet nodig, of zelfs ongewenst |
---|
| 77 | #net WEL omdat we nf_conntrack nodig zijn voor drbd! |
---|
| 78 | #rm -r $INITROOT/lib/modules/*/kernel/net || exit 1 |
---|
[5fedc40] | 79 | rm -r `find $INITROOT/lib/modules/*/kernel/fs/* -type d -not -name '*fat*' -not -name '*cifs*' -not -name '*fscache*'` |
---|
[c5c522c] | 80 | #rm -r $INITROOT/lib/modules/*/kernel/drivers/usb/serial || exit 1 |
---|
| 81 | #rm -r $INITROOT/lib/modules/*/kernel/drivers/usb/storage || exit 1 |
---|
| 82 | #rm -r $INITROOT/lib/modules/*/pcmcia || exit 1 |
---|
| 83 | #wel: is nodig voor cpu throttling enzo: rm -r $INITROOT/lib/modules/*/kernel/drivers/hwmon || exit 1 |
---|
| 84 | #rm -r $INITROOT/lib/modules/*/kernel/drivers/media || exit 1 |
---|
| 85 | #rm -r $INITROOT/lib/modules/*/kernel/drivers/ieee1394 || exit 1 |
---|
| 86 | #rm -r $INITROOT/lib/modules/*/kernel/drivers/parport || exit 1 |
---|
| 87 | #rm -r $INITROOT/lib/modules/*/kernel/drivers/char/agp || exit 1 |
---|
| 88 | #rm -r $INITROOT/lib/modules/*/kernel/drivers/gpu || exit 1 |
---|
| 89 | #rm -r $INITROOT/lib/modules/*/kernel/sound || exit 1 |
---|
| 90 | #rm -r $INITROOT/lib/modules/*/kernel/drivers/bluetooth || exit 1 |
---|
| 91 | #rm -r $INITROOT/lib/modules/*/kernel/net/bluetooth || exit 1 |
---|
| 92 | #rm -r $INITROOT/lib/modules/*/kernel/drivers/input/touchscreen || exit 1 |
---|
| 93 | #rm -r $INITROOT/lib/modules/*/kernel/drivers/char/ppdev.ko || exit 1 |
---|
| 94 | #rm -r $INITROOT/lib/modules/*/kernel/drivers/char/lp.ko || exit 1 |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | #extra drivers |
---|
| 98 | #installpkg `../../findpkg drv_r1000` || exit 1 |
---|
| 99 | installpkg `../../findpkg open_vm_tools` || exit 1 |
---|
| 100 | installpkg `../../findpkg drv_e1000e` || exit 1 |
---|
| 101 | #installpkg `../../findpkg drv_e1000` || exit 1 |
---|
| 102 | #installpkg `../../findpkg drv_viafb` || exit 1 |
---|
| 103 | #installpkg `../../findpkg drv_3w_sas` || exit 1 |
---|
| 104 | #installpkg `../../findpkg drv_r8168` || exit 1 |
---|
| 105 | |
---|
| 106 | #r8169 8.00 driver is buggy en werkt niet goed met deze kaart: |
---|
| 107 | #02:00.0 0200: 10ec:8168 (rev 06) |
---|
| 108 | #02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06) |
---|
| 109 | #(workaround gemaakt in initrd_scripts die eerst 8168 laad) |
---|
| 110 | #installpkg `../../findpkg drv_r8169` || exit 1 |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | #splashscreen |
---|
| 114 | installpkg `../../findpkg syn3splash` || exit 1 |
---|
| 115 | installpkg `../../findpkg splashutils` || exit 1 |
---|
| 116 | #installpkg `../../findpkg freetype2` || exit 1 |
---|
| 117 | #installpkg `../../findpkg libjpeg` || exit 1 |
---|
| 118 | #installpkg `../../findpkg zlib` || exit 1 |
---|
| 119 | installpkg `../../findpkg v86d` || exit 1 |
---|
| 120 | #installpkg `../../findpkg gcc` || exit 1 |
---|
[5fedc40] | 121 | #only need S-theme: |
---|
| 122 | rm -rf $INITROOT/etc/splash/{B,A,H,E,P,V,K,X} || exit 1 |
---|
| 123 | |
---|
| 124 | |
---|
[c5c522c] | 125 | |
---|
| 126 | #installpkg `../../findpkg libtermcap` || exit 1 |
---|
| 127 | #installpkg `../../findpkg bash` || exit 1 |
---|
| 128 | # gebruik bash standaard ipv ash |
---|
| 129 | #ln -sf bash $INITROOT/bin/sh || exit 1 |
---|
| 130 | |
---|
| 131 | #de echte modprobe ivm modaliassen |
---|
[5fedc40] | 132 | TGZ=`../../findpkg kmod` || exit 1 |
---|
[c5c522c] | 133 | ( |
---|
| 134 | cd $INITROOT && |
---|
[5fedc40] | 135 | rm sbin/modprobe sbin/depmod &>/dev/null && |
---|
| 136 | tar -xzf "$TGZ" 'sbin/kmod' && |
---|
| 137 | ln -s /sbin/kmod sbin/modprobe && |
---|
| 138 | ln -s /sbin/kmod sbin/depmod |
---|
[c5c522c] | 139 | ) || exit 1 |
---|
| 140 | |
---|
| 141 | #shadow, group, passwd voor udevd |
---|
| 142 | TGZ=`../../findpkg etc` || exit 1 |
---|
| 143 | ( |
---|
| 144 | cd $INITROOT && |
---|
| 145 | tar -xzf "$TGZ" etc/passwd.new etc/shadow.new etc/group.new && |
---|
| 146 | mv etc/passwd.new etc/passwd && |
---|
| 147 | mv etc/group.new etc/group && |
---|
[5fedc40] | 148 | mv etc/shadow.new etc/shadow |
---|
[c5c522c] | 149 | ) || exit 1 |
---|
| 150 | |
---|
| 151 | #de echte mount ivm norecovery optie |
---|
| 152 | #TGZ=`../../findpkg util_linux` || exit 1 |
---|
| 153 | #(# |
---|
| 154 | # cd $INITROOT && |
---|
| 155 | # tar -xzf "$TGZ" 'bin/mount' |
---|
| 156 | #) || exit 1 |
---|
| 157 | |
---|
| 158 | |
---|
| 159 | ################addons |
---|
| 160 | |
---|
| 161 | #niet nodig, genzaptelcfg doet dit wel |
---|
| 162 | #installpkg `../../findpkg zaptel` || exit 1 |
---|
| 163 | #very small and very usefull in debugging |
---|
| 164 | installpkg `../../findpkg strace` || exit 1 |
---|
| 165 | installpkg `../../findpkg gzip` || exit 1 |
---|
| 166 | #installpkg `../../findpkg cmospwd` || exit 1 |
---|
| 167 | |
---|
| 168 | #################eject er in |
---|
| 169 | #TGZ=`../../findpkg bin` || exit 1 |
---|
| 170 | #( |
---|
| 171 | # cd $INITROOT |
---|
[5fedc40] | 172 | # tar -xzf $TGZ usr/bin/eject |
---|
[c5c522c] | 173 | #) || exit 1 |
---|
| 174 | |
---|
| 175 | #################speciale mount voor netwerk boot. |
---|
| 176 | #De busybox mount kan geen subdir mounts aan. |
---|
| 177 | |
---|
| 178 | #NOTE: zit nu in cifstools package |
---|
| 179 | #TGZ=`../../findpkg samba` || exit 1 |
---|
| 180 | #( |
---|
| 181 | # cd $INITROOT |
---|
[5fedc40] | 182 | # tar -xzf $TGZ usr/sbin/mount.cifs |
---|
[c5c522c] | 183 | #) || exit 1 |
---|
| 184 | |
---|
| 185 | |
---|
| 186 | ###################init scripts er in |
---|
| 187 | installpkg `../../findpkg initrd_scripts` || exit 1 |
---|
| 188 | |
---|
| 189 | |
---|
| 190 | ####################lib configuratie |
---|
| 191 | touch $INITROOT/etc/ld.so.conf |
---|
| 192 | ldconfig -r $INITROOT || exit 1 |
---|
| 193 | |
---|
| 194 | #####################bepaal versie (adhv kernel nummer) |
---|
| 195 | VERSION=`cat ../linux/linux.version` || exit 1 |
---|
| 196 | echo "Version $VERSION" |
---|
| 197 | |
---|
[5fedc40] | 198 | ####################depmod runnen |
---|
[c5c522c] | 199 | #hiervoor moeten we ff tijdelijk depmod installen |
---|
| 200 | |
---|
| 201 | # workaround for bug or feature in modprobe. modprobe looks in the 'extra' dir first, but busyboxs modprobe doesnt: |
---|
[5fedc40] | 202 | # pushd $INITROOT/lib/modules/$VERSION/extra || exit 1 |
---|
| 203 | # for EMOD in *; do |
---|
| 204 | # OMOD=`find $INITROOT/lib/modules/$VERSION -name $EMOD |grep -v extra` |
---|
| 205 | # if [ "$OMOD" != "" ];then |
---|
| 206 | # mv $EMOD $OMOD || exit 1 |
---|
| 207 | # fi |
---|
| 208 | # done |
---|
| 209 | # popd |
---|
| 210 | |
---|
| 211 | |
---|
| 212 | #edwin: replaced by kmod, uses one binary for all |
---|
| 213 | # TGZ=`../../findpkg module_init_tools` || exit 1 |
---|
| 214 | # ( |
---|
| 215 | # cd $INITROOT && |
---|
| 216 | # tar -xzf $TGZ --wildcards '*sbin/depmod*' |
---|
| 217 | # ) || exit 1 |
---|
[c5c522c] | 218 | echo "Running depmod..." |
---|
| 219 | chroot $INITROOT /sbin/depmod -e -a $VERSION || exit 1 |
---|
[5fedc40] | 220 | # echo "done" |
---|
| 221 | # |
---|
| 222 | # #depmod kan weer weg |
---|
| 223 | # rm $INITROOT/sbin/depmod* |
---|
[c5c522c] | 224 | |
---|
| 225 | #####################overbodige zooi eruit strippen |
---|
| 226 | rm -r $INITROOT/var/log |
---|
| 227 | rm -r $INITROOT/usr/include |
---|
| 228 | rm -r $INITROOT/usr/share/locale |
---|
| 229 | rm -r $INITROOT/usr/man |
---|
| 230 | rm -r $INITROOT/usr/doc |
---|
| 231 | rm -r $INITROOT/usr/share/doc |
---|
| 232 | rm -r $INITROOT/usr/share/man |
---|
| 233 | rm -r $INITROOT/boot |
---|
| 234 | rm -r $INITROOT/service 2>/dev/null |
---|
| 235 | rm `find $INITROOT -type f -name *.static` 2>/dev/null |
---|
| 236 | rm `find $INITROOT -name *.a` 2>/dev/null |
---|
[5fedc40] | 237 | rm -r $INITROOT/usr/share/bash-completion |
---|
| 238 | rm -r $INITROOT/home |
---|
| 239 | rm -r $INITROOT/usr/src |
---|
[c5c522c] | 240 | |
---|
| 241 | |
---|
| 242 | ####################binaries strippen voor als dit nog niet gebeurd is |
---|
| 243 | echo "stripping binaries" |
---|
[5fedc40] | 244 | pushd $INITROOT |
---|
[c5c522c] | 245 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || exit 1 |
---|
| 246 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || exit 1 |
---|
| 247 | find lib/modules/*/kernel -type f | xargs strip --strip-unneeded || exit 1 |
---|
| 248 | popd |
---|
| 249 | |
---|
| 250 | ##################### ongebruikte libs verwijderen |
---|
| 251 | USED=used.tmp |
---|
| 252 | |
---|
| 253 | |
---|
| 254 | #bepaal alle GEBRUIKTE libs |
---|
| 255 | echo "* finding library dependencies" |
---|
| 256 | echo "Size now:" |
---|
| 257 | du -hs $INITROOT |
---|
| 258 | |
---|
| 259 | find $INITROOT|grep -v dev|while read FILE;do ldd "$FILE" 2>/dev/null;done|sed 's/^\t//g'|sed 's/\..*$//g' |sort|uniq > $USED |
---|
| 260 | |
---|
| 261 | #bepaal alle aanwezige libs en wis ze indien niet gebruikt |
---|
| 262 | echo "* deleting unused libs" |
---|
| 263 | find $INITROOT -name '*.so*'|while read NAME; do |
---|
| 264 | SHORTNAME=`echo "$NAME"|sed 's/.*\///g'|sed 's/\..*$//g'|sed 's/-.*$//g'` |
---|
| 265 | if ! grep $SHORTNAME $USED >/dev/null; then |
---|
| 266 | rm "$NAME" |
---|
| 267 | fi |
---|
| 268 | done |
---|
| 269 | rm $USED |
---|
| 270 | |
---|
| 271 | echo "Size after:" |
---|
| 272 | du -hs $INITROOT |
---|
| 273 | |
---|
| 274 | |
---|
| 275 | ##################### in een initrd proppen |
---|
| 276 | #vrije ruimte die ongeveer overblijft: |
---|
| 277 | #SIZE=`du -s $INITROOT|cut -f 1` || exit 1 |
---|
| 278 | |
---|
[5fedc40] | 279 | #echo "Size van alles files: $SIZE" |
---|
[c5c522c] | 280 | #(( SIZE+=3000 )) |
---|
| 281 | #echo "* initrd fixen van $SIZE kbytes." |
---|
| 282 | #mkdir initrd.mnt &>/dev/null |
---|
| 283 | #umount -l initrd.mnt &>/dev/null |
---|
| 284 | #dd bs=1024 if=/dev/zero of=$INITROOT.dsk count=$SIZE >/dev/null || exit 1 |
---|
| 285 | #mkfs.ext2 -F $INITROOT.dsk >/dev/null || exit 1 |
---|
| 286 | |
---|
| 287 | #mount -o loop $INITROOT.dsk initrd.mnt || exit 1 |
---|
| 288 | #if ! cp -a $INITROOT/* initrd.mnt ; then# |
---|
| 289 | # umount initrd.mnt |
---|
| 290 | # exit 1 |
---|
| 291 | #fi |
---|
| 292 | #echo "Space usage op initrd:" |
---|
| 293 | #df -h initrd.mnt |
---|
| 294 | #sleep 1 |
---|
| 295 | #umount initrd.mnt || exit 1 |
---|
| 296 | |
---|
| 297 | #fsck.ext2 -n -f $INITROOT.dsk || exit 1 |
---|
| 298 | |
---|
| 299 | #testen |
---|
| 300 | if [ "$1" == "test" ]; then |
---|
| 301 | echo TESTMODE |
---|
| 302 | exit 1 |
---|
| 303 | fi |
---|
| 304 | |
---|
| 305 | #rm initrd.gz &>/dev/null |
---|
| 306 | #gzip -9 $INITROOT.dsk || exit 1 |
---|
| 307 | #mv $INITROOT.dsk.gz initrd.gz || exit 1 |
---|
| 308 | echo "Compressing initrd.gz.." |
---|
| 309 | ( cd $INITROOT ; find . | cpio -o -H newc --quiet | xz --check=crc32 ) > initrd.gz || exit 1 |
---|
| 310 | #( cd $INITROOT ; find . | cpio -o -H newc --quiet | gzip -9 ) > initrd.gz || exit 1 |
---|
| 311 | rm -r "$INITROOT" || exit 1 |
---|
| 312 | |
---|
| 313 | #################### maak er een nette package van |
---|
| 314 | PKG=/tmp/initrd |
---|
| 315 | rm -r $PKG &>/dev/null |
---|
| 316 | mkdir -p $PKG/boot || exit 1 |
---|
| 317 | mv initrd.gz $PKG/boot/initrd.gz.test || exit 1 |
---|
| 318 | |
---|
| 319 | #postinstaller |
---|
| 320 | mkdir -p $PKG/etc/postinst.d |
---|
| 321 | cp $CWD/post.initrd $PKG/etc/postinst.d || exit 1 |
---|
| 322 | chmod +x $PKG/etc/postinst.d/* || exit 1 |
---|
| 323 | |
---|
| 324 | |
---|
| 325 | NAME=initrd |
---|
| 326 | cd $PKG |
---|
| 327 | /sbin/makepkg -l y -c n $CWD/$NAME.pkg >/dev/null && |
---|
[5fedc40] | 328 | echo $VERSION > $CWD/$NAME.version |
---|