From: W. Trevor King Date: Mon, 22 Mar 2010 22:36:02 +0000 (-0400) Subject: Added commandline options to buildscripts/recreate-iso.sh X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8de8cf1a3a4ff0fd78dde26e36326ee265e9f8bb;p=systemrescuecd.git Added commandline options to buildscripts/recreate-iso.sh --- diff --git a/buildscripts/recreate-iso.sh b/buildscripts/recreate-iso.sh index d0ddd88..063e18d 100755 --- a/buildscripts/recreate-iso.sh +++ b/buildscripts/recreate-iso.sh @@ -1,74 +1,111 @@ #!/bin/sh +## HELP AND BASIC ARGUMENT PROCESSING +##################################### + +PROG="${0}" VERSION="1.5.0" EXTRAVER="" VOLNAME="sysrcd-1.5.0" ISODIR=/worksrc/isofiles -TEMPDIR=/worksrc/catalyst/isotemp +MOUNTDIR=/mnt/cdrom +WORKDIR=/worksrc/catalyst/isotemp +DESTDIR=/home/sysresccdiso REPOSRC=/worksrc/sysresccd-src REPOBIN=/worksrc/sysresccd-bin - -# ================================================================== -# ================================================================== +MYDATE=$(date +%Y%m%d-%Hh%M) usage() { - echo "Usage: $0 " - echo " arch = x86 | amd64 | sparc" + cat < + +Rebuild the distribution iso by applying the SystemRescueCD overlays +and recent kernels to a previous vesion. + +arch: x86 | amd64 | sparc + +Options: + -h|--help Display this screen and exit + -i ISODIR Directory containing the iso file to rebuild ($ISODIR) + /systemrescuecd--current.iso + -w WORKDIR Set the work directory for the custom CD (${WORKDIR}) + -r REPOSRC Location of git systemrescuecd repo ($REPOSRC) + -r REPOBIN ? ($REPOBIN) + -d DESTDIR Set the directory for saving the rebuild iso file ($DESTDIR) + -m MOUNTDIR Set the directory for mounting the current iso ($MOUNTDIR) + +Distributed under the GNU Public License version 2 - http://www.sysresccd.org +EOF } +while getopts ":i:w:r:b:d:m:" Option +do + case $Option in + i ) ISODIR="$OPTARG";; + w ) WORKDIR="$OPTARG";; + r ) REPOSRC="$OPTARG";; + b ) REPOBIN="$OPTARG";; + d ) DESTDIR="$OPTARG";; + m ) MOUNTDIR="$OPTARG";; + * ) usage; exit 1;; # Default, handles -h + esac +done +shift $(($OPTIND - 1)) + if [ "$1" = "x86" ] || [ "$1" = "amd64" ] || [ "$1" = "sparc" ] then - CURARCH="$1" + ARCH="$1" else - usage + usage # handles --help exit 1 fi +## ERROR HANDLING +##################################### + +die() +{ + if [ -n "$1" ] + then + echo "${PROG}: error: $1" + else + echo "${PROG}: aborting." + fi + exit 1 +} + # ========= copy files from the temp iso image ================================ -CURFILE="${ISODIR}/systemrescuecd-${CURARCH}-current.iso" -MYDATE=$(date +%Y%m%d-%Hh%M) -DESTDIR=/home/sysresccdiso +CURFILE="${ISODIR}/systemrescuecd-${ARCH}-current.iso" + mkdir -p ${DESTDIR} -if [ ! -f "${CURFILE}" ] -then - echo "Cannot find \"${CURFILE}\". Failed" - exit 1 -fi +[ -f "${CURFILE}" ] || die "Cannot find \"${CURFILE}\"" -umount /mnt/cdrom 2>/dev/null -if ! mount -o loop,ro ${CURFILE} /mnt/cdrom -then - echo "Cannot mount ${CURFILE}" - exit 1 -fi +umount ${MOUNTDIR} 2>/dev/null || die "Cannot unmount \"${MOUNTDIR}\"" +mount -o loop,ro ${CURFILE} ${MOUNTDIR} || die "Cannot mount \"${CURFILE}\"" -if [ ! -f /mnt/cdrom/image.squashfs ] -then - echo "Cannot find a valid file in the ISO" - exit 1 -fi +[ -f ${MOUNTDIR}/image.squashfs ] || die "Cannot find a valid file in the ISO" -[ -d ${TEMPDIR} ] && rm -rf ${TEMPDIR} -mkdir -p ${TEMPDIR} -cp /mnt/cdrom/isolinux/rescuecd* ${REPOBIN}/kernels-x86/ -cp /mnt/cdrom/image.squashfs ${TEMPDIR}/sysrcd.dat -( cd ${TEMPDIR} ; md5sum sysrcd.dat > sysrcd.md5 ; chmod 644 sysrcd.* ) -umount /mnt/cdrom +[ -d ${WORKDIR} ] && rm -rf ${WORKDIR} +mkdir -p ${WORKDIR} +cp ${MOUNTDIR}/isolinux/rescuecd* ${REPOBIN}/kernels-x86/ +cp ${MOUNTDIR}/image.squashfs ${WORKDIR}/sysrcd.dat +( cd ${WORKDIR} ; md5sum sysrcd.dat > sysrcd.md5 ; chmod 644 sysrcd.* ) +umount ${MOUNTDIR} # ========= copy files from overlays =========================================== -rsync -ax ${REPOBIN}/overlay-iso-x86/ "${TEMPDIR}/" -rsync -ax ${REPOSRC}/overlay-iso-x86/isolinux/ "${TEMPDIR}/isolinux/" -rsync -ax ${REPOBIN}/kernels-x86/ ${TEMPDIR}/isolinux/ --exclude='*.igz' -cp ${REPOSRC}/overlay-squashfs-x86/root/version ${TEMPDIR} +rsync -ax ${REPOBIN}/overlay-iso-${ARCH}/ "${WORKDIR}/" +rsync -ax ${REPOSRC}/overlay-iso-${ARCH}/isolinux/ "${WORKDIR}/isolinux/" +rsync -ax ${REPOBIN}/kernels-${ARCH}/ ${WORKDIR}/isolinux/ --exclude='*.igz' +cp ${REPOSRC}/overlay-squashfs-${ARCH}/root/version ${WORKDIR} # ========= integrate the version number in f1boot.msg ========================= -TXTVERSION=$(cat ${REPOSRC}/overlay-squashfs-x86/root/version) -sed -i -e "s/VERSION/${TXTVERSION}${EXTRAVER}/" ${TEMPDIR}/isolinux/f1boot.msg +TXTVERSION=$(cat ${REPOSRC}/overlay-squashfs-${ARCH}/root/version) +sed -i -e "s/VERSION/${TXTVERSION}${EXTRAVER}/" ${WORKDIR}/isolinux/f1boot.msg # ========= merge (rescuecd.igz+rescue64.igz+altker32.igz) --> rescuecd.igz ==== -curdir="${TEMPDIR}/isolinux" +curdir="${WORKDIR}/isolinux" newramfs="${curdir}/initram-root" newinitrfs="${curdir}/initram.igz" modulesdir="${newramfs}/lib/modules" @@ -82,7 +119,7 @@ mkdir -p ${modulesdir} # extract the old ramdisks for ker in rescuecd rescue64 altker32 altker64 do - oldimg="${REPOBIN}/kernels-x86/${ker}.igz" + oldimg="${REPOBIN}/kernels-${ARCH}/${ker}.igz" newdir="${curdir}/${ker}-tmp" echo "extracting ${oldimg}..." mkdir -p "${newdir}" @@ -122,24 +159,23 @@ done # ========= copy the new files to the pxe environment ========================= if [ -d /tftpboot ] then - cp ${TEMPDIR}/sysrcd.dat /tftpboot/ - cp ${TEMPDIR}/sysrcd.md5 /tftpboot/ - cp ${TEMPDIR}/isolinux/* /tftpboot/ + cp ${WORKDIR}/sysrcd.dat /tftpboot/ + cp ${WORKDIR}/sysrcd.md5 /tftpboot/ + cp ${WORKDIR}/isolinux/* /tftpboot/ fi # ========= prepare the ISO image ============================================= -ISOFILE="${DESTDIR}/systemrescuecd-${CURARCH}-${VERSION}-${MYDATE}.iso" +ISOFILE="${DESTDIR}/systemrescuecd-${ARCH}-${VERSION}-${MYDATE}.iso" -if [ "${CURARCH}" = "x86" ] || [ "${CURARCH}" = "amd64" ] +if [ "${ARCH}" = "x86" ] || [ "${ARCH}" = "amd64" ] then - 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} + 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 ${WORKDIR} fi -if [ "${CURARCH}" = "sparc" ] +if [ "${ARCH}" = "sparc" ] then - mkisofs -G /boot/isofs.b -J -V ${VOLNAME} -B ... -r -o ${ISOFILE} ${TEMPDIR} + mkisofs -G /boot/isofs.b -J -V ${VOLNAME} -B ... -r -o ${ISOFILE} ${WORKDIR} fi # ========= prepare the backup ================================================== -tar cfjp "${DESTDIR}/systemrescuecd-${CURARCH}-${VERSION}-${MYDATE}.tar.bz2" /worksrc/sysresccd-src /worksrc/sysresccd-bin --exclude='.git' - +tar cfjp "${DESTDIR}/systemrescuecd-${ARCH}-${VERSION}-${MYDATE}.tar.bz2" ${REPOSRC} ${REPOBIN} --exclude='.git'