LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Ubuntu-9.10 remaster iso script- help needed! (https://www.linuxquestions.org/questions/linux-general-1/ubuntu-9-10-remaster-iso-script-help-needed-774718/)

linus72 12-10-2009 06:40 AM

Ubuntu-9.10 remaster iso script- help needed!
 
OK
I need to do this "in the black"
so no GUI, no update-manager,etc

I know that for some reason "apt-get dist-upgrade"
doesn't seem to be the best option
http://ubuntuforums.org/archive/inde...t-1304588.html

so, any ideas?
I just need info before I screw it up

Has anyone upgraded 9.04 to 9.10 thru terminal?
thanks

linus72 12-10-2009 07:35 AM

OK
to better explain myself..

I am making a Ubuntu Remaster script that will take any 9.04/9.10 ubuntu.iso (xubuntu/kubuntu/ubuntu)
and will enable a person to add/remove pkgs, and additionally setup their desktop environment
with Xnest
and then the script receates the iso, so you have a pre-customized iso that will run and install
just like the original but with all your extra pkgs and desktop setup

so, I need some help on this one as my Bash ain't groovy yet:)

is this a good idea or no?

linus72 12-10-2009 07:49 AM

So
heres the main questions I have, as the script is working now
but needs refinement and:

1) I need to be able to fully upgrade the 9.04 iso to a 9.10, so how do I have the /etc/apt/sources.list
updated to karmic thru script?

2) I need to then remove the earlier/older kernel/initrd's completely

3) I need it also to be interactive, so thru the term the script asks you
what pkg's you want installed
the user would then type in or copy/paste in a list of pkgs, each seperated by a space
Example

iceweasel rox-filer opera

you know...then Xnest would start after installing the pkgs and you could setup desktop,etc

So, I need some help with this one...

the trooper 12-10-2009 08:01 AM

Here's a few pointers that i've picked up from Debian for upgrades.
First off it's advised to use aptitude for upgrades rather than apt-get.
Make sure 9.04 is up to date ,then change your sources.list to your target release;9.10.
Then aptitude update.
Next we'll need to install some packages so do:
aptitude install apt dpkg aptitude.
Then do the upgrade with aptitude full-upgrade.
This has worked for me with Debian YMMV with Ubuntu though.

linus72 12-10-2009 10:45 AM

OK
FIRST
forget about upgrading from 9.04 to 9.10
now, just start with 9.10 mini iso

heres where I'm at now

1) I go get clamav update script and ubuntu-mini-remix-9.10.iso
http://feedingthemachine.blogspot.co...te-script.html

http://www.crealabs.it/ubuntu-mini-remix/

2) edit script to amke new cd and add pkgs
heres the script so far:
note that you must be running from a 9.10 install or livecd with your sources.list setup

Code:

#!/bin/bash

iso="ubuntu-mini-remix-9.10"

if [ "$UID" -ne "0" ]
then
echo "This script will only work when run by "root"."
exit 1
fi

# not everyone will have squash tools, install them if not found
if [ ! `which unsquashfs` ]
then
aptitude install squashfs-tools
fi

# not everyone will have genisoimage, install it if not found
if [ ! `which mkisofs` ]
then
aptitude install genisoimage
fi

START=$(date +%s)

mkdir iso
mount $iso.iso iso/ -o loop

cp -R iso/ image/

echo "Decompressing SquashFS..."
cp iso/casper/filesystem.squashfs ./
unsquashfs filesystem.squashfs

echo "Setting up Live CD chroot..."
cp /etc/resolv.conf squashfs-root/etc/resolv.conf
cp /etc/hosts squashfs-root/etc/
cp /etc/apt/sources.list squashfs-root/etc/apt/sources.list

mount --bind /dev/ squashfs-root/dev

chroot squashfs-root/ mount -t proc none /proc
chroot squashfs-root/ mount -t sysfs none /sys
chroot squashfs-root/ mount -t devpts none /dev/pts
export HOME=/root
export LC_ALL=C

