From 643504e1b82092b1b46f46e50318c4bbe9f7bca4 Mon Sep 17 00:00:00 2001 From: Stefan Fiedler Date: Sun, 5 Aug 2007 19:46:50 +0000 Subject: [PATCH] Stefan Fiedler: first patch for experimental implementation of target-finish packages [2007072400325131793] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@8658 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- .../target-finish/1st-stage/1st-stage.conf | 227 ++++++++++++++++++ .../target-finish/1st-stage/1st-stage.desc | 39 +++ .../target-finish/2nd-stage/2nd-stage.conf | 200 +++++++++++++++ .../target-finish/2nd-stage/2nd-stage.desc | 39 +++ 4 files changed, 505 insertions(+) create mode 100644 package/target-finish/1st-stage/1st-stage.conf create mode 100644 package/target-finish/1st-stage/1st-stage.desc create mode 100644 package/target-finish/2nd-stage/2nd-stage.conf create mode 100644 package/target-finish/2nd-stage/2nd-stage.desc diff --git a/package/target-finish/1st-stage/1st-stage.conf b/package/target-finish/1st-stage/1st-stage.conf new file mode 100644 index 000000000..280857c6b --- /dev/null +++ b/package/target-finish/1st-stage/1st-stage.conf @@ -0,0 +1,227 @@ +#!/bin/bash + +mainfunction="first_stage_mainfunction" + +first_stage_mainfunction () +{ +disksdir="$build_rock/bootdisk" + +echo "Creating initrd data:" +rm -rf $disksdir/initrd +mkdir -p $disksdir/initrd/{dev,proc,sys,tmp,scsi,net,bin,etc,lib} +cd $disksdir/initrd; ln -s bin sbin; ln -s . usr + +# make mount not complain +touch etc/fstab + +rock_targetdir="$base/target/$target/" +rock_target="$target" + +rootdir="$disksdir/2nd_stage" +targetdir="$disksdir/initrd" +cross_compile="" +if [ "$ROCKCFG_CROSSBUILD" = "1" ] ; then + cross_compile="`find ${base}/ROCK/tools.cross/ -name "*-readelf"`" + cross_compile="${cross_compile##*/}" + cross_compile="${cross_compile%%readelf}" +fi +initrdfs="ext2fs" +block_size="" +ramdisk_size=12288 + +case ${initrdfs} in + ext2fs|ext3fs|cramfs) + initrd_img="${disksdir}/initrd.img" + ;; + ramfs) + initrd_img="${disksdir}/initrd.cpio" + ;; +esac + +echo "Creating some device nodes" +mknod ${targetdir}/dev/ram0 b 1 0 +mknod ${targetdir}/dev/null c 1 3 +mknod ${targetdir}/dev/zero c 1 5 +mknod ${targetdir}/dev/tty c 5 0 +mknod ${targetdir}/dev/console c 5 1 + +# this copies a set of programs and the necessary libraries into a +# chroot environment + +echo "Create checkisomd5 binary" +cp -r ${base}/misc/isomd5sum ${base}/build/${ROCKCFG_ID}/ +cat >${base}/build/${ROCKCFG_ID}/compile_isomd5sum.sh </dev/null | grep "(NEEDED)" | + sed -e"s,.*Shared library: \[\(.*\)\],\1," | + while read library ; do + find ${libdirs} -name "${library}" 2>/dev/null | + sed -e "s,^${rootdir},,g" | tr '\n' ' ' + done +} + +libs="${libs} `needed_libs bin/checkisomd5`" + +echo "Copying other files ... " +for x in ${rock_targetdir}/initrd/initrd_* ; do + [ -f ${x} ] || continue + while read file target ; do + file="${rootdir}/${file}" + [ -e ${file} ] || continue + + while read f ; do + tfile=${targetdir}/${target}${f#${file}} + [ -e ${tfile} ] && continue + + if [ -d ${f} -a ! -L ${f} ] ; then + mkdir -p ${tfile} + continue + else + mkdir -p ${tfile%/*} + fi + +# if [ -b ${f} -o -c ${f} -o -p ${f} -o -L ${f} ] ; then + cp -a ${f} ${tfile} +# else +# cp ${f} ${tfile} +# fi + + file -L ${f} | grep -q ELF || continue + libs="${libs} `needed_libs ${f}`" + done < <( find "${file}" ) + done < ${x} +done + +for x in modprobe.static modprobe.static.old insmod.static insmod.static.old ; do + if [ -f ../2nd_stage/sbin/${x/.static/} ]; then + rm -f bin/${x/.static/} + cp -a ../2nd_stage/sbin/${x/.static/} bin/ + fi + if [ -f ../2nd_stage/sbin/$x ]; then + rm -f bin/$x bin/${x/.static/} + cp -a ../2nd_stage/sbin/$x bin/ + ln -sf $x bin/${x/.static/} + fi +done + +echo "Copy scsi and network kernel modules." +tmptar="`mktemp`" ; tar cfT ${tmptar} /dev/null + +for x in $( cd ../2nd_stage ; ls -d lib/modules/*/kernel/drivers/{scsi,net} ) +do + [ -e "../2nd_stage/${x}" ] && tar rf ${tmptar} -C ../2nd_stage ${x} +done +tar xf ${tmptar} ; rm -f ${tmptar} + +[ -e lib/modules ] && find lib/modules -type f -exec $STRIP --strip-debug {} \; + +for x in ../2nd_stage/lib/modules/*/modules.{dep,pcimap,isapnpmap} ; do + cp $x ${x#../2nd_stage/} || echo "not found: $x" ; +done + +for x in lib/modules/*/kernel/drivers/{scsi,net}; do + [ -d $x ] && ln -s ${x#lib/modules/} lib/modules/ +done +rm -f lib/modules/[0-9]*/kernel/drivers/scsi/{st,scsi_debug}.{o,ko} +rm -f lib/modules/[0-9]*/kernel/drivers/net/{dummy,ppp*}.{o,ko} + +echo "Copying required libraries ... " +while [ -n "${libs}" ] ; do + oldlibs=${libs} + libs="" + for x in ${oldlibs} ; do + [ -e ${targetdir}/${x} ] && continue + mkdir -p ${targetdir}/${x%/*} + cp ${rootdir}/${x} ${targetdir}/${x} + file -L ${rootdir}/${x} | grep -q ELF || continue + for y in `needed_libs ${rootdir}/${x}` ; do + [ ! -e "${targetdir}/${y}" ] && libs="${libs} ${y}" + done + done +done + +echo "Creating links for identical files ..." +while read ck fn +do + # don't link empty files... + if [ "${oldck}" = "${ck}" -a -s "${fn}" ] ; then + echo "\`- Found ${fn#${targetdir}} -> ${oldfn#${targetdir}}." + rm ${fn} ; ln -s /${oldfn#${targetdir}} ${fn} + else + oldck=${ck} ; oldfn=${fn} + fi +done < <( find ${targetdir} -type f | xargs md5sum | sort ) + +cd .. + +echo "Creating initrd filesystem image (${initrdfs}): " +case "${initrdfs}" in +cramfs) + [ "${block_size}" == "" ] && block_size=4096 + mkfs.cramfs -b ${block_size} ${targetdir} ${initrd_img} + ;; +ramfs) +# cp -a ${targetdir}/{linuxrc,init} + ( cd ${targetdir} ; find | cpio -o -c > ${initrd_img} ; ) + ;; +ext2fs|ext3fs) + [ "${block_size}" == "" ] && block_size=1024 + block_count=$(( ( 1024 * ${ramdisk_size} ) / ${block_size} )) + + echo "Creating temporary files." + tmpdir=`mktemp -d` ; mkdir -p ${tmpdir} + dd if=/dev/zero of=${initrd_img} bs=${block_size} count=${block_count} &> /dev/null + tmpdev="`losetup -f 2>/dev/null`" + if [ -z "${tmpdev}" ] ; then + for x in /dev/loop* /dev/loop/* ; do + [ -b "${x}" ] || continue + losetup ${x} 2>&1 >/dev/null || tmpdev="${x}" + [ -n "${tmpdev}" ] && break + done + if [ -z "${tmpdev}" ] ; then + echo "No free loopback device found!" + rm -f ${tmpfile} ; rmdir ${tmpdir}; exit 1 + fi + fi + echo "Using loopback device ${tmpdev}." + losetup "${tmpdev}" ${initrd_img} + + echo "Writing initrd image file." + mkfs.${initrdfs:0:4} -b ${block_size} -m 0 -N 360 -q ${tmpdev} &> /dev/null + mount -t ${initrdfs:0:4} ${tmpdev} ${tmpdir} + rmdir ${tmpdir}/lost+found/ + cp -a ${targetdir}/* ${tmpdir} + umount ${tmpdir} + + echo "Removing temporary files." + losetup -d ${tmpdev} + rm -rf ${tmpdir} + ;; +esac + +echo "Compressing initrd image file." +gzip -9 -c ${initrd_img} > ${initrd_img}.gz +mv ${initrd_img%.img}{.img,}.gz + +target="$rock_target" +} diff --git a/package/target-finish/1st-stage/1st-stage.desc b/package/target-finish/1st-stage/1st-stage.desc new file mode 100644 index 000000000..0c4a07980 --- /dev/null +++ b/package/target-finish/1st-stage/1st-stage.desc @@ -0,0 +1,39 @@ + +[COPY] --- ROCK-COPYRIGHT-NOTE-BEGIN --- +[COPY] +[COPY] This copyright note is auto-generated by ./scripts/Create-CopyPatch. +[COPY] Please add additional copyright information _after_ the line containing +[COPY] the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by +[COPY] the ./scripts/Create-CopyPatch script. Do not edit this copyright text! +[COPY] +[COPY] ROCK Linux: rock-src/package/base/mdadm/mdadm.desc +[COPY] ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf +[COPY] +[COPY] This program is free software; you can redistribute it and/or modify +[COPY] it under the terms of the GNU General Public License as published by +[COPY] the Free Software Foundation; either version 2 of the License, or +[COPY] (at your option) any later version. A copy of the GNU General Public +[COPY] License can be found at Documentation/COPYING. +[COPY] +[COPY] Many people helped and are helping developing ROCK Linux. Please +[COPY] have a look at http://www.rocklinux.org/ and the Documentation/TEAM +[COPY] file for details. +[COPY] +[COPY] --- ROCK-COPYRIGHT-NOTE-END --- + +[I] Raid Configuration Tool + +[T] mdadm is a tool for creating, managing and monitoring +[T] device arrays using the "md" driver in Linux, also +[T] known as Software RAID arrays + +[A] The ROCK Linux Project +[M] The ROCK Linux Project + +[C] extra/base + +[L] GPL +[S] Stable +[V] 1 +[P] O --------8- 195.200 + diff --git a/package/target-finish/2nd-stage/2nd-stage.conf b/package/target-finish/2nd-stage/2nd-stage.conf new file mode 100644 index 000000000..3612640c4 --- /dev/null +++ b/package/target-finish/2nd-stage/2nd-stage.conf @@ -0,0 +1,200 @@ +package_map=" +00-dirtree +$ROCKCFG_PKG_GLIBC_BRANCH +-automake17 -automake18 -automake19 -gcc2 +-gcc33 -gcc34 -gcc40 -gcc41 +-gmp -mpfr -rockinitrd +stone +-linux24-source -linux26-header -linux24 +udev +-linux26-source -linux26-header -linux26 -postinstall +-binutils -bin86 -nasm -dietlibc ++grub +lilo +yaboot +aboot ++silo +parted +mac-fdisk +pdisk ++xfsprogs +dosfstools +jfsutils +hfsutils ++e2fsprogs +reiserfsprogs +genromfs +device-mapper ++popt +file +mdadm +lvm2 ++dump +eject +disktype +lvm-wrapper ++hdparm +memtest86 +cpuburn +bonnie++ +-mine -bize -termcap +ncurses ++readline -strace -ltrace -perl5 +-m4 -time -gettext -zlib ++$ROCKCFG_PKG_BASH_DEFAULT +attr +acl +findutils ++mktemp +coreutils -diffutils -patch +-make +grep +sed +gzip ++tar +gawk -flex +bzip2 +-texinfo +less -groff -man ++nvi -bison +bc +cpio ++ed -autoconf -automake -libtool ++curl +wget +dialog +minicom ++lrzsz +rsync +tcpdump +module-init-tools ++sysvinit +shadow +util-linux +wireless-tools ++net-tools +procps +psmisc +rockplug ++modutils +pciutils -cron +portmap ++sysklogd +devfsd +setserial +iproute2 ++netkit-base +netkit-ftp +netkit-telnet +netkit-tftp ++sysfiles +libpcap +iptables +tcp_wrappers +-kiss +kbd -syslinux +ntfsprogs +-ethtool -uml_utilities +ddrescue +libelf" + +package_map="+$ROCKCFG_PKG_LINUX_DEFAULT +$packager $package_map" + +progs="agetty bash cat cp date dd df ifconfig ln ls $packager mkdir mke2fs \ + mkswap mount mv rm reboot route sleep swapoff swapon sync umount \ + eject chmod chroot grep halt rmdir sh shutdown uname killall5 \ + stone mktemp sort fold sed mkreiserfs cut head tail disktype" + +progs="$progs fdisk sfdisk" + +if [ $arch = ppc ] ; then + progs="$progs mac-fdisk pdisk" +fi + +if [ $packager = bize ] ; then + progs="$progs bzip2 md5sum" +fi + +mainfunction="2nd_stage_mainfunction" + +2nd_stage_mainfunction () +{ +disksdir="$build_rock/bootdisk" + +taropt="--use-compress-program=bzip2 -xf" + +echo "Creating 2nd stage filesystem:" +mkdir -p $disksdir/2nd_stage +cd $disksdir/2nd_stage +mkdir -p mnt/source mnt/target +# + +if [ -f ../../pkgs/bize.tar.bz2 -a ! -f ../../pkgs/mine.tar.bz2 ] ; then + packager=bize +else + packager=mine +fi + +echo "Extracting the packages archives." +for x in $( ls ../../pkgs/*.tar.bz2 | tr . / | cut -f8 -d/ ) +do + if [ -z "${x##*:dev*}" -o -z "${x##*:doc*}" ] + then + # simply ignore :dev and :doc packages + true + elif echo "" $package_map "" | grep -q " +$x " + then + echo "\`- Extracting $x.tar.bz2 ..." + tar --use-compress-program=bzip2 -xpf ../../pkgs/$x.tar.bz2 + elif ! echo "" $package_map "" | grep -q " -$x " + then + echo "\`- Not found in \$package_map: $x" + echo " ... target/bootdisk/build_stage1.sh" + fi +done +# +echo "Saving boot/* - we do not need this on the 2nd stage ..." +rm -rf ../boot ; mkdir ../boot +mv boot/* ../boot/ +# +echo "Remove the stuff we do not need ..." +rm -rf home usr/{local,doc,man,info,games,share} +rm -rf var/adm/* var/games var/adm var/mail var/opt +rm -rf usr/{include,src} usr/*-linux-gnu {,usr/}lib/*.{a,la,o} +for x in usr/lib/*/; do rm -rf ${x%/}; done +# +echo "Installing some terminfo databases ..." +tar $taropt ../../pkgs/ncurses.tar.bz2 \ + usr/share/terminfo/x/xterm usr/share/terminfo/a/ansi \ + usr/share/terminfo/n/nxterm usr/share/terminfo/l/linux \ + usr/share/terminfo/v/vt200 usr/share/terminfo/v/vt220 \ + usr/share/terminfo/v/vt100 usr/share/terminfo/s/screen +# +if [ -f ../../pkgs/kbd.tar.bz2 ] ; then + echo "Installing some keymaps ..." + tar $taropt ../../pkgs/kbd.tar.bz2 \ + usr/share/kbd/keymaps/amiga usr/share/kbd/keymaps/i386/qwerty \ + usr/share/kbd/keymaps/atari usr/share/kbd/keymaps/i386/qwertz \ + usr/share/kbd/keymaps/sun + find usr/share/kbd -name '*dvo*' -o -name '*az*' -o -name '*fgG*' | \ + xargs rm -f +fi +# +if [ -f ../../pkgs/pciutils.tar.bz2 ] ; then + echo "Installing pci.ids ..." + tar $taropt ../../pkgs/pciutils.tar.bz2 \ + usr/share/pci.ids +fi +# +echo "Creating 2nd stage linuxrc." +cp -v $base/target/$target/linuxrc2.sh sbin/init ; chmod -v +x sbin/init +cp -v $base/target/$target/shutdown sbin/shutdown ; chmod -v +x sbin/shutdown +echo '$STONE install' > etc/stone.d/default.sh +# +echo "Creating 2nd_stage.tar.gz archive." +tar -czvf ../2nd_stage.tar.gz * ; cd .. + + +echo "Creating small 2nd stage filesystem:" +mkdir -pv 2nd_stage_small ; cd 2nd_stage_small +mkdir -pv dev proc sys tmp bin lib etc share +mkdir -pv mnt/source mnt/target +ln -sv bin sbin ; ln -sv . usr + +# + +echo "Copy the most important programs ..." +for x in $progs ; do + fn="" + [ -f ../2nd_stage/bin/$x ] && fn="bin/$x" + [ -f ../2nd_stage/sbin/$x ] && fn="sbin/$x" + [ -f ../2nd_stage/usr/bin/$x ] && fn="usr/bin/$x" + [ -f ../2nd_stage/usr/sbin/$x ] && fn="usr/sbin/$x" + + if [ "$fn" ] ; then + cp -v ../2nd_stage/$fn $fn + else + echo "\`- Program not found: $x" + fi +done + +# + +echo "Copy the required libraries ..." +found=1 ; while [ $found = 1 ] +do + found=0 + for x in ../2nd_stage/lib ../2nd_stage/usr/lib + do + for y in $( cd $x ; ls *.so.* 2> /dev/null ) + do + if [ ! -f lib/$y ] && + grep -q $y bin/* lib/* 2> /dev/null + then + echo "\`- Found $y." + cp -v $x/$y lib/$y ; found=1 + fi + done + done +done +# +echo "Copy linuxrc." +cp -v ../2nd_stage/sbin/init sbin/init +echo "Copy /etc/fstab." +cp -v ../2nd_stage/etc/fstab etc +echo "Copy stone.d." +mkdir -pv etc/stone.d +for i in gui_text mod_install mod_packages mod_gas default ; do + cp -v ../2nd_stage/etc/stone.d/$i.sh etc/stone.d +done +# +echo "Creating links for identical files." +while read ck fn +do + if [ "$oldck" = "$ck" ] ; then + echo "\`- Found $fn -> $oldfn." + rm -v $fn ; ln -v $oldfn $fn + else + oldck=$ck ; oldfn=$fn + fi +done < <( find -type f | xargs md5sum | sort ) +# +echo "Creating 2nd_stage_small.tar.gz archive." +tar -cvf- * | gzip -9 > ../2nd_stage_small.tar.gz ; cd .. + +} diff --git a/package/target-finish/2nd-stage/2nd-stage.desc b/package/target-finish/2nd-stage/2nd-stage.desc new file mode 100644 index 000000000..0c4a07980 --- /dev/null +++ b/package/target-finish/2nd-stage/2nd-stage.desc @@ -0,0 +1,39 @@ + +[COPY] --- ROCK-COPYRIGHT-NOTE-BEGIN --- +[COPY] +[COPY] This copyright note is auto-generated by ./scripts/Create-CopyPatch. +[COPY] Please add additional copyright information _after_ the line containing +[COPY] the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by +[COPY] the ./scripts/Create-CopyPatch script. Do not edit this copyright text! +[COPY] +[COPY] ROCK Linux: rock-src/package/base/mdadm/mdadm.desc +[COPY] ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf +[COPY] +[COPY] This program is free software; you can redistribute it and/or modify +[COPY] it under the terms of the GNU General Public License as published by +[COPY] the Free Software Foundation; either version 2 of the License, or +[COPY] (at your option) any later version. A copy of the GNU General Public +[COPY] License can be found at Documentation/COPYING. +[COPY] +[COPY] Many people helped and are helping developing ROCK Linux. Please +[COPY] have a look at http://www.rocklinux.org/ and the Documentation/TEAM +[COPY] file for details. +[COPY] +[COPY] --- ROCK-COPYRIGHT-NOTE-END --- + +[I] Raid Configuration Tool + +[T] mdadm is a tool for creating, managing and monitoring +[T] device arrays using the "md" driver in Linux, also +[T] known as Software RAID arrays + +[A] The ROCK Linux Project +[M] The ROCK Linux Project + +[C] extra/base + +[L] GPL +[S] Stable +[V] 1 +[P] O --------8- 195.200 +