Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (9b3a108a75f90553c121cb5dc22aa84439a0afdf)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Justin Boffemmyer <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (9b3a108a75f90553c121cb5dc22aa84439a0afdf)
  • Date: Wed, 8 Oct 2008 18:47:41 -0500

GIT changes to test cauldron by Justin Boffemmyer <flux AT sourcemage.org>:

scripts/mkinitrd | 197
----------------------------------------------------
scripts/mkinitrd.sh | 197
++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 197 insertions(+), 197 deletions(-)

New commits:
commit 9b3a108a75f90553c121cb5dc22aa84439a0afdf
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

scripts/mkinitrd -> scripts/mkinitrd.sh

Renamed mkinitrd to mkinitrd.sh to be consistent with the naming of
all the other (test-branch) cauldron ISO creation scripts.

diff --git a/scripts/mkinitrd b/scripts/mkinitrd
deleted file mode 100755
index 85f051c..0000000
--- a/scripts/mkinitrd
+++ /dev/null
@@ -1,197 +0,0 @@
-#!/bin/bash
-# This script will crank out an initrd image for the ISO to use.
-
-if [[ $# != 2 ]] ;then
- echo "Usage: $0 <path to chroot> <kernel version>"
- echo "(path to chroot can be / if you want to be sloppy)"
- exit 1
-fi >&2
-
-CHROOT_DIR=$1
-KERNEL_VERSION=$2
-
-if ! [[ -d $CHROOT_DIR/lib/modules/$KERNEL_VERSION/kernel ]] ;then
- echo "Chroot failed sanity check:"
- echo "Unable to find $CHROOT_DIR/lib/modules/$KERNEL_VERSION/kernel"
- exit 2
-fi >&2
-
-# The temporary dir I'll use to put the initrd files
-INITRDROOT=/tmp/initrd-dir
-
-# Dirs to look in for executables (no leading / please)
-EXECDIRS=(bin sbin usr/bin usr/sbin)
-
-#---------------------------------------------------------------------
-## @param full path of binary to check
-## @Stdout libraries with full path
-## echos all libs that the given file is linked against (not ld-linux)
-#---------------------------------------------------------------------
-# Used to implicitly install linked-against-libs to the initrd with a binary
-function libscan() {
- chroot $CHROOT_DIR /usr/bin/ldd "$1" |
- grep '/' |
- cut -f 2 |
- sed -e 's/.*=> //' |
- sed -e 's/ (0x.*)$//' |
- sed -e 's/^[/]//'
-}
-
-# This function gets the real library files from the symlinks returned
-# by running libscan (ldd returns symlinks if that's what the binary
-# links to). The leading '/' is removed for convenience.
-function reallib() {
- chroot $CHROOT_DIR readlink -f $1 |
- sed -e 's/^[/]//'
-}
-
-function my_which() {
- for dir in "${EXECDIRS[@]}" ;do
- if [[ -x $dir/$1 ]] ;then
- echo "$dir/$1"
- return 0
- fi
- done
- echo "Unable to find $1 in your chroot!" >&2
- return 1
-}
-
-#---------------------------------------------------------------------
-## Tries to find the given binary and copy it and its required libs
-## onto the initrd at the same paths they are in the parent system.
-## (working directory is assumed to be the root dir of a chroot, or /)
-#---------------------------------------------------------------------
-function install_prog() {
- local prog progpath
- local i
- for prog in $* ;do
- # find executable
- progpath=$(my_which $prog) &&
- # install executable (path will be relative to $CHROOT_DIR)
- cp --parents -f $progpath $INITRDROOT &&
- # install needed libs
- for i in $(libscan $progpath) ; do
- # Needed to copy both the lib and symlinks
- # Some programs (like ldconfig) rely on the symlinks
- cp --parents -f $(reallib $i) $INITRDROOT
- cp -d --parents -f $i $INITRDROOT
- done
- done
-}
-
-
-#---------------------------------------------------------------------
-## @param path to initrd directory
-## @param path to store gzip-compressed initrd image
-## @Description
-## This function creates a loopback-mountable filesystem from the
-## given initrd and passes it through gzip compression
-#---------------------------------------------------------------------
-function mk_initrd_file() {
- local initrd_size tmp_file tmp_mountdir
-
- # Measure size of the initrd files, add 20% for e2fs overhead and safety
- initrd_size=$(du -ks ${INITRDROOT} | cut -d$'\t' -f1)
- initrd_size="$(( initrd_size + initrd_size / 5 ))"
-
- tmp_file="/tmp/initrd.$$"
- tmp_mountdir="/tmp/initrdmpoint.$$"
-
- rm -rf $tmp_file $tmp_mountdir
- # Create initrd file and filesystem
- dd if=/dev/zero of=$tmp_file bs=1024 count=$initrd_size
- mke2fs -q -b 1024 -i 1024 -F $tmp_file
-
- # Copy stuff into image
- mkdir -p $tmp_mountdir
- mount $tmp_file $tmp_mountdir -o loop
- cp -a $1/* $tmp_mountdir
- umount -d $tmp_mountdir
-
- gzip -c $tmp_file >$2
-
- rm -rf $tmp_file $tmp_mountdir
- echo "initrd is at $2, compressed $(du -ks $2 | cut -d$'\t' -f1)K,
uncompressed ${initrd_size}K."
- echo "Don't forget to adjust isolinux.cfg for the new size."
-}
-
-
-# Find my stuff
-MYDIR=$(readlink -f ${0%/*}/..)
-
-if ! [[ -e $MYDIR/data/initrd.files ]] ;then
- echo "Failed sanity check: Cannot find data/initrd.files in my dir"
- echo "(assumed to be $MYDIR)"
- exit 2
-fi >&2
-
-rm -rf $INITRDROOT
-mkdir -p $INITRDROOT
-
-OLDWD=$PWD
-# Unless otherwise noted, this is our working directory.
-cd $CHROOT_DIR >/dev/null
-
-# Create all dirs we need on the initrd
-echo "Creating dirs..."
-while read line ; do
- mkdir -p ${INITRDROOT}/${line}
-done <$MYDIR/data/initrd.dirs
-
-# Copy files onto the initrd that we need.
-echo "Copying files and programs..."
-while read line ; do
- # If it has a leading /, treat it as a single file
- if [[ ${line:0:1} == '/' ]] ;then
- cp -a --parents ${line:1} ${INITRDROOT}
- else
- # Otherwise, it's a binary, find it and install its libs too
- install_prog $line
- fi
-done <$MYDIR/data/initrd.files
-
-# Copy the dynamic loader over
-echo "Copying over dynamic loader"
-cp --parents lib/ld-2.* $INITRDROOT
-
-# Create a static /dev
-echo "Creating static dev"
-pushd $INITRDROOT/dev >/dev/null
-$MYDIR/data/MAKEDEV generic-nopty
-popd >/dev/null
-
-# Add kernel modules that are supposed to be on the iso
-echo "adding kernel modules"
-mkdir -p ${INITRDROOT}/lib/modules/${KERNEL_VERSION}/kernel
-pushd $CHROOT_DIR/lib/modules/${KERNEL_VERSION}/kernel >/dev/null
- while read line ; do
- cp -pr --parents ./${line}
${INITRDROOT}/lib/modules/${KERNEL_VERSION}/kernel
- done <$MYDIR/data/initrd.kernel
-popd >/dev/null
-
-# Copy module listing and other files the kernel needs, omit dirs though
-echo "Copy module listing and other files"
-cp -dp --parents lib/modules/$KERNEL_VERSION/* $INITRDROOT 2>/dev/null
-
-# Finally, copy everything from the skeleton on top
-echo "Copy skeleton"
-cp -af $MYDIR/initrd/* ${INITRDROOT}
-
-# Set up linker caches and symlinks
-echo "Set up linker caches and symlinks"
-cp sbin/ldconfig ${INITRDROOT}
-chroot ${INITRDROOT} /ldconfig
-rm ${INITRDROOT}/ldconfig
-
-# create module dependencies.
-echo "create module dependencies"
-cp sbin/depmod ${INITRDROOT}
-chroot ${INITRDROOT} /depmod ${KERNEL_VERSION}
-rm -f ${INITRDROOT}/depmod
-
-# The initrd is complete now.
-echo "Make the initrd"
-mk_initrd_file $INITRDROOT $OLDWD/initrd.gz
-
-echo "cleaning up..."
-rm -rf ${INITRDROOT}
diff --git a/scripts/mkinitrd.sh b/scripts/mkinitrd.sh
new file mode 100755
index 0000000..85f051c
--- /dev/null
+++ b/scripts/mkinitrd.sh
@@ -0,0 +1,197 @@
+#!/bin/bash
+# This script will crank out an initrd image for the ISO to use.
+
+if [[ $# != 2 ]] ;then
+ echo "Usage: $0 <path to chroot> <kernel version>"
+ echo "(path to chroot can be / if you want to be sloppy)"
+ exit 1
+fi >&2
+
+CHROOT_DIR=$1
+KERNEL_VERSION=$2
+
+if ! [[ -d $CHROOT_DIR/lib/modules/$KERNEL_VERSION/kernel ]] ;then
+ echo "Chroot failed sanity check:"
+ echo "Unable to find $CHROOT_DIR/lib/modules/$KERNEL_VERSION/kernel"
+ exit 2
+fi >&2
+
+# The temporary dir I'll use to put the initrd files
+INITRDROOT=/tmp/initrd-dir
+
+# Dirs to look in for executables (no leading / please)
+EXECDIRS=(bin sbin usr/bin usr/sbin)
+
+#---------------------------------------------------------------------
+## @param full path of binary to check
+## @Stdout libraries with full path
+## echos all libs that the given file is linked against (not ld-linux)
+#---------------------------------------------------------------------
+# Used to implicitly install linked-against-libs to the initrd with a binary
+function libscan() {
+ chroot $CHROOT_DIR /usr/bin/ldd "$1" |
+ grep '/' |
+ cut -f 2 |
+ sed -e 's/.*=> //' |
+ sed -e 's/ (0x.*)$//' |
+ sed -e 's/^[/]//'
+}
+
+# This function gets the real library files from the symlinks returned
+# by running libscan (ldd returns symlinks if that's what the binary
+# links to). The leading '/' is removed for convenience.
+function reallib() {
+ chroot $CHROOT_DIR readlink -f $1 |
+ sed -e 's/^[/]//'
+}
+
+function my_which() {
+ for dir in "${EXECDIRS[@]}" ;do
+ if [[ -x $dir/$1 ]] ;then
+ echo "$dir/$1"
+ return 0
+ fi
+ done
+ echo "Unable to find $1 in your chroot!" >&2
+ return 1
+}
+
+#---------------------------------------------------------------------
+## Tries to find the given binary and copy it and its required libs
+## onto the initrd at the same paths they are in the parent system.
+## (working directory is assumed to be the root dir of a chroot, or /)
+#---------------------------------------------------------------------
+function install_prog() {
+ local prog progpath
+ local i
+ for prog in $* ;do
+ # find executable
+ progpath=$(my_which $prog) &&
+ # install executable (path will be relative to $CHROOT_DIR)
+ cp --parents -f $progpath $INITRDROOT &&
+ # install needed libs
+ for i in $(libscan $progpath) ; do
+ # Needed to copy both the lib and symlinks
+ # Some programs (like ldconfig) rely on the symlinks
+ cp --parents -f $(reallib $i) $INITRDROOT
+ cp -d --parents -f $i $INITRDROOT
+ done
+ done
+}
+
+
+#---------------------------------------------------------------------
+## @param path to initrd directory
+## @param path to store gzip-compressed initrd image
+## @Description
+## This function creates a loopback-mountable filesystem from the
+## given initrd and passes it through gzip compression
+#---------------------------------------------------------------------
+function mk_initrd_file() {
+ local initrd_size tmp_file tmp_mountdir
+
+ # Measure size of the initrd files, add 20% for e2fs overhead and safety
+ initrd_size=$(du -ks ${INITRDROOT} | cut -d$'\t' -f1)
+ initrd_size="$(( initrd_size + initrd_size / 5 ))"
+
+ tmp_file="/tmp/initrd.$$"
+ tmp_mountdir="/tmp/initrdmpoint.$$"
+
+ rm -rf $tmp_file $tmp_mountdir
+ # Create initrd file and filesystem
+ dd if=/dev/zero of=$tmp_file bs=1024 count=$initrd_size
+ mke2fs -q -b 1024 -i 1024 -F $tmp_file
+
+ # Copy stuff into image
+ mkdir -p $tmp_mountdir
+ mount $tmp_file $tmp_mountdir -o loop
+ cp -a $1/* $tmp_mountdir
+ umount -d $tmp_mountdir
+
+ gzip -c $tmp_file >$2
+
+ rm -rf $tmp_file $tmp_mountdir
+ echo "initrd is at $2, compressed $(du -ks $2 | cut -d$'\t' -f1)K,
uncompressed ${initrd_size}K."
+ echo "Don't forget to adjust isolinux.cfg for the new size."
+}
+
+
+# Find my stuff
+MYDIR=$(readlink -f ${0%/*}/..)
+
+if ! [[ -e $MYDIR/data/initrd.files ]] ;then
+ echo "Failed sanity check: Cannot find data/initrd.files in my dir"
+ echo "(assumed to be $MYDIR)"
+ exit 2
+fi >&2
+
+rm -rf $INITRDROOT
+mkdir -p $INITRDROOT
+
+OLDWD=$PWD
+# Unless otherwise noted, this is our working directory.
+cd $CHROOT_DIR >/dev/null
+
+# Create all dirs we need on the initrd
+echo "Creating dirs..."
+while read line ; do
+ mkdir -p ${INITRDROOT}/${line}
+done <$MYDIR/data/initrd.dirs
+
+# Copy files onto the initrd that we need.
+echo "Copying files and programs..."
+while read line ; do
+ # If it has a leading /, treat it as a single file
+ if [[ ${line:0:1} == '/' ]] ;then
+ cp -a --parents ${line:1} ${INITRDROOT}
+ else
+ # Otherwise, it's a binary, find it and install its libs too
+ install_prog $line
+ fi
+done <$MYDIR/data/initrd.files
+
+# Copy the dynamic loader over
+echo "Copying over dynamic loader"
+cp --parents lib/ld-2.* $INITRDROOT
+
+# Create a static /dev
+echo "Creating static dev"
+pushd $INITRDROOT/dev >/dev/null
+$MYDIR/data/MAKEDEV generic-nopty
+popd >/dev/null
+
+# Add kernel modules that are supposed to be on the iso
+echo "adding kernel modules"
+mkdir -p ${INITRDROOT}/lib/modules/${KERNEL_VERSION}/kernel
+pushd $CHROOT_DIR/lib/modules/${KERNEL_VERSION}/kernel >/dev/null
+ while read line ; do
+ cp -pr --parents ./${line}
${INITRDROOT}/lib/modules/${KERNEL_VERSION}/kernel
+ done <$MYDIR/data/initrd.kernel
+popd >/dev/null
+
+# Copy module listing and other files the kernel needs, omit dirs though
+echo "Copy module listing and other files"
+cp -dp --parents lib/modules/$KERNEL_VERSION/* $INITRDROOT 2>/dev/null
+
+# Finally, copy everything from the skeleton on top
+echo "Copy skeleton"
+cp -af $MYDIR/initrd/* ${INITRDROOT}
+
+# Set up linker caches and symlinks
+echo "Set up linker caches and symlinks"
+cp sbin/ldconfig ${INITRDROOT}
+chroot ${INITRDROOT} /ldconfig
+rm ${INITRDROOT}/ldconfig
+
+# create module dependencies.
+echo "create module dependencies"
+cp sbin/depmod ${INITRDROOT}
+chroot ${INITRDROOT} /depmod ${KERNEL_VERSION}
+rm -f ${INITRDROOT}/depmod
+
+# The initrd is complete now.
+echo "Make the initrd"
+mk_initrd_file $INITRDROOT $OLDWD/initrd.gz
+
+echo "cleaning up..."
+rm -rf ${INITRDROOT}



  • [SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (9b3a108a75f90553c121cb5dc22aa84439a0afdf), Justin Boffemmyer, 10/08/2008

Archive powered by MHonArc 2.6.24.

Top of Page