echo "Refreshing and Upgrading Packages"
chroot squashfs-root/ aptitude update
chroot squashfs-root/ aptitude -f safe-upgrade

chroot squashfs-root/ aptitude install lubuntu-desktop firefox flashplugin-nonfree
chroot squashfs-root/ aptitude clean
chroot squashfs-root/ aptitude autoclean

#cleanup chroot
echo "Cleaning up chroot..."
chroot squashfs-root/ rm -rf /tmp/*
chroot squashfs-root/ rm /etc/resolv.conf
chroot squashfs-root/ umount -l -f /proc
chroot squashfs-root/ umount -l -f /sys
chroot squashfs-root/ umount /dev/pts
exit
umount squashfs-root/dev

echo "Removing old SquashFS filesystem..."
rm image/casper/filesystem.squashfs

echo "Creating new SquashFS filesystem..."
mksquashfs squashfs-root image/casper/filesystem.squashfs

echo "Finding and creating MD5 hash sums of files in image..."
cd image
find . -type f -print0 | xargs -0 md5sum > md5sum.txt

cd ..
echo "Creating new image..."
mkisofs -r -V "ubuntu-mini-remix-9.10" -cache-inodes -J -l \
-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \
-boot-load-size 4 -boot-info-table -o $iso_new.iso image/

# Make sure that mkisofs succeeded before we try moving or renaming
# any images.
if [ $? != "0" ]
then
echo "mkisofs failed with error code: $?"
exit
fi

echo "Renaming new image, and moving original image to old..."
mv $iso.iso $iso_old.iso
mv $iso_new.iso $iso.iso

#cleanup working directory

echo "Cleaning up working directory..."
umount iso/

rm -rf squashfs-root
rm -rf image
rm -rf iso
rm filesystem.squashfs

echo "Getting MD5 and SHA1 sum of image..."
echo "MD5: " > umr-livecd.sums
md5sum $iso.iso >> umr-livecd.sums
echo "SHA1: " >> umr-livecd.sums
sha1sum $iso.iso >> umr-livecd.sums

END=$(date +%s)

echo "Done at `date`. The whole process took $(($END - $START)) seconds!"

Problems:

1) Howw to remove the old kernels/initrds without knowing the names/numbers??
I can use mv command to make a new kernel initrd for cd..
Code:

mv squashfs-root/boot/initrd.img-? iso/casper/initrd.lz
etc

2) How to completely remove pkgs as even purge remove etc
pkgs still show up in synaptic as residual ?

linus72 12-10-2009 11:32 AM

Mmmm
alright I must have screwed up the process when I added

Code:

#cleanup chroot
echo "Cleaning up chroot..."
chroot squashfs-root/ rm -rf /tmp/*
chroot squashfs-root/ rm /etc/resolv.conf
chroot squashfs-root/ umount -l -f /proc
chroot squashfs-root/ umount -l -f /sys
chroot squashfs-root/ umount /dev/pts
exit
umount squashfs-root/dev

so I removed "exit" as maybe that made the script quit?
LOL

I also added

Code:

echo "Copying your kernel and initrd for the livecd"
cp squashfs-root/boot/vmlinuz-`uname -r` image/casper/vmlinuz
cp /boot/initrd.img-`uname -r` image/casper/initrd.lz

so the newcd will have the new kernel/initrd...

and I gotta add what ubiquity,etc too huh?

lubuntu-desktop is experimental LXDE desktop

linus72 12-10-2009 06:37 PM

Update
so far its working but now I'm gonna start over a litlle
and first just use the full ubuntu-9.10 desktop iso
and add repos and apps I want
while removing bs like gnome-games,etc

Question:
after upgrading/installing
how do I, thru the terminal, remove the old kernel/initrd.img's???
thamks

linus72 12-10-2009 08:49 PM

OK

now I'm at the point of playing with the ubuntu-9.10-desktop-i386.iso
and have the script thus far removing some stuff and adding some stuff and then mksquashfs'n it

heres partial script so far...
Please note its incomplete and
for some reason /dev wont umount?
Code:

chroot squashfs-root/ umount /dev
why doesn't that work??

Code:

#!/bin/bash

iso="ubuntu-9.10-desktop-i386"

if [ "$UID" -ne "0" ]
then
echo "This script will only work when run by "root"."
exit 1
fi

# not everyone will have squash tools, install them if not found
if [ ! `which unsquashfs` ]
then
aptitude install squashfs-tools
fi

# not everyone will have genisoimage, install it if not found
if [ ! `which mkisofs` ]
then
aptitude install genisoimage
fi

START=$(date +%s)

mkdir iso
mount $iso.iso iso/ -o loop

cp -R iso/ image/

echo "Decompressing SquashFS..."
cp iso/casper/filesystem.squashfs ./
unsquashfs filesystem.squashfs

echo "Setting up Live CD chroot..."
cp /etc/resolv.conf squashfs-root/etc/resolv.conf
cp /etc/hosts squashfs-root/etc/
cp /etc/apt/sources.list squashfs-root/etc/apt/sources.list

mount --bind /dev/ squashfs-root/dev

chroot squashfs-root/ mount -t proc none /proc
chroot squashfs-root/ mount -t sysfs none /sys
chroot squashfs-root/ mount -t devpts none /dev/pts
export HOME=/root
export LC_ALL=C

echo "Refreshing and Upgrading Packages"
chroot squashfs-root/ aptitude update
chroot squashfs-root/ aptitude -f safe-upgrade

chroot squashfs-root/ aptitude purge evolution evolution-common evolution-couchdb evolution-documentation-en evolution-exchange evolution-indicator evolution-pluginsevolution-webcal gnome-games gnome-games-common openoffice.org-base-core openoffice.org-core
chroot squashfs-root/ apt-get autoremove

chroot squashfs-root/ aptitude install flashplugin-nonfree unetbootin isomaster

chroot squashfs-root/ aptitude clean
chroot squashfs-root/ aptitude autoclean

#cleanup chroot
echo "Cleaning up chroot..."
chroot squashfs-root/ rm -rf /tmp/*
chroot squashfs-root/ rm /etc/resolv.conf
chroot squashfs-root/ umount -l -f /proc
chroot squashfs-root/ umount -l -f /sys
chroot squashfs-root/ umount /dev/pts
chroot squashfs-root/ umount /dev

echo "Copying your kernel and initrd for the livecd"
cp squashfs-root/boot/vmlinuz-`uname -r` image/casper/vmlinuz
cp squashfs-root/boot/initrd.img-`uname -r` image/casper/initrd.lz

echo "Removing old SquashFS filesystem..."
rm image/casper/filesystem.squashfs

echo "Creating new SquashFS filesystem..."
mksquashfs squashfs-root image/casper/filesystem.squashfs

TODO includes adding the Xnest stuff and other stuff...?

The above script will make a squashfs of about 659MB
vs normal ubuntu 668MB

linus72 12-10-2009 08:56 PM

also, the above script will leave everything in the folder "image"
just transfer all that to fat32 usb with syslinux installed and it runs and installs:)

However, you must be root to do all that and then delete whatever

linus72 12-12-2009 08:00 AM

OK
I have now made the script at least workable:)

So, I'll break it down into parts-

1) just update & upgrade base 9.10 ubuntu iso

2) update, upgrade, uninstall stuff, install stuff

3) make new squashfs and make into new iso

TODO:
1) make it so user's /home/name and /root desktops are configured and setup
possibly just using cp to copy users /home/name/* to /etc/skel/ and then chowning,etc /etc/skel?

2) Possibly figure out how to integrate xnest into script and how to make script interactive??

OK
To run the script you need these things-

1) either running from livecd/usb with access to a 5+GB ext2/3 partition
or running from a fresh 9.10 install with all your settings set up and at least 3GB free space

2) the ubuntu-9.10-desktop-i386.iso
http://www.ubuntu.com/GetUbuntu/download
maybe 64bit works too?

3) a USB or a HD partition(can be same as installed) to boot your test
iso from, or use Qemu to run the new iso.

Heres the script so far; I have verified it works and I even installed the finished product to a partition and everything was cool:)

I will break down the script in the nest post:)
Code:

#---------------------------------------------------------------
#!/bin/bash
# Title: Ubuntu-9.10 Update&&Upgrade
# Purpose: Upgrade, Remove, and install Packages to Ubuntu-9.10
# iso and recreate customized, installable iso


iso="ubuntu-9.10-desktop-i386"

if [ "$UID" -ne "0" ]
then
echo "This script will only work when run by "root"."
exit 1
fi

# not everyone will have squash tools, install them if not found
if [ ! `which unsquashfs` ]
then
aptitude install squashfs-tools
fi

# not everyone will have genisoimage, install it if not found
if [ ! `which mkisofs` ]
then
aptitude install genisoimage
fi

START=$(date +%s)

mkdir iso
mount $iso.iso iso/ -o loop

cp -R iso/ image/

echo "Decompressing SquashFS..."
cp iso/casper/filesystem.squashfs ./
unsquashfs filesystem.squashfs

echo "Setting up Live CD chroot..."
cp /etc/resolv.conf squashfs-root/etc/resolv.conf
cp /etc/hosts squashfs-root/etc/
cp -a /etc/apt/* squashfs-root/etc/apt/

chroot squashfs-root/ mount -t proc none /proc
chroot squashfs-root/ mount -t sysfs none /sys
chroot squashfs-root/ mount -t devpts none /dev/pts

export HOME=/root
export LC_ALL=C

echo "Refreshing Aptitude"
chroot squashfs-root/ aptitude update
chroot squashfs-root/ apt-get autoremove

echo "...Upgrading Packages"
chroot squashfs-root/ aptitude -f safe-upgrade

sleep 3

echo "Removing Unwanted Packages"
sleep 1
chroot squashfs-root/ aptitude purge evolution evolution-common evolution-couchdb evolution-documentation-en evolution-exchange evolution-indicator evolution-plugins evolution-webcal gnome-games gnome-games-common openoffice.org-base-core openoffice.org-core bogofilter-common bogofilter bogofilter-bdb hplip hplip-data pidgin pidgin-data sane-utils speech-dispatcher thunderbird xsane xsane-common gnome-pilot gnome-pilot-conduits gnome-accessibility-themes glchess glines gnect gnibbles gnobots2 gnome-blackjack gnome-mahjongg gnome-sudoku gnomine gnotravex gtali iagno language-support-writing-en openoffice.org-calc openoffice.org-draw openoffice.org-emailmerge openoffice.org-hyphenation-en-us openoffice.org-impress openoffice.org-math openoffice.org-thesaurus-en-us openoffice.org-thesaurus-en-au openoffice.org-writer language-pack-bn language-pack-bn-base language-pack-de language-pack-de-base language-pack-es language-pack-es-base language-pack-fr language-pack-fr-base language-pack-pt language-pack-pt-base language-pack-xh language-pack-xh-base same-gnome wbritish linux-image-2.6.31-14-generic aislerot language-pack-gnome-bn language-pack-gnome-bn-base language-pack-gnome-de language-pack-gnome-de-base language-pack-gnome-es language-pack-gnome-es-base language-pack-gnome-fr language-pack-gnome-fr-base language-pack-gnome-pt language-pack-gnome-pt-base language-pack-gnome-xh language-pack-gnome-xh-base

echo "Installing Packages you want"
sleep 3
chroot squashfs-root/ aptitude install normalize-audio abiword abiword-plugins flashplugin-nonfree flashplugin-nonfree-extrasound opera chromium-browser unetbootin isomaster qemu-launcher xnest grub-rescue-pc alsamixergui ubuntu-restricted-extras osmo notecase

chroot squashfs-root/ apt-get check
chroot squashfs-root/ apt-get autoremove
chroot squashfs-root/ apt-get clean
chroot squashfs-root/ aptitude clean
chroot squashfs-root/ aptitude autoclean

echo "Creating filesystem.manifest and filesystem.manifest-desktop"
echo "...Copying installed packages text to image/"
sleep 3
chroot squashfs-root/ dpkg-query -W --showformat='${Package} ${Version}\n' > image/casper/filesystem.manifest
cp image/casper/filesystem.manifest image/casper/filesystem.manifest-desktop

# prevent the installer from changing the apt sources.list

if [ ! -f "/usr/share/ubiquity/apt-setup.saved" ]; then
cp /usr/share/ubiquity/apt-setup squashfs-root/usr/share/ubiquity/apt-setup.saved
fi

sleep 3

#cleanup chroot
echo "Cleaning up chroot..."
chroot squashfs-root/ rm -rf /tmp/*
chroot squashfs-root/ rm /etc/resolv.conf
chroot squashfs-root/ umount -l -f /proc
chroot squashfs-root/ umount -l -f /sys
chroot squashfs-root/ umount /dev/pts
chroot squashfs-root/ umount /dev/

echo "Copying your kernel and initrd for the livecd"
cp squashfs-root/boot/vmlinuz-`uname -r` image/casper/vmlinuz
cp squashfs-root/boot/initrd.img-`uname -r` image/casper/initrd.lz

echo "Removing old SquashFS filesystem..."
rm image/casper/filesystem.squashfs

echo "Creating new SquashFS filesystem..."
mksquashfs squashfs-root image/casper/filesystem.squashfs

echo "Finding and creating MD5 hash sums of files in image..."
cd image
find . -type f -print0 | xargs -0 md5sum > md5sum.txt

sleep 3

cd ..
echo "Creating new image..."
mkisofs -r -V "ubuntu-9.10-desktop-i386" -cache-inodes -J -l \
-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \
-boot-load-size 4 -boot-info-table -o ubuntu-9.10-desktop-i386-new.iso image/

# Make sure that mkisofs succeeded before we try moving or renaming
# any images.
if [ $? != "0" ]
then
echo "mkisofs failed with error code: $?"
exit
fi

#echo "Renaming new image, and moving original image to old..."
#mv $iso.iso $iso_old.iso
#mv $iso_new.iso $iso.iso

#cleanup working directory

echo "Cleaning up working directory..."
umount iso/

#rm -rf squashfs-root
#rm -rf image
rm -rf iso
rm filesystem.squashfs

echo "Getting MD5 and SHA1 sum of image..."
echo "MD5: " > umr-livecd.sums
md5sum mynew.iso >> umr-livecd.sums
echo "SHA1: " >> umr-livecd.sums
sha1sum mynew.iso >> umr-livecd.sums

END=$(date +%s)

echo "Done at `date`. The whole process took $(($END - $START)) seconds!"
#------------------------------------------------


linus72 12-12-2009 08:27 AM

OK
so, now explaining about the script
first, this script will install chromium-browser, opera, flash, and more if left unedited:)
adjust remove/install pkgs!

these things must be in a folder(any name) on your Desktop or somewhere on a partition

1) the ubuntu-9.10-desktop-i386.iso

2) the script(named whatever)

heres my working folder on my root desktop

http://multidistro.com/scripts/File%20Browser.png

thats the script running now
http://multidistro.com/scripts/1st.png

so, now I'll start breaking down the script:

Code:

#!/bin/bash

iso="ubuntu-9.10-desktop-i386"

if [ "$UID" -ne "0" ]
then
echo "This script will only work when run by "root"."
exit 1
fi

# not everyone will have squash tools, install them if not found
if [ ! `which unsquashfs` ]
then
aptitude install squashfs-tools
fi

# not everyone will have genisoimage, install it if not found
if [ ! `which mkisofs` ]
then
aptitude install genisoimage
fi

START=$(date +%s)

mkdir iso
mount $iso.iso iso/ -o loop

cp -R iso/ image/

echo "Decompressing SquashFS..."
cp iso/casper/filesystem.squashfs ./
unsquashfs filesystem.squashfs

so, in the above it will mount the iso, install genisoimage & squashfs-tools if you dont have thm...
and then unsquashfs the original compressed fs

here it sets up the chroot and updates apt
BIG NOTE!
you must have your /etc/apt/sources.list fully setup
a good place to start is here
http://repogen.simplylinux.ch/

NOTE: heres my /etc/apt/sources.list for this script
http://multidistro.com/scripts/myapt

Code:

echo "Setting up Live CD chroot..."
cp /etc/resolv.conf squashfs-root/etc/resolv.conf
cp /etc/hosts squashfs-root/etc/
cp -a /etc/apt/* squashfs-root/etc/apt/

chroot squashfs-root/ mount -t proc none /proc
chroot squashfs-root/ mount -t sysfs none /sys
chroot squashfs-root/ mount -t devpts none /dev/pts

export HOME=/root
export LC_ALL=C

echo "Refreshing Aptitude"
chroot squashfs-root/ aptitude update
chroot squashfs-root/ apt-get autoremove

echo "...Upgrading Packages"
chroot squashfs-root/ aptitude -f safe-upgrade

then it removes and installs additional pkgs

Code:

echo "Removing Unwanted Packages"
sleep 1
chroot squashfs-root/ aptitude purge $%&*&^*

Code:

echo "Installing Packages you want"
sleep 3
chroot squashfs-root/ aptitude install

after that it basically recreates the original ubuntu iso, with all your changes, and names it
ubuntu-9.10-desktop-i386-new.iso

so, thats where I'm at right now....
EDIT: I'm making the 3rd test iso now, will put it on usb and install
will report in next post during install and show pics:)

linus72 12-12-2009 09:14 AM

OK
installing my newly made ubuntu 9.10 to a 5gb partition...
pic
http://multidistro.com/scripts/install.png

and hers the menu with the new stuff
http://multidistro.com/scripts/install2.png

so, I'll report back and see whats what...

linus72 12-12-2009 09:38 AM

OK
well, it didn't use my /etc/apt/sources.list
it replaced my sources.list and renamed it sources.list.save?

and it left ubiquity installer still installed
wonder why?

Other than that though everything went Koscher:)

its 2.1 GB installed with those apps above
and it makes a 670MB iso vs ubuntu-9.10 reg 690MB iso

if you just upgraded, removed all that in script
and just added flash, opera or chromium it would be evn smaller:)

linus72 12-13-2009 06:19 AM

Aha!

so, my evil plans for Ubuntu are succeeding!

I am currently messing with like 5 scripts i made for re-inventing ubuntu's

Theres this one for upgrading/adding apps to reg ubuntu iso^

and I have a good one for using the small ubuntu-mini-remix
http://www.crealabs.it/ubuntu-mini-remix/
where I addded fluxbox and lite apps and its like 350MB with all the goodies

and this one I used ubuntu-rescue-remix
http://ubuntu-rescue-remix.org/
and am now adding all the rescue tools and LXDE desktop and at 400MB!

so, gonna want to put these scripts/tutorials somewhere as my site is not permenent:(

the trooper 12-13-2009 06:23 AM

Quote:

so, gonna want to put these scripts/tutorials somewhere as my site is not permenent
Why is that?.


All times are GMT -5. The time now is 05:10 PM.