File indexing completed on 2025-01-05 04:27:23
0001 #!/usr/bin/env bash 0002 #set -x 0003 0004 ############################################################################ 0005 # Disassemble an Amarok LiveCD iso file into a specified directory 0006 # for the purpose of adding a users own music and putting it back together 0007 # 0008 # Based on a script authored by Ivan Kerekes <ikerekes@gmail.com> 0009 # and modified by Leo Franchi <lfranchi at gmaildotcom>, Mike Diehl 0010 # <madpenguin8 at yahoodotcom> and Greg Meyer <greg at gkmwebdotcom> 0011 # 0012 # See the file called README for more information 0013 ############################################################################ 0014 # 0015 # This program is free software; you can redistribute it and/or modify 0016 # it under the terms of the GNU General Public License as published by 0017 # the Free Software Foundation; either version 2 of the License, or 0018 # (at your option) any later version. 0019 # 0020 ############################################################################ 0021 0022 # We need to be root to mount the loopback 0023 # check for root and exit if not 0024 0025 if [ `/usr/bin/whoami` = 'root' ]; then 0026 0027 kdialog --title "Amarok livecd remaster" --yesno "Welcome to the Amarok live cd remaster utility. The first step is to select the iso image, would you like to continue." 0028 0029 if [ $? = 0 ] ; then 0030 0031 iso=`kdialog --getopenfilename /home "*.iso"` 0032 0033 WORK=`kdialog --title "Choose working directory" --getexistingdirectory .` 0034 0035 if [ $WORK = 0 ] ; then 0036 exit; 0037 fi 0038 0039 # Determine if enough space 0040 0041 redo=0 0042 enough=0 0043 tmp=$WORK 0044 while [ "$redo" = "0" ]; do 0045 while [ "$enough" = "0" ]; do # loops until found something 0046 if [[ -n `df | grep $tmp` ]] ; then # we got it in df, find the space left 0047 anotmp=`df | grep $tmp | sed "s~^\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\)$~\4~"` # now we have a string, first item is free space in / 0048 free=`echo $anotmp | sed "s~^\([^ ]*\) \(.*\)~\1~"` # get first space-delimited item 0049 echo "comparing" $free "to 1572864" 0050 if [[ $free -gt 1572864 ]] ; then 0051 enough=1 0052 redo=1 0053 break 0054 else 0055 kdialog --sorry "Not enough free space. Please select another folder." 0056 break 0057 fi 0058 else 0059 res=`echo "$tmp" | sed "s~/\(.*\)/\([^/]*\)$~/\1~"` 0060 if [[ "$tmp" = "$res" ]]; then # last one, regexp fails here 0061 tmp="/" 0062 else #normal, removes one dir from path 0063 tmp=$res 0064 fi 0065 echo "new tmp: " $tmp 0066 fi 0067 done 0068 if [[ "$redo" = "0" ]]; then 0069 WORK=`kdialog --title "Choose working directory" --getexistingdirectory .` 0070 tmp=$WORK 0071 if [[ "$?" == 0 ]]; then 0072 break 0073 else 0074 exit 0075 fi 0076 enough=0 0077 fi 0078 done 0079 0080 # Mount the iso if not already mounted 0081 if [ ! -d "$DATADIR" ]; then 0082 DATADIR=$WORK/livecd_data$$ 0083 mkdir -p "$DATADIR" 0084 mount -o loop "$iso" "$DATADIR" 0085 fi 0086 0087 # Make the working directories and blow out the initrd.gz into a separate directory 0088 0089 mkdir -p $WORK/mklivecd/livecd 0090 cp -a --preserve "$DATADIR"/* $WORK/mklivecd/livecd/ 0091 mkdir -p $WORK/mklivecd/initrd.dir 0092 mkdir -p $WORK/mklivecd/initrd.mnt 0093 gunzip -c $WORK/mklivecd/livecd/isolinux/initrd.gz > $WORK/mklivecd/livecd/isolinux/initrd 0094 mount -o loop $WORK/mklivecd/livecd/isolinux/initrd $WORK/mklivecd/initrd.mnt 0095 (cd $WORK/mklivecd/initrd.mnt ; tar cf - .) | (cd $WORK/mklivecd/initrd.dir ; tar xf -) 0096 umount $WORK/mklivecd/initrd.mnt 0097 rm -f $WORK/mklivecd/livecd/isolinux/initrd 0098 0099 0100 # cleanup all temporary files and directories 0101 0102 umount "$DATADIR" 2>/dev/null >/dev/null 0103 if [ "$?" = "0" ]; then rmdir $DATADIR; fi 0104 0105 # at this point we unsquash the fs so the user can add their own music 0106 0107 if [[ `cat /proc/filesystems | grep squash | wc -l` = 0 ]]; then 0108 modprobe squashfs 0109 if [[ `cat /proc/filesystems | grep squash | wc -l` = 0 ]]; then 0110 0111 kdialog --title "Amarok livecd remaster" --error "You do not have squashfs support enabled. You need to have a patched kernel with squashfs. You can find more info about squashfs, and how to patch your kernel, here: http://tldp.org/HOWTO/SquashFS-HOWTO/" 0112 0113 rm -rf $WORK/mklivecd 0114 fi 0115 fi 0116 0117 mkdir $WORK/amarok.livecd/ 0118 mount -o loop -t squashfs $WORK/mklivecd/livecd/livecd.sqfs $WORK/amarok.livecd/ 0119 0120 # gotta copy it locally so the user can add files to it 0121 0122 mkdir $WORK/amarok.live/ 0123 kdialog --title "Amarok livecd remaster" --msgbox "Copying files now. Please be patient, this step takes a long time." 0124 echo 0125 echo "Please wait, copying in progress." 0126 echo 0127 cp -a $WORK/amarok.livecd/* $WORK/amarok.live/ 0128 umount $WORK/amarok.livecd/ 0129 rmdir $WORK/amarok.livecd 0130 0131 kdialog --title "Amarok livecd remaster" --msgbox "Copying done. To add music to the Amarok livecd, place additional music in /tmp/amarok.live/music/ Please do not add more than about 380 mb, as then the resulting ISO will be too large to fit on a CD-ROM. Once you are done, run the amarok.live.remaster.part2.sh script and you are finished!." 0132 0133 fi 0134 0135 else 0136 0137 kdialog --title "Amarok livecd remaster" --sorry "You must run this script as root. Try running 'kdesu sh amarok.live.remaster.part1.sh' instead." 0138 0139 fi