rd

tiny cpt ramdisk image generator meant for system rescue
git clone git://git.ckyln.com/rd
Log | Files | Refs | README | LICENSE

build (2496B)


      1 #!/bin/sh -e
      2 # shellcheck disable=2174
      3 
      4 # An initramfs image managed by the package manager itself
      5 # that is meant to be completely static. Below are example
      6 # builds for baselayout, busybox, util-linux (fsck, findfs),
      7 # e2fsprogs (fsck.ext*)
      8 
      9 # BASELAYOUT
     10 
     11 # Setup base directories.
     12 for d in boot dev etc mnt mnt/root usr var run; do
     13     mkdir -pm 755 "$1/$d"
     14 done
     15 
     16 mkdir -pm 555  "$1/proc"
     17 mkdir -pm 555  "$1/sys"
     18 mkdir -pm 0750 "$1/root"
     19 mkdir -pm 1777 "$1/tmp"
     20 
     21 # Setup /usr hierarchy.
     22 for d in bin include lib lib32 local share share/man src; do
     23     mkdir -pm 755 "$1/usr/$d"
     24 done
     25 
     26 # Add symlinks.
     27 ln -s usr/bin "$1/bin"
     28 ln -s usr/bin "$1/sbin"
     29 ln -s bin     "$1/usr/sbin"
     30 ln -s usr/lib "$1/lib"
     31 
     32 
     33 # BUSYBOX
     34 
     35 (
     36     cd busybox
     37 
     38     for patch in *.patch; do
     39         patch -p1 < "$patch"
     40     done
     41 
     42     mv bb-config .config
     43 
     44     make CC="${CC:-gcc}"
     45     make CONFIG_PREFIX="$1/usr" install
     46 
     47     # Install symlinks
     48     "$1/usr/bin/busybox" --list | while read -r bin; do
     49         ln -s busybox "$1/usr/bin/$bin"
     50     done
     51 )
     52 
     53 export CFLAGS="$CFLAGS -static"
     54 export LDFLAGS="$LDFLAGS -static"
     55 
     56 # UTIL-LINUX
     57 (
     58     cd util-linux
     59 
     60     ./configure \
     61         --prefix=/usr \
     62         --localstatedir=/var \
     63         --bindir=/usr/bin \
     64         --sbindir=/usr/bin \
     65         --libdir=/usr/lib \
     66         --enable-libuuid \
     67         --enable-libblkid \
     68         --disable-shared \
     69         --enable-fsck \
     70         --disable-makeinstall-chown \
     71         --disable-rpath \
     72         --without-udev \
     73         --without-python \
     74         --without-systemd
     75 
     76     # I don't exactly know why '--static' is necessary,
     77     # it is a util-linux thing.
     78     make LDFLAGS="$LDFLAGS --static" findfs fsck
     79 
     80     install -Dt "$1/usr/bin" -m755 findfs fsck
     81 )
     82 
     83 # E2FSCK
     84 (
     85     cd e2fsprogs
     86 
     87     ./configure \
     88         --prefix=/usr \
     89         --sbindir=/usr/bin \
     90         --sysconfdir=/etc \
     91         --enable-symlink-install \
     92         --disable-uuidd \
     93         --disable-libuuid \
     94         --disable-libblkid \
     95         --disable-elf-shlibs \
     96         --disable-fsck
     97 
     98     make
     99     install -Dm755 e2fsck/e2fsck "$1/usr/bin/e2fsck"
    100     for i in 2 3 4; do ln -sf e2fsck "$1/usr/bin/fsck.ext$i"; done
    101 )
    102 
    103 # EUDEV
    104 # (
    105 #     cd udev
    106 # 
    107 #     export CFLAGS="$CFLAGS -static"
    108 #     export LDFLAGS="$LDFLAGS -static"
    109 # 
    110 #     ./configure \
    111 #         --prefix=/usr \
    112 #         --disable-shared \
    113 #         --sysconfdir=/etc \
    114 #         --enable-hwdb \
    115 #         --disable-introspection
    116 # 
    117 #     make LDFLAGS="$LDFLAGS"
    118 #     make DESTDIR="$1" install
    119 # )