#!/bin/bash # # $Id: modified-iso-build,v 1.3 2008/05/17 07:00:42 suter Exp $ # Copyright (C) 2003 Mark Suter # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ## Where the data comes and goes home=/shared/standard-build/ source=bbc-2.1.iso build=ebbe dest=modified.iso script_hd=modified-iso-install script_md=modified-iso-install-raid ## Our "die" function (think perl) function die () { echo "$@" 1>&2 ; exit 1 ; } ## Set our PATH and test for needed binaries export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin hash test id md5sum mktemp mount find bzip2 cpio cp mkisofs umount rmdir rm || die $0: required binaries not present ## We need the power! test "$( id -u )" == "0" || die $0: Please run this script as root ## Go to the right place cd $home || die $0: Cannot chdir to \$home $home directory ## Check the source md5sum -v -c $source.md5 || die $0: base iso image is corrupt ## Make a read-write copy of the iso's contents ro_mount=$( mktemp -d ) || die $0: failed to create ro area rw_copy=$( mktemp -d ) || die $0: failed to create rw area mount -o loop $source $ro_mount ( cd $ro_mount ; find . -print0 | cpio --null --make-directories --preserve-modification-time --pass-through $rw_copy ) umount $ro_mount rmdir $ro_mount ## Add the "$build" system ( cd $build ; find . -print0 | cpio --null --format=crc --create | bzip2 --best --stdout --compress > $rw_copy/$build ) cp $script_hd $rw_copy/install.sh cp $script_md $rw_copy/raid-install.sh ## Generate a modified iso image mkisofs -c boot.catalog -b lnx.img \ -A "GNU/Linux" -V "LNX-BBC" --publisher "www.lnx-bbc.org" \ -d -D -N -r -T \ -o $dest \ $rw_copy ## Clean up rm -rf $rw_copy