Changeset 5804e5f


Ignore:
Timestamp:
05/22/2021 10:56:09 AM (4 months ago)
Author:
Xi Ruoyao <xry111@…>
Branches:
11.0, qt5new, trunk
Children:
d9506f7
Parents:
99ed8506
git-author:
Xi Ruoyao <xry111@…> (05/22/2021 10:53:33 AM)
git-committer:
Xi Ruoyao <xry111@…> (05/22/2021 10:56:09 AM)
Message:

update mkinitramfs script (merge /usr)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • postlfs/filesystems/initramfs.xml

    r99ed8506 r5804e5f  
    6666    </para>
    6767
    68     <screen role="root"><userinput>cat &gt; /sbin/mkinitramfs &lt;&lt; "EOF"
     68    <screen role="root"><userinput>cat &gt; /usr/sbin/mkinitramfs &lt;&lt; "EOF"
    6969<literal>#!/bin/bash
    7070# This file based in part on the mkinitramfs script for the LFS LiveCD
     
    7676
    7777  if [ "$2" = "lib" ]; then
    78     file=$(PATH=/lib:/usr/lib type -p $1)
     78    file=$(PATH=/usr/lib type -p $1)
    7979  else
    8080    file=$(type -p $1)
     
    8282
    8383  if [ -n "$file" ] ; then
    84     cp $file $WDIR/$2
     84    cp $file $WDIR/usr/$2
    8585  else
    8686    echo "Missing required file: $1 for directory $2"
     
    9797fi
    9898
    99 if [ -n "$KERNEL_VERSION" ] &amp;&amp; [ ! -d "/lib/modules/$1" ] ; then
     99if [ -n "$KERNEL_VERSION" ] &amp;&amp; [ ! -d "/usr/lib/modules/$1" ] ; then
    100100  echo "No modules directory named $1"
    101101  exit 1
     
    109109
    110110# Systemd installs udevadm in /bin. Other udev implementations have it in /sbin
    111 if [ -x /bin/udevadm ] ; then binfiles="$binfiles udevadm"; fi
     111if [ -x /usr/bin/udevadm ] ; then binfiles="$binfiles udevadm"; fi
    112112
    113113sbinfiles="modprobe blkid switch_root"
    114114
    115 #Optional files and locations
     115# Optional files and locations
    116116for f in mdadm mdmon udevd udevadm; do
    117   if [ -x /sbin/$f ] ; then sbinfiles="$sbinfiles $f"; fi
     117  if [ -x /usr/sbin/$f ] ; then sbinfiles="$sbinfiles $f"; fi
    118118done
    119119
    120120# Add lvm if present (cannot be done with the others because it
    121121# also needs dmsetup
    122 if [ -x /sbin/lvm ] ; then sbinfiles="$sbinfiles lvm dmsetup"; fi
     122if [ -x /usr/sbin/lvm ] ; then sbinfiles="$sbinfiles lvm dmsetup"; fi
    123123
    124124unsorted=$(mktemp /tmp/unsorted.XXXXXXXXXX)
     
    131131
    132132# Create base directory structure
    133 mkdir -p $WDIR/{bin,dev,lib/firmware,run,sbin,sys,proc,usr}
     133mkdir -p $WDIR/{dev,run,sys,proc,usr/{bin,lib/{firmware,modules},sbin}}
    134134mkdir -p $WDIR/etc/{modprobe.d,udev/rules.d}
    135135touch $WDIR/etc/modprobe.d/modprobe.conf
    136 ln -s lib $WDIR/lib64
    137 ln -s ../bin $WDIR/usr/bin
     136ln -s usr/bin  $WDIR/bin
     137ln -s usr/lib  $WDIR/lib
     138ln -s usr/sbin $WDIR/sbin
     139ln -s lib      $WDIR/lib64
    138140
    139141# Create necessary device nodes
     
    151153
    152154# Install any firmware present
    153 cp -a /lib/firmware $WDIR/lib
     155cp -a /usr/lib/firmware $WDIR/usr/lib
    154156
    155157# Copy the RAID configuration file if present
     
    162164
    163165if [  -n "$KERNEL_VERSION" ] ; then
    164   if [ -x /bin/kmod ] ; then
     166  if [ -x /usr/bin/kmod ] ; then
    165167    binfiles="$binfiles kmod"
    166168  else
     
    172174# Install basic binaries
    173175for f in $binfiles ; do
    174   if [ -e /bin/$f ]; then d="/bin"; else d="/usr/bin"; fi
    175   ldd $d/$f | sed "s/\t//" | cut -d " " -f1 &gt;&gt; $unsorted
    176   copy $d/$f bin
     176  ldd /usr/bin/$f | sed "s/\t//" | cut -d " " -f1 &gt;&gt; $unsorted
     177  copy /usr/bin/$f bin
    177178done
    178179
    179180for f in $sbinfiles ; do
    180   ldd /sbin/$f | sed "s/\t//" | cut -d " " -f1 &gt;&gt; $unsorted
     181  ldd /usr/sbin/$f | sed "s/\t//" | cut -d " " -f1 &gt;&gt; $unsorted
    181182  copy $f sbin
    182183done
    183184
    184 # Add udevd libraries if not in /sbin
    185 if [ -x /lib/udev/udevd ] ; then
    186   ldd /lib/udev/udevd | sed "s/\t//" | cut -d " " -f1 &gt;&gt; $unsorted
    187 elif [ -x /lib/systemd/systemd-udevd ] ; then
    188   ldd /lib/systemd/systemd-udevd | sed "s/\t//" | cut -d " " -f1 &gt;&gt; $unsorted
     185# Add udevd libraries if not in /usr/sbin
     186if [ -x /usr/lib/udev/udevd ] ; then
     187  ldd /usr/lib/udev/udevd | sed "s/\t//" | cut -d " " -f1 &gt;&gt; $unsorted
     188elif [ -x /usr/lib/systemd/systemd-udevd ] ; then
     189  ldd /usr/lib/systemd/systemd-udevd | sed "s/\t//" | cut -d " " -f1 &gt;&gt; $unsorted
    189190fi
    190191
    191192# Add module symlinks if appropriate
    192 if [ -n "$KERNEL_VERSION" ] &amp;&amp; [ -x /bin/kmod ] ; then
    193   ln -s kmod $WDIR/bin/lsmod
    194   ln -s kmod $WDIR/bin/insmod
     193if [ -n "$KERNEL_VERSION" ] &amp;&amp; [ -x /usr/bin/kmod ] ; then
     194  ln -s kmod $WDIR/usr/bin/lsmod
     195  ln -s kmod $WDIR/usr/bin/insmod
    195196fi
    196197
    197198# Add lvm symlinks if appropriate
    198199# Also copy the lvm.conf file
    199 if  [ -x /sbin/lvm ] ; then
    200   ln -s lvm $WDIR/sbin/lvchange
    201   ln -s lvm $WDIR/sbin/lvrename
    202   ln -s lvm $WDIR/sbin/lvextend
    203   ln -s lvm $WDIR/sbin/lvcreate
    204   ln -s lvm $WDIR/sbin/lvdisplay
    205   ln -s lvm $WDIR/sbin/lvscan
    206 
    207   ln -s lvm $WDIR/sbin/pvchange
    208   ln -s lvm $WDIR/sbin/pvck
    209   ln -s lvm $WDIR/sbin/pvcreate
    210   ln -s lvm $WDIR/sbin/pvdisplay
    211   ln -s lvm $WDIR/sbin/pvscan
    212 
    213   ln -s lvm $WDIR/sbin/vgchange
    214   ln -s lvm $WDIR/sbin/vgcreate
    215   ln -s lvm $WDIR/sbin/vgscan
    216   ln -s lvm $WDIR/sbin/vgrename
    217   ln -s lvm $WDIR/sbin/vgck
     200if  [ -x /usr/sbin/lvm ] ; then
     201  ln -s lvm $WDIR/usr/sbin/lvchange
     202  ln -s lvm $WDIR/usr/sbin/lvrename
     203  ln -s lvm $WDIR/usr/sbin/lvextend
     204  ln -s lvm $WDIR/usr/sbin/lvcreate
     205  ln -s lvm $WDIR/usr/sbin/lvdisplay
     206  ln -s lvm $WDIR/usr/sbin/lvscan
     207
     208  ln -s lvm $WDIR/usr/sbin/pvchange
     209  ln -s lvm $WDIR/usr/sbin/pvck
     210  ln -s lvm $WDIR/usr/sbin/pvcreate
     211  ln -s lvm $WDIR/usr/sbin/pvdisplay
     212  ln -s lvm $WDIR/usr/sbin/pvscan
     213
     214  ln -s lvm $WDIR/usr/sbin/vgchange
     215  ln -s lvm $WDIR/usr/sbin/vgcreate
     216  ln -s lvm $WDIR/usr/sbin/vgscan
     217  ln -s lvm $WDIR/usr/sbin/vgrename
     218  ln -s lvm $WDIR/usr/sbin/vgck
    218219  # Conf file(s)
    219220  cp -a /etc/lvm $WDIR/etc
     
    234235done
    235236
    236 if [ -d /lib/udev ]; then
    237   cp -a /lib/udev $WDIR/lib
    238 fi
    239 if [ -d /lib/systemd ]; then
    240   cp -a /lib/systemd $WDIR/lib
    241 fi
    242 if [ -d /lib/elogind ]; then
    243   cp -a /lib/elogind $WDIR/lib
     237if [ -d /usr/lib/udev ]; then
     238  cp -a /usr/lib/udev $WDIR/usr/lib
     239fi
     240if [ -d /usr/lib/systemd ]; then
     241  cp -a /usr/lib/systemd $WDIR/usr/lib
     242fi
     243if [ -d /usr/lib/elogind ]; then
     244  cp -a /usr/lib/elogind $WDIR/usr/lib
    244245fi
    245246
     
    247248if [ -n "$KERNEL_VERSION" ]; then
    248249  find                                                                        \
    249      /lib/modules/$KERNEL_VERSION/kernel/{crypto,fs,lib}                      \
    250      /lib/modules/$KERNEL_VERSION/kernel/drivers/{block,ata,md,firewire}      \
    251      /lib/modules/$KERNEL_VERSION/kernel/drivers/{scsi,message,pcmcia,virtio} \
    252      /lib/modules/$KERNEL_VERSION/kernel/drivers/usb/{host,storage}           \
     250     /usr/lib/modules/$KERNEL_VERSION/kernel/{crypto,fs,lib}                      \
     251     /usr/lib/modules/$KERNEL_VERSION/kernel/drivers/{block,ata,md,firewire}      \
     252     /usr/lib/modules/$KERNEL_VERSION/kernel/drivers/{scsi,message,pcmcia,virtio} \
     253     /usr/lib/modules/$KERNEL_VERSION/kernel/drivers/usb/{host,storage}           \
    253254     -type f 2&gt; /dev/null | cpio --make-directories -p --quiet $WDIR
    254255
    255   cp /lib/modules/$KERNEL_VERSION/modules.{builtin,order}                     \
    256             $WDIR/lib/modules/$KERNEL_VERSION
     256  cp /usr/lib/modules/$KERNEL_VERSION/modules.{builtin,order}                     \
     257            $WDIR/usr/lib/modules/$KERNEL_VERSION
    257258
    258259  depmod -b $WDIR $KERNEL_VERSION
     
    262263
    263264# Prepare early loading of microcode if available
    264 if ls /lib/firmware/intel-ucode/* &gt;/dev/null 2&gt;&amp;1 ||
    265    ls /lib/firmware/amd-ucode/*   &gt;/dev/null 2&gt;&amp;1; then
     265if ls /usr/lib/firmware/intel-ucode/* &gt;/dev/null 2&gt;&amp;1 ||
     266   ls /usr/lib/firmware/amd-ucode/*   &gt;/dev/null 2&gt;&amp;1; then
    266267
    267268# first empty WDIR to reuse it
     
    271272  mkdir -p $DSTDIR
    272273
    273   if [ -d /lib/firmware/amd-ucode ]; then
    274     cat /lib/firmware/amd-ucode/microcode_amd*.bin &gt; $DSTDIR/AuthenticAMD.bin
     274  if [ -d /usr/lib/firmware/amd-ucode ]; then
     275    cat /usr/lib/firmware/amd-ucode/microcode_amd*.bin &gt; $DSTDIR/AuthenticAMD.bin
    275276  fi
    276277
    277   if [ -d /lib/firmware/intel-ucode ]; then
    278     cat /lib/firmware/intel-ucode/* &gt; $DSTDIR/GenuineIntel.bin
     278  if [ -d /usr/lib/firmware/intel-ucode ]; then
     279    cat /usr/lib/firmware/intel-ucode/* &gt; $DSTDIR/GenuineIntel.bin
    279280  fi
    280281
     
    291292EOF
    292293
    293 chmod 0755 /sbin/mkinitramfs</userinput></screen>
     294chmod 0755 /usr/sbin/mkinitramfs</userinput></screen>
    294295
    295296    <screen role="root"><userinput>mkdir -p /usr/share/mkinitramfs &amp;&amp;
     
    297298<literal>#!/bin/sh
    298299
    299 PATH=/bin:/usr/bin:/sbin:/usr/sbin
     300PATH=/usr/bin:/usr/sbin
    300301export PATH
    301302
Note: See TracChangeset for help on using the changeset viewer.