6 ISODIR=/worksrc/isofiles
7 TEMPDIR=/worksrc/catalyst/isotemp
8 REPOSRC=/worksrc/sysresccd-src
9 REPOBIN=/worksrc/sysresccd-bin
11 # ==================================================================
12 # ==================================================================
16 echo "Usage: $0 <arch> <options>"
17 echo " arch = x86 | amd64 | sparc"
20 if [ "$1" = "x86" ] || [ "$1" = "amd64" ] || [ "$1" = "sparc" ]
28 # ========= copy files from the temp iso image ================================
29 CURFILE="${ISODIR}/systemrescuecd-${CURARCH}-current.iso"
30 MYDATE=$(date +%Y%m%d-%Hh%M)
31 DESTDIR=/home/sysresccdiso
34 if [ ! -f "${CURFILE}" ]
36 echo "Cannot find \"${CURFILE}\". Failed"
40 umount /mnt/cdrom 2>/dev/null
41 if ! mount -o loop,ro ${CURFILE} /mnt/cdrom
43 echo "Cannot mount ${CURFILE}"
47 if [ ! -f /mnt/cdrom/image.squashfs ]
49 echo "Cannot find a valid file in the ISO"
53 [ -d ${TEMPDIR} ] && rm -rf ${TEMPDIR}
55 cp /mnt/cdrom/isolinux/rescuecd* ${REPOBIN}/kernels-x86/
56 cp /mnt/cdrom/image.squashfs ${TEMPDIR}/sysrcd.dat
57 ( cd ${TEMPDIR} ; md5sum sysrcd.dat > sysrcd.md5 ; chmod 644 sysrcd.* )
60 # ========= copy files from overlays ===========================================
61 rsync -ax ${REPOBIN}/overlay-iso-x86/ "${TEMPDIR}/"
62 rsync -ax ${REPOSRC}/overlay-iso-x86/isolinux/ "${TEMPDIR}/isolinux/"
63 rsync -ax ${REPOBIN}/kernels-x86/ ${TEMPDIR}/isolinux/ --exclude='*.igz'
64 cp ${REPOSRC}/overlay-squashfs-x86/root/version ${TEMPDIR}
66 # ========= integrate the version number in f1boot.msg =========================
67 TXTVERSION=$(cat ${REPOSRC}/overlay-squashfs-x86/root/version)
68 sed -i -e "s/VERSION/${TXTVERSION}${EXTRAVER}/" ${TEMPDIR}/isolinux/f1boot.msg
70 # ========= merge (rescuecd.igz+rescue64.igz+altker32.igz) --> rescuecd.igz ====
71 curdir="${TEMPDIR}/isolinux"
72 newramfs="${curdir}/initram-root"
73 newinitrfs="${curdir}/initram.igz"
74 modulesdir="${newramfs}/lib/modules"
76 # prepare root of new initramfs
77 [ -d ${newramfs} ] && rm -rf ${newramfs}
79 cp -a ${REPOBIN}/overlay-initramfs/* ${newramfs}/
80 mkdir -p ${modulesdir}
82 # extract the old ramdisks
83 for ker in rescuecd rescue64 altker32 altker64
85 oldimg="${REPOBIN}/kernels-x86/${ker}.igz"
86 newdir="${curdir}/${ker}-tmp"
87 echo "extracting ${oldimg}..."
89 ( cd "${newdir}" && cat ${oldimg} | gzip -d | cpio -id 2>/dev/null )
92 # copy {rescue64,altker32,altker64}/lib/modules to the new initramfs
93 for ker in rescuecd rescue64 altker32 altker64
95 cp -a ${curdir}/${ker}-tmp/lib/modules/* ${modulesdir}/
98 # copy custom busybox binary to the new initramfs
99 cp ${curdir}/rescuecd-tmp/bin/busybox ${newramfs}/bin/
100 ( cd ${newramfs}/bin/ ; ln busybox sh )
102 # update the init boot script in the initramfs
103 cp ${REPOSRC}/mainfiles/linuxrc* ${newramfs}/
104 cp ${REPOSRC}/mainfiles/linuxrc ${newramfs}/init
106 # strip and compress kernel modules which are in the sysrcd.dat to save space
107 find ${modulesdir} -name "*.ko" -exec strip --strip-unneeded '{}' \;
108 find ${modulesdir} -name "*.ko" -exec gzip '{}' \;
110 # build new initramfs
111 echo 'building the new initramfs...'
112 ( cd ${newramfs} && find . | cpio -H newc -o | gzip -9 > ${newinitrfs} )
114 # remove old igz-images and tmp-dirs
115 [ -d ${newramfs} ] && rm -rf ${newramfs}
116 for ker in rescuecd rescue64 altker32 altker64
118 #[ -f "${curdir}/${ker}.igz" ] && rm -f "${curdir}/${ker}.igz"
119 [ -d "${curdir}/${ker}-tmp" ] && rm -rf "${curdir}/${ker}-tmp"
122 # ========= copy the new files to the pxe environment =========================
125 cp ${TEMPDIR}/sysrcd.dat /tftpboot/
126 cp ${TEMPDIR}/sysrcd.md5 /tftpboot/
127 cp ${TEMPDIR}/isolinux/* /tftpboot/
130 # ========= prepare the ISO image =============================================
131 ISOFILE="${DESTDIR}/systemrescuecd-${CURARCH}-${VERSION}-${MYDATE}.iso"
133 if [ "${CURARCH}" = "x86" ] || [ "${CURARCH}" = "amd64" ]
135 mkisofs -J -l -V ${VOLNAME} -input-charset utf-8 -o ${ISOFILE} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${TEMPDIR}
138 if [ "${CURARCH}" = "sparc" ]
140 mkisofs -G /boot/isofs.b -J -V ${VOLNAME} -B ... -r -o ${ISOFILE} ${TEMPDIR}
143 # ========= prepare the backup ==================================================
144 tar cfjp "${DESTDIR}/systemrescuecd-${CURARCH}-${VERSION}-${MYDATE}.tar.bz2" /worksrc/sysresccd-src /worksrc/sysresccd-bin --exclude='.git'