- JWM theme, icon theme, GTK theme and wallpaper selection GUI
- More fixes, detection of errors
- Slightly faster
- Better GUI
- Puplet name, version and prefix
- Works with Puppy 4.3.1 and above (all Woofed puppies)
TODO:
- Default applications wizard integration
- Make the pets/stuff directories really optional (no need to specify if you don't want them)
Code: Select all
#!/bin/busybox ash
# Moo - a simple Puppy remaster tool
# Iguleder, June 2010, GPL, gl hf
. /etc/DISTRO_SPECS
# the puplet name, prefix and version
export pupletName=$DISTRO_NAME
export pupletPrefix=$DISTRO_FILE_PREFIX
export pupletVersion=$DISTRO_VERSION
# the ISO you wish to remaster
export originalIso="/path/to/iso"
# a directory with PETs to slipstream and an optional directory to copy over to the main SFS
export petsDirectory="/root/moo/pets"
export stuffDirectory="/root/moo/stuff"
# a working for all operations directory
export workingDirectory="/tmp"
# the directory for the remastered iso
export isoDirectory="/root"
# a working directory where the SFS is extracted, needs plenty of space
export sfsWorkingDirectory="$workingDirectory/sfstemp"
# a working directory for the initramfs
export initramfsWorkingDirectory="$workingDirectory/initramfstemp"
# a working directory for the extracted, remastered ISO
export isoWorkingDirectory="$workingDirectory/isotemp"
# a working directory for PETs
export petWorkingDirectory="$workingDirectory/pettemp"
# a temporary mount point for the ISO
export isoMountPoint="/mnt/`basename $originalIso`"
# export all functions, credit goes to sc0ttman
set -a
mount_iso()
{
echo "Creating a mount point for the ISO"
mkdir -p "$isoMountPoint"
echo "Mounting the ISO"
mount -t iso9660 -o loop,ro "$originalIso" "$isoMountPoint"
}
extract_iso()
{
echo "Creating the ISO working directory"
mkdir -p "$isoWorkingDirectory"
sfsFileName="$(basename `ls $isoMountPoint/*.sfs`)"
echo "Extracting the ISO"
for file in `ls $isoMountPoint/*`; do
temp=`basename $file`
if [ "$temp" != "$sfsFileName" ]; then
echo " $temp"
cp $file "$isoWorkingDirectory"
fi
done
}
unmount_iso()
{
echo "Unmounting the ISO"
umount -d "$isoMountPoint"
echo "Removing the ISO mount point"
rmdir "$isoMountPoint"
}
extract_sfs()
{
echo "Extracting the Puppy SFS"
unsquashfs -d "$sfsWorkingDirectory" "$isoMountPoint/$sfsFileName" > /dev/null 2>&1
}
# usage: add_pet /path/to/pet
add_pet()
{
echo "Adding `basename $1`"
echo " Extracting"
tar xzf $1 -C $petWorkingDirectory > /dev/null 2>&1
echo " Copying files to the SFS working directory"
cp -r $petWorkingDirectory/*/* "$sfsWorkingDirectory"
if [ -f "$sfsWorkingDirectory/pinstall.sh" ]; then
echo " Executing pinstall.sh"
chroot $sfsWorkingDirectory bash pinstall.sh
rm $sfsWorkingDirectory/pinstall.sh
fi
echo " Cleaning the PET working directory"
rm -r $petWorkingDirectory/*
}
add_pets()
{
echo "Creating the PET working directory"
mkdir "$petWorkingDirectory"
for pet in `find $petsDirectory -name '*.pet'`; do
add_pet `realpath $pet`
done
echo "Deleting PET working directory"
rmdir "$petWorkingDirectory"
rm $sfsWorkingDirectory/*pet.specs
}
add_stuff()
{
if [ -f "$stuffDirectory" ]; then
if [ "`ls $stuffDirectory`" != "" ]; then
echo "Adding other stuff"
cp -r $stuffDirectory/* "$sfsWorkingDirectory"
fi
fi
}
create_sfs()
{
echo "Creating the remastered SFS"
mksquashfs "$sfsWorkingDirectory" "$isoWorkingDirectory/$pupletPrefix-$pupletVersion.sfs"
echo "Deleting the SFS working directory"
rm -r "$sfsWorkingDirectory"
}
create_iso()
{
cd "$isoWorkingDirectory"
echo "Creating the ISO"
mkisofs -D -R -o "$isoDirectory/$pupletPrefix-$pupletVersion.iso" -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table "$isoWorkingDirectory"
echo "Deleting the ISO working directory"
rm -r "$isoWorkingDirectory"
if [ -f $isoDirectory/$pupletPrefix-$pupletVersion.iso ]; then
export flag=1
fi
}
last_minute()
{
cd $sfsWorkingDirectory
. etc/DISTRO_SPECS
echo "Doing all last-minute stuff"
echo " Setting the puplet name"
sed s/DISTRO_NAME=\'$DISTRO_NAME\'/DISTRO_NAME=\'$pupletName\'/ etc/DISTRO_SPECS > etc/DISTRO_SPECS_temp
mv etc/DISTRO_SPECS_temp etc/DISTRO_SPECS
echo " Setting the puplet version"
sed s/DISTRO_VERSION=$DISTRO_VERSION/DISTRO_VERSION=$pupletVersion/ etc/DISTRO_SPECS > etc/DISTRO_SPECS_temp
mv etc/DISTRO_SPECS_temp etc/DISTRO_SPECS
echo " Setting the puplet file prefix"
sed s/DISTRO_FILE_PREFIX=\'$DISTRO_FILE_PREFIX\'/DISTRO_FILE_PREFIX=\'$pupletPrefix\'/ etc/DISTRO_SPECS > etc/DISTRO_SPECS_temp
mv etc/DISTRO_SPECS_temp etc/DISTRO_SPECS
echo " Running fixmenus"
chroot . fixmenus > /dev/null 2>&1
}
# must run before create_sfs (!!!)
create_initramfs()
{
echo "Remastering the initramfs"
echo " Creating the initramfs working directory"
mkdir "$initramfsWorkingDirectory"
echo " Moving over the initramfs"
mv "$isoWorkingDirectory/initrd.gz" "$initramfsWorkingDirectory"
cd "$initramfsWorkingDirectory"
echo " Extracting the initramfs"
gunzip initrd.gz
cpio -i < initrd
rm initrd
echo " Writing the puplet information"
cp "$sfsWorkingDirectory/etc/DISTRO_SPECS" .
echo " Creating the remastered initramfs"
find . | cpio -o -H newc | gzip -9 > "$isoWorkingDirectory/initrd.gz"
echo "Deleting the initramfs working directory"
rm -r "$initramfsWorkingDirectory"
}
# a wrapper for everything
remaster()
{
if [ "`initial_checks`" = "passed" ]; then
msgbox "The remastering process will begin now. It may take time; you will see a message when it is over. Press \"OK\" to continue."
mount_iso
if [ "$(mount | grep "on $isoMountPoint")" != "" ]; then
extract_iso
if [ "`ls $isoWorkingDirectory`" != "" ]; then
extract_sfs
if [ "`ls $sfsWorkingDirectory`" != "" ]; then
unmount_iso
if [ "$(mount | grep "on $isoMountPoint")" = "" ]; then
add_pets
add_stuff
last_minute
select_artwork
create_initramfs
if [ -f "$isoWorkingDirectory/initrd.gz" ]; then
create_sfs
if [ -f "$isoWorkingDirectory/$pupletPrefix-$pupletVersion.sfs" ]; then
create_iso
else
error="unable to create the SFS."
fi
else
error="unable to create the initramfs."
fi
else
error="unable to unmount the ISO."
fi
else
error="unable to extract the SFS."
fi
else
error="unable to extract the ISO."
fi
else
error="unable to mount the ISO."
fi
if [ "$flag" = 1 ]; then
msgbox "Done! Your remastered ISO is $isoDirectory/$pupletPrefix-$pupletVersion.iso."
else
msgbox "Error: $error"
clean_up
fi
else
msgbox "Something is wrong with the selected options. Make sure all fields contain valid values."
fi
}
select_artwork()
{
echo "Locating artwork"
cd "$sfsWorkingDirectory"
for iconTheme in `ls -1 usr/local/lib/X11/themes`; do
if [ "`file usr/local/lib/X11/themes/$iconTheme | grep directory`" != "" ]; then
export iconThemes="$iconThemes<item>$iconTheme</item>"
fi
done
for jwmTheme in `ls -1 root/.jwm/themes | grep jwmrc`; do
export jwmThemes="$jwmThemes<item>${jwmTheme%%-jwmrc*}</item>"
done
for wallpaper in `ls -1 usr/share/backgrounds`; do
export wallpapers="$wallpapers<item>$wallpaper</item>"
done
for gtkTheme in `ls -1 usr/share/themes`; do
if [ "$gtkTheme" != "Default" ]; then
export gtkThemes="$gtkThemes<item>$gtkTheme</item>"
fi
done
export themeChooser='
<vbox>
<hbox>
<text><label>Icon theme:</label></text>
<combobox width-request="250">
<variable>iconTheme</variable>
'$iconThemes'
</combobox>
</hbox>
<hbox>
<text><label>JWM theme:</label></text>
<combobox width-request="250">
<variable>jwmTheme</variable>
'$jwmThemes'
</combobox>
</hbox>
<hbox>
<text><label>Wallpaper:</label></text>
<combobox width-request="250">
<variable>wallpaper</variable>
'$wallpapers'
</combobox>
</hbox>
<hbox>
<text><label>GTK theme:</label></text>
<combobox width-request="250">
<variable>gtkTheme</variable>
'$gtkThemes'
</combobox>
</hbox>
<button label="OK" has-focus="true">
<action>echo $iconTheme > /tmp/moo</action>
<action>echo $jwmTheme >> /tmp/moo</action>
<action>echo $wallpaper >> /tmp/moo</action>
<action>echo $gtkTheme >> /tmp/moo</action>
<action>EXIT:Exit</action>
</button>
</vbox>'
gtkdialog3 -c -p themeChooser > /dev/null 2>&1
iconTheme=`cat /tmp/moo | head -1`
jwmTheme=`cat /tmp/moo | head -2 | tail -1`
wallpaper=`cat /tmp/moo | head -3 | tail -1`
gtkTheme=`cat /tmp/moo | tail -1`
rm /tmp/moo
echo "Setting artwork"
rm usr/local/lib/X11/pixmaps/*
cp -a usr/local/lib/X11/themes/$iconTheme/* usr/local/lib/X11/pixmaps
echo $iconTheme > etc/desktop_icon_theme
cp -f root/.jwm/themes/$jwmTheme-colors root/.jwm/jwm_colors
cp -f root/.jwm/themes/$jwmTheme-jwmrc root/.jwm/jwmrc-theme
cp usr/share/backgrounds/$wallpaper usr/share/backgrounds/default.jpg
echo "# -- THEME AUTO-WRITTEN DO NOT EDIT
include \"/usr/share/themes/$gtkTheme/gtk-2.0/gtkrc\"
include \"/root/.gtkrc.mine\"
# -- THEME AUTO-WRITTEN DO NOT EDIT" > root/.gtkrc-2.0
}
msgbox()
{
export message="
<vbox>
<text><label>$1</label></text>
<button label=\"OK\" has-focus=\"true\">
<action>EXIT:Exit</action>
</button>
</vbox>"
gtkdialog3 -c -p message > /dev/null 2>&1
}
initial_checks()
{
if [[ -f "$originalIso" && -d "$workingDirectory" && -d "$petsDirectory" && -d "$stuffDirectory" && "$pupletName" != "" && "$pupletVersion" != "" && "$pupletPrefix" != "" && -d "$isoDirectory" ]]; then
echo "passed"
fi
}
clean_up()
{
echo "Cleaning up"
if [ -d "$isoMountPooint" ]; then
if [ "$(mount | grep "on $isoMountPoint")" != "" ]; then
umount "$isoMountPoint"
fi
rmdir "$isoMountPoint"
fi
if [ -f "$sfsWorkingDirectory" ]; then
rm -r "$sfsWorkingDirectory"
fi
if [ -f "$initramfsWorkingDirectory" ]; then
rm -r "$initramfsWorkingDirectory"
fi
if [ -f "$isoWorkingDirectory" ]; then
rm -r "$isoWorkingDirectory"
fi
if [ -f /tmp/moo ]; then
rm /tmp/moo
fi
}
export gui='
<window title="Moo 003" allow-grow="false">
<vbox>
<text><label>Welcome to the Moo remaster tool.</label></text>
<frame Technical Stuff>
<hbox>
<text><label>The Puppy ISO to remaster:</label></text>
<entry accept="file" >
<default>"'$originalIso'"</default>
<variable>originalIso</variable>
</entry>
<button>
<input file icon="gtk-file"></input>
<action type="fileselect">originalIso</action>
</button>
</hbox>
<hbox>
<text><label>A working directory (at least 512 MB free):</label></text>
<entry accept="directory">
<default>"'$workingDirectory'"</default>
<variable>workingDirectory</variable>
</entry>
<button>
<input file icon="gtk-file"></input>
<action type="fileselect">workingDirectory</action>
</button>
</hbox>
<hbox>
<text><label>A directory with PETs to slipstream (optional):</label></text>
<entry accept="directory">
<default>"'$petsDirectory'"</default>
<variable>petsDirectory</variable>
</entry>
<button>
<input file icon="gtk-file"></input>
<action type="fileselect">petsDirectory</action>
</button>
</hbox>
<hbox>
<text><label>A directory with stuff to copy to the main SFS (optional):</label></text>
<entry accept="directory">
<default>"'$stuffDirectory'"</default>
<variable>stuffDirectory</variable>
</entry>
<button>
<input file icon="gtk-file"></input>
<action type="fileselect">stuffDirectory</action>
</button>
</hbox>
</frame>
<frame The Puplet Information>
<hbox>
<vbox>
<text><label>The puplet name:</label></text>
<entry>
<default>"'$pupletName'"</default>
<variable>pupletName</variable>
</entry>
</vbox>
<vbox>
<text><label>The puplet prefix:</label></text>
<entry>
<default>"'$pupletPrefix'"</default>
<variable>pupletPrefix</variable>
</entry>
</vbox>
<vbox>
<text><label>The puplet version:</label></text>
<entry>
<default>"'$pupletVersion'"</default>
<variable>pupletVersion</variable>
</entry>
</vbox>
</hbox>
</frame>
<hbox>
<text><label>Location for the remastered ISO:</label></text>
<entry>
<default>"'$isoDirectory'"</default>
<variable>isoDirectory</variable>
</entry>
<button>
<input file icon="gtk-file"></input>
<action type="fileselect">isoDirectory</action>
</button>
</hbox>
<hbox>
<button>
<label>Remaster</label>
<action>remaster</action>
</button>
<button use-stock="true" label="gtk-quit">
<label>Exit</label>
<action type="exit">EXIT_NOW</action>
</button>
</hbox>
</vbox>
</window>'
gtkdialog3 -p gui