[PATCH 1/8] Switch to a dynamically linked stage 1.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- Use udev, not udev-static.
- Include module-init-tools.
- Link loader dynamically.
- Split DSO dependency finder off into a separate functions file; use
it in both mk-images and upd-instroot
- Adjust mk-images to use it
- Nuke hardcoded s390 library list for stage1
- Add non-DSO library deps to stage1 - libgcc (backtrace), libnss_files
---
 Makefile.inc         |    2 +-
 loader2/Makefile     |    2 +-
 scripts/Makefile     |    1 +
 scripts/mk-images    |  103 +++++++++++++++---------------------------
 scripts/upd-instroot |  123 ++-----------------------------------------------
 5 files changed, 45 insertions(+), 186 deletions(-)

diff --git a/Makefile.inc b/Makefile.inc
index f015f17..4d2fb85 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -33,4 +33,4 @@ endif
 # uncomment to build 32bit on an 64bit host
 #M32FLAGS = -m32
 CFLAGS = $(RPM_OPT_FLAGS) -Wall -Werror -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 $(SELINUXFLAGS) $(M32FLAGS)
-LDFLAGS = $(M32FLAGS)
+LDFLAGS = $(M32FLAGS) -rdynamic
diff --git a/loader2/Makefile b/loader2/Makefile
index 5df797c..791877a 100644
--- a/loader2/Makefile
+++ b/loader2/Makefile
@@ -45,7 +45,7 @@ SOURCES = $(subst .o,.c,$(OBJS)) loader.c
 LIBS += -lkudzu_loader -lpci
 
 CFLAGS += -DUSE_LOGDEV -DVERSION='"$(VERSION)"'
-STATIC = -static
+STATIC =
 REALCC=gcc
 
 LIBS += ../stubs/libunicode-lite.a ../wlite/libwlite.a
diff --git a/scripts/Makefile b/scripts/Makefile
index a5c456e..df5e866 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -9,6 +9,7 @@ install:
 	install -m 755 mk-images* $(DESTDIR)/$(RUNTIMEDIR)
 	install -m 755 mk-rescueimage* $(DESTDIR)/$(RUNTIMEDIR)
 	install -m 755 buildinstall $(DESTDIR)/$(RUNTIMEDIR)
+	install -m 755 buildinstall.functions $(DESTDIR)/$(RUNTIMEDIR)
 	install -m 755 splittree.py $(DESTDIR)/$(RUNTIMEDIR)
 	install -m 755 scrubtree $(DESTDIR)/$(RUNTIMEDIR)
 	install -m 755 pkgorder $(DESTDIR)/$(RUNTIMEDIR)
diff --git a/scripts/mk-images b/scripts/mk-images
index 661f354..2b990a8 100755
--- a/scripts/mk-images
+++ b/scripts/mk-images
@@ -50,6 +50,8 @@ CRYPTOMODS="sha256_generic cbc aes_generic blkcipher"
 PCMCIASOCKMODS="yenta_socket i82365 tcic pcmcia"
 INITRDMODS="$USBMODS $FIREWIREMODS $IDEMODS $SCSIMODS $FSMODS $LVMMODS $RAIDMODS $CRYPTOMODS $COMMONMODS $PCMCIASOCKMODS =scsi =net"
 
+. $(dirname $0)/buildinstall.functions
+
 # Set, verify, and create paths
     KERNELPATH=$1
     TOPDESTPATH=$2
@@ -348,8 +350,22 @@ makeproductfile() {
     fi
 }
 
+instbin() {
+    ROOT=$1
+    BIN=$2
+    DIR=$3
+    DEST=$4
+
+    install -s -m 755 $ROOT/$BIN $DIR/$DEST
+    get_dso_deps $ROOT "$BIN"
+    local DEPS="$DSO_DEPS"
+    mkdir -p $DIR/$LIBDIR
+    for x in $DEPS ; do
+      cp -Lfp $ROOT/$x $DIR/$LIBDIR
+   done
+}
+
 setupShellEnvironment() {
-    # setup password/group entries
     echo "tcp     6       TCP" > $MBD_DIR/etc/protocols
 
     # PAM configuration
@@ -416,10 +432,10 @@ EOF
     chmod 600 $MBD_DIR/etc/ssh/sshd_config
 
     # copy in the binaries
-    cp -f $IMGPATH/usr/bin/login $MBD_DIR/sbin/login
-    cp -f $IMGPATH/usr/sbin/sshd $MBD_DIR/sbin/sshd
-    cp -f $IMGPATH/usr/bin/bash $MBD_DIR/sbin/bash
-    cp -f $IMGPATH/usr/bin/busybox $MBD_DIR/sbin/busybox
+    instbin $IMGPATH /usr/bin/login $MBD_DIR /sbin/login
+    instbin $IMGPATH /usr/sbin/sshd $MBD_DIR /sbin/sshd
+    instbin $IMGPATH /usr/bin/bash $MBD_DIR /sbin/bash
+    instbin $IMGPATH /usr/bin/busybox $MBD_DIR /sbin/busybox
     
     # make some symlinks
     ln -sf bash $MBD_DIR/sbin/sh
@@ -436,62 +452,9 @@ EOF
     	      fi
     	      shift
 	 done )
