4 ############################################################################
5 # Disassemble an Amarok LiveCD iso file into a specified directory
6 # for the purpose of adding a users own music and putting it back together
8 # Based on a script authored by Ivan Kerekes <ikerekes@gmail.com>
9 # and modified by Leo Franchi <lfranchi at gmaildotcom>, Mike Diehl
10 # <madpenguin8 at yahoodotcom> and Greg Meyer <greg at gkmwebdotcom>
12 # See the file called README for more information
13 ############################################################################
15 # This program is free software; you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation; either version 2 of the License, or
18 # (at your option) any later version.
20 ############################################################################
25 rm -rf $WORK/amarok.live
26 rm -rf $WORK/livecd_data
*
29 # We need to be root to mount the loopback
30 # check for root and exit if not
32 if [ `/usr/bin/whoami` = 'root' ]; then
36 if [ $iso = 0 ] ; then
42 if [ $WORK = 0 ] ; then
46 # Determine if enough space
51 while [ "$redo" = "0" ]; do
52 while [ "$enough" = "0" ]; do # loops until found something
53 if [[ -n `df | grep $tmp` ]] ; then # we got it in df, find the space left
54 anotmp
=`df | grep $tmp | sed "s~^\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\)$~\4~"` # now we have a string, first item is free space in /
55 free
=`echo $anotmp | sed "s~^\([^ ]*\) \(.*\)~\1~"` # get first space-delimited item
56 # echo "comparing" $free "to 1572864"
57 if [[ $free -gt 1572864 ]] ; then
62 dcop
--all-users amarok playlist popupMessage
"Not enough free space. Please select another folder."
66 res
=`echo "$tmp" | sed "s~/\(.*\)/\([^/]*\)$~/\1~"`
67 if [[ "$tmp" = "$res" ]]; then # last one, regexp fails here
69 else #normal, removes one dir from path
72 # echo "new tmp: " $tmp
75 if [[ "$redo" = "0" ]]; then
76 WORK
=`kdialog --title "Choose working directory" --getexistingdirectory .`
78 if [[ "$?" == 0 ]]; then
87 #Mount the iso if not already mounted
88 if [ ! -d "$DATADIR" ]; then
89 DATADIR
=$WORK/livecd_data$$
91 mount
-o loop
"$iso" "$DATADIR"
94 # Make the working directories and blow out the initrd.gz into a separate directory
96 mkdir
-p $WORK/mklivecd
/livecd
97 cp -a --preserve "$DATADIR"/* $WORK/mklivecd
/livecd
/
98 mkdir
-p $WORK/mklivecd
/initrd.dir
99 mkdir
-p $WORK/mklivecd
/initrd.mnt
100 gunzip
-c $WORK/mklivecd
/livecd
/isolinux
/initrd.gz
> $WORK/mklivecd
/livecd
/isolinux
/initrd
101 mount
-o loop
$WORK/mklivecd
/livecd
/isolinux
/initrd
$WORK/mklivecd
/initrd.mnt
102 (cd $WORK/mklivecd
/initrd.mnt
; tar cf
- .
) |
(cd $WORK/mklivecd
/initrd.dir
; tar xf
-)
103 umount
$WORK/mklivecd
/initrd.mnt
104 rm -f $WORK/mklivecd
/livecd
/isolinux
/initrd
107 # cleanup all temporary files and directories
109 umount
"$DATADIR" 2>/dev
/null
>/dev
/null
110 if [ "$?" = "0" ]; then rmdir $DATADIR; fi
112 # at this point we unsquash the fs so the user can add their own music
114 if [[ `cat /proc/filesystems | grep squash | wc -l` = 0 ]]; then
116 if [[ `cat /proc/filesystems | grep squash | wc -l` = 0 ]]; then
118 dcop
--all-users amarok playlist popupMessage
"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/"
120 rm -rf $WORK/mklivecd
124 mkdir
$WORK/amarok.livecd
/
125 mount
-o loop
-t squashfs
$WORK/mklivecd
/livecd
/livecd.sqfs
$WORK/amarok.livecd
/
127 # gotta copy it locally so the user can add files to it
129 mkdir
$WORK/amarok.live
/
130 dcop
--all-users amarok playlist shortStatusMessage
"Copying files now. Please be patient, this step takes a long time."
132 #echo "Please wait, copying in progress."
134 cp -a $WORK/amarok.livecd
/* $WORK/amarok.live
/
135 umount
$WORK/amarok.livecd
/
136 rmdir $WORK/amarok.livecd
138 mkdir
$WORK/amarok.live
/home
/amarok
/.kde
/share
/apps
/amarok
/playlists
139 chown
500:500 $WORK/amarok.live
/home
/amarok
/.kde
/share
/apps
/amarok
/playlists
140 find $WORK/amarok.live
/home
/amarok
/.kde
/share
/apps
/ -type d
-print0 |
xargs -0 chmod +x
141 chmod -R 777 $WORK/amarok.live
/music
/
142 chmod -R 777 $WORK/amarok.live
/home
/amarok
/.kde
/share
/apps
/amarok
143 #chmod -R 777 $WORK/mklivecd/
145 dcop
--all-users amarok playlist popupMessage
"Copying done. To add music to the Amarok livecd, select the tracks you wish to add in the playlist, and select \"Add to livecd\" from the right click menu. 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, select Create Remastered CD. Enjoy!"
149 kdialog
--title "Amarok livecd remaster" --sorry "You must run this script as root. Try running 'kdesu sh amarok.live.remaster.part1.sh' instead."