home *** CD-ROM | disk | FTP | other *** search
- #!/bin/bash
- # Knoppix.mkcompressed
- # $Id: knoppixFreedom.mkCompressed,v 1.5 2005/02/24 10:26:10 wilde Exp $
-
- DEST="$1"
- DEST_ENV="$DEST"_env
-
- [ -z "$DEST" -o ! -d "$DEST" ] && { echo "Usage: $0 DESTINATIONDIR" >&2 ; exit 1; }
- [ ! -x /usr/bin/create_compressed_fs ] && { echo "Need /usr/bin/create_compressed_fs." ; exit 1; }
- [ `whoami` != "root" ] && { echo "Need to be root to run $0" ; exit 1 ; }
-
- # Compression blocksize (must be multiple of 512)
- # All block headers must fit into a kmalloc segment (ca. 130000 bytes)
- BLOCKSIZE=65536
- # BLOCKSIZE=53248
- #BLOCKSIZE=102400
-
- echo -n "Recreate KNOPPIX compressed FS? "
- read answer
- if [ x"$answer" = x"y" ]
- then
- [ ! -d "$DEST_ENV" ] && { echo "Need knoppix_environment: $DEST_ENV" ; exit 1; }
- SUDOERS=$DEST_ENV/etc/sudoers
- [ ! -r "$SUDOERS" ] && { echo "Cannot read : $SUDOERS. Are we root?" ; exit 1; }
-
- ! find "$SUDOERS" -uid 0 -perm 440 &&
- { echo "$SUDOERS does not belong to uid 0 with perm 440." ; exit 1; }
-
- chmod gu+w "$DEST"/KNOPPIX
- rm -f "$DEST"/KNOPPIX/KNOPPIX
-
- if [ -f sortfile.template ]
- then
- if [ -f mkisofs.sort ]
- then
- echo "Backing up mkisofs.sort as mkisofs.sort~"
- [ ! -w mkisofs.sort~ ] && echo "Warning: can not write mkisofs.sort~"
- cp -a mkisofs.sort mkisofs.sort~
- fi
- echo "Creating mkisofs.sort from sortfile.template"
- [ ! -w mkisofs.sort ] && echo "Warning: can not write to mkisofs.sort!"
- sed /^$/d sortfile.template | sed "/^#/d" | sed s/DIR/$DEST_ENV/g | awk 'BEGIN {x=10000}; {print $1, x--}' > mkisofs.sort
- fi
-
-
- SORT=""
- if [ -e mkisofs.sort ]
- then SORT="-sort mkisofs.sort"
- else echo "Warning: mkisofs.sort does not exist. The created CD will probably boot slow."
- fi
- nice mkisofs -R -U -v $SORT -V "Freie Software KNOPPIX" -P "Intevation <A HREF='http://www.intevation.net/'>www.intevation.net</A>" -hide-rr-moved -cache-inodes -no-bak -pad "$DEST_ENV" \
- | nice -5 /usr/bin/create_compressed_fs - $BLOCKSIZE >"$DEST"/KNOPPIX/KNOPPIX || exit 1
- chmod 444 "$DEST"/KNOPPIX/KNOPPIX
- fi
-
- echo -n "Recreate md5sums file? "
- read answer
- if [ x"$answer" = x"y" ]; then
- echo "updating md5sums (this will take some time)..."
- OLDWD=`pwd`
- cd "$DEST"
- rm -f KNOPPIX/md5sums
- (find . -type f -exec md5sum \{\} \;) >../md5sums.new
- mv ../md5sums.new KNOPPIX/md5sums
- cd "$OLDWD"
- fi
-
- mkfinal() {
- TARGET="$1.iso.modified"
- mkisofs -pad -l -r -J -v \
- -V 'Freie Software KNOPPIX' -A 'Freie Software KNOPPIX CD-ROM' \
- -P "INTEVATION.DE <A HREF='http://www.intevation.net/'>www.intevation.net</A>" \
- -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -no-emul-boot \
- -boot-load-size 4 -boot-info-table -hide-rr-moved -o "$TARGET" "$DEST"
- }
-
- echo -n "Recreate KNOPPIX isofile '$DEST.iso.modified'? "
- read answer
- if [ x"$answer" = x"y" ]; then
- ## DEPRECATED: knoppix uses isolinux now... -sw-
- ##
- ## Make sure that the boot floppy file is at the beginning of the image.
- ## Some controllers seem to depend on this.
- #rm -f /tmp/knoppix.sort
- #echo "$DEST/KNOPPIX/boot.img 100002" >/tmp/knoppix.sort
- #echo "$DEST/KNOPPIX/KNOPPIX 100001" >>/tmp/knoppix.sort
-
- # Make final CD Image
- mkfinal "$DEST"
- fi
-