-
-    # and copy libraries too
-    mkdir -p $MBD_DIR/$LIBDIR $MBD_DIR/lib
-    for lib in $IMGPATH/$LIBDIR/libc.so* \
-	       $IMGPATH/$LIBDIR/libc-*.so* \
-       	       $IMGPATH/$LIBDIR/ld-*.so* \
-       	       $IMGPATH/$LIBDIR/ld.so* \
-       	       $IMGPATH/$LIBDIR/ld64.so* \
-	       $IMGPATH/$LIBDIR/libaudit.so* \
-	       $IMGPATH/$LIBDIR/libtermcap.so* \
-               $IMGPATH/$LIBDIR/libpam.so* \
-    	       $IMGPATH/$LIBDIR/libdl.so* \
-    	       $IMGPATH/$LIBDIR/libdl-*.so* \
-	       $IMGPATH/$LIBDIR/libnss_files* \
-	       $IMGPATH/$LIBDIR/libnsl* \
-	       $IMGPATH/$LIBDIR/libutil.so* \
-	       $IMGPATH/$LIBDIR/libutil-*.so* \
-	       $IMGPATH/$LIBDIR/libcrypt*so* \
-	       $IMGPATH/$LIBDIR/libselinux*so* \
-	       $IMGPATH/$LIBDIR/libsepol*so* \
-	       $IMGPATH/$LIBDIR/libattr*so* \
-	       $IMGPATH/$LIBDIR/libresolv.so* \
-	       $IMGPATH/$LIBDIR/libresolv-*.so* \
-	       $IMGPATH/$LIBDIR/libm.so* \
-	       $IMGPATH/$LIBDIR/libm-*.so* \
-	       $IMGPATH/usr/$LIBDIR/libz.so* \
-	       $IMGPATH/$LIBDIR/libssl* \
-	       $IMGPATH/$LIBDIR/libcom_err* \
-	       $IMGPATH/$LIBDIR/libe2p* \
-	       $IMGPATH/$LIBDIR/libuuid* \
-	       $IMGPATH/usr/$LIBDIR/libwrap*.so* \
-               $IMGPATH/usr/$LIBDIR/libX11.so* \
-               $IMGPATH/usr/$LIBDIR/libXau.so* \
-               $IMGPATH/usr/$LIBDIR/libXdmcp.so* \
-	       $IMGPATH/usr/$LIBDIR/libXmuu.so* \
-	       $IMGPATH/usr/$LIBDIR/libXext.so* \
-	       $IMGPATH/usr/$LIBDIR/libXt.so* \
-	       $IMGPATH/usr/$LIBDIR/libSM.so* \
-	       $IMGPATH/usr/$LIBDIR/libICE.so* ; do
-	if [ -e $lib ]; then cp -df $lib $MBD_DIR/$LIBDIR/ ; fi
-    done 
-
-    if [ -e $IMGPATH/lib/ld64.so* ]; then cp -df $IMGPATH/lib/ld64.so* $MBD_DIR/lib/ ; fi 
-    if [ -e $IMGPATH/lib/ld-*.so ]; then cp -df $IMGPATH/lib/ld-*.so $MBD_DIR/lib/ ; fi 
-    if [ -e $IMGPATH/lib64/ld64.so* ]; then cp -df $IMGPATH/lib64/ld64.so* $MBD_DIR/lib64/ ; fi 
-
-    mkdir -p $MBD_DIR/usr/$LIBDIR
-    for lib in $IMGPATH/usr/$LIBDIR/libkrb5.so* \
-	       $IMGPATH/usr/$LIBDIR/libkrb5support.so* \
-	       $IMGPATH/usr/$LIBDIR/libgssapi_krb5.so* \
-	       $IMGPATH/usr/$LIBDIR/libk5crypto.so* \
-	       $IMGPATH/usr/$LIBDIR/libcom_err.so* ; do
-	if [ -e $lib ]; then cp -df $lib $MBD_DIR/usr/$LIBDIR/ ; fi
-    done 
 }
 
+
 makeinitrd() {
     EXTRAINITRDPATH=""
     INITRDSIZE=""
@@ -619,16 +582,17 @@ makeinitrd() {
     # set up the arch bits
     echo $arch > $MBD_DIR/etc/arch
 
-    install -s -m 755 $LOADERBINDIR/$LOADERBIN $MBD_DIR/sbin/loader
+    echo "Setting up arch bits"
+    instbin $IMGPATH ${LOADERBINDIR##$IMGPATH}/$LOADERBIN $MBD_DIR /sbin/loader
     if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
-	install -s -m 755 $LOADERBINDIR/init $MBD_DIR/sbin
+        instbin $IMGPATH ${LOADERBINDIR##$IMGPATH}/init $MBD_DIR /sbin/init
 	ln -s ./init $MBD_DIR/sbin/reboot
 	ln -s ./init $MBD_DIR/sbin/halt
 	ln -s ./init $MBD_DIR/sbin/poweroff
     else
-	install -s -m 755 $LOADERBINDIR/shutdown $MBD_DIR/sbin/shutdown
-	install -m 755 $IMGPATH/usr/lib/anaconda-runtime/loader/linuxrc.s390 $MBD_DIR/sbin/init
-	install -m 755 $IMGPATH/usr/sbin/dasdfmt $MBD_DIR/sbin/dasdfmt
+	instbin $IMGPATH ${LOADERBINDIR##IMGPATH}/shutdown $MBD_DIR /sbin/shutdown
+	instbin $IMGPATH /usr/lib/anaconda-runtime/loader/linuxrc.s390 $MBD_DIR /sbin/init
+	instbin $IMGPATH /usr/sbin/dasdfmt $MBD_DIR /sbin/dasdfmt
     fi
 
     if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
@@ -639,7 +603,14 @@ makeinitrd() {
     install -m 644 $IMGPATH/etc/passwd $MBD_DIR/etc/passwd
     install -m 644 $IMGPATH/etc/group $MBD_DIR/etc/group
 
-    install -s -m 755 $IMGPATH/usr/sbin/udevd.static $MBD_DIR/sbin/udevd
+    instbin $IMGPATH /usr/sbin/udevd $MBD_DIR /sbin/udevd
+    instbin $IMGPATH /usr/sbin/udevtrigger $MBD_DIR /sbin/udevtrigger
+    instbin $IMGPATH /usr/sbin/udevsettle $MBD_DIR /sbin/udevsettle
+
+    # Indirect dependencies
+    install -m 755 $IMGPATH/$LIBDIR/libnss_files.so.2 $MBD_DIR/$LIBDIR/
+    install -m 755 $IMGPATH/$LIBDIR/libgcc_s.so.1 $MBD_DIR/$LIBDIR/
+
     install -m 644 $IMGPATH/etc/udev/udev.conf $MBD_DIR/etc/udev/udev.conf
     for i in $IMGPATH/etc/udev/rules.d/*.rules ; do
        install -m 644 $i $MBD_DIR/etc/udev/rules.d/${i##*/}
@@ -656,7 +627,7 @@ makeinitrd() {
     makeproductfile $MBD_DIR
 
     for n in insmod rmmod modprobe; do
-	ln -s loader $MBD_DIR/sbin/$n
+	instbin $IMGPATH /usr/sbin/$n $MBD_DIR /sbin/$n
     done
 
     ln -s /usr/bin/sh $MBD_DIR/sbin/sh
diff --git a/scripts/upd-instroot b/scripts/upd-instroot
index 6a39cb4..1de91d9 100755
--- a/scripts/upd-instroot
+++ b/scripts/upd-instroot
@@ -39,121 +39,7 @@ else
     LIBDIR=lib
 fi
 
-# pulled right out of mkinitrd....
-DSO_DEPS=""
-LDSO=""
-get_dso_deps() {
-    root="$1" ; shift
-    bin="$1" ; shift
-    DSO_DEPS=""
-
-    declare -a FILES
-    declare -a NAMES
-
-    # this is a hack, but the only better way requires binutils or elfutils
-    # be installed.  i.e., we need readelf to find the interpretter.
-    if [ -z "$LDSO" ]; then
-        for ldso in $root/lib*/ld*.so* ; do
-            [ -L $ldso ] && continue
-            [ -x $ldso ] || continue
-            $ldso --verify $bin >/dev/null 2>&1 || continue
-            LDSO=$(echo $ldso |sed -e "s,$root,,")
-        done
-    fi
-
-    # I still hate shell.
-    declare -i n=0
-    while read NAME I0 FILE ADDR I1 ; do
-        [ "$FILE" == "not" ] && FILE="$FILE $ADDR"
-        NAMES[$n]="$NAME"
-        FILES[$n]="$FILE"
-        let n++
-    done << EOF
-        $(chroot $root env LD_TRACE_PRELINKING=1 LD_WARN= \
-                           LD_TRACE_LOADED_OBJECTS=1 $LDSO $bin)
-EOF
-
-    [ ${#FILES[*]} -eq 0 ] && return 1
-
-    # we don't want the name of the binary in the list
-    if [ "${FILES[0]}" == "$bin" ]; then
-        FILES[0]=""
-        NAMES[0]=""
-        [ ${#FILES[*]} -eq 1 ] && return 1
-    fi
-
-    declare -i n=0
-    while [ $n -lt ${#FILES[*]} ]; do
-        FILE="${FILES[$n]}"
-        if [ "$FILE" == "not found" ]; then
-            cat 1>&2 <<EOF
-There are missing files on your system.  The dynamic object $bin
-requires ${NAMES[$n]} n order to properly function.  mkinitrd cannot continue.
-EOF
-            exit 1
-        fi
-       case "$FILE" in
-         /lib*)
-           TLIBDIR=`echo "$FILE" | sed 's,\(/lib[^/]*\)/.*$,\1,'`
-           BASE=`basename "$FILE"`
-           # Prefer nosegneg libs over direct segment accesses on i686.
-           if [ -f "$TLIBDIR/i686/nosegneg/$BASE" ]; then
-             FILE="$TLIBDIR/i686/nosegneg/$BASE"
-           # Otherwise, prefer base libraries rather than their optimized
-           # variants.
-           elif [ -f "$TLIBDIR/$BASE" ]; then
-             FILE="$TLIBDIR/$BASE"
-           fi
-           ;;
-       esac
-        dynamic="yes"
-        let n++
-    done
-
-    DSO_DEPS="${FILES[@]}"
-
-    for l in $(chroot $root find /lib* -maxdepth 1 -type l -name ld*.so*); do
-       [ "$(chroot $root readlink -f $l)" == "$LDSO" ] && DSO_DEPS="$DSO_DEPS $l"
-    done
-
-    [ -n "$DEBUG" ] && echo "DSO_DEPS for $bin are $DSO_DEPS"
-}
-
-instFile() {
-    FILE=$1
-    DESTROOT=$2
-
-    [ -n "$DEBUG" ] && echo "Installing $FILE"
-    if [ -e $DESTROOT/$FILE -o -L $DESTROOT/$FILE ]; then
-      return
-    elif [ ! -d $DESTROOT/`dirname $FILE` ]; then
-      mkdir -p $DESTROOT/`dirname $FILE`
-    fi
-    if [ -L $FILE ]; then
-	cp -al $FILE $DESTROOT/`dirname $FILE`
-	instFile ./`dirname $FILE`/`readlink $FILE` $DESTROOT
-	return
-    else
-	cp -aL $FILE $DESTROOT/`dirname $FILE`
-    fi
-
-    get_dso_deps $(pwd) "$FILE"
-    local DEPS="$DSO_DEPS"
-    for x in $DEPS ; do 
-      instFile ./$x $DESTROOT
-    done
-}
-
-instDir() {
-    DIR=$1
-    DESTROOT=$2
-
-    echo "Installing $DIR"
-    if [ -d $DESTROOT/$DIR -o -h $DESTROOT/$DIR ]; then
-      return
-    fi
-    cp -a --parents $DIR $DESTROOT/
-}
+. $(dirname $0)/buildinstall.functions
 
 expandPackageSet() {
     YUMCONF=$1
@@ -254,7 +140,8 @@ PACKAGES="glibc-common setup python newt slang libselinux
 	 libdhcp libnl libdhcp6client libdhcp4client newt-python
 	 device-mapper device-mapper-libs dmraid keyutils-libs libsemanage-python
 	 python-pyblock mkinitrd libbdevid libbdevid-python nss nspr pcre
-	 cryptsetup-luks libgcrypt libgpg-error udev udev-static dbus dbus-python hal"
+	 cryptsetup-luks libgcrypt libgpg-error udev dbus dbus-python hal
+	 module-init-tools"
 
 if [ $ARCH = i386 ]; then
     PACKAGES="$PACKAGES glibc.i386 openssl.i386"
@@ -323,7 +210,7 @@ PACKAGESGR="anaconda libpng gtk2 libglade2 fonts-ISO8859-2 fonts-ISO8859-9
            fonts-malayalam fonts-oriya fonts-kannada fonts-telugu cjkunifonts-ukai
            fonts-gujarati fonts-hindi fonts-punjabi fonts-tamil synaptics
            firstboot pycairo pirut dejavu-fonts libxcb sazanami-fonts-gothic
-           dmraid python-pyblock libbdevid libbdevid-python zenity udev udev-static dbus dbus-python hal"
+           dmraid python-pyblock libbdevid libbdevid-python zenity udev dbus dbus-python hal"
 
 #
 # stuff ONLY included for rescue mode
@@ -472,7 +359,7 @@ sbin/*gfs*
 sbin/iscsid
 sbin/iscsiadm
 sbin/iscsistart
-sbin/udevd.static
+sbin/udev*
 usr/bin/lshal
 usr/bin/python
 usr/bin/python?.?
-- 
1.5.3.7

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux