mirror of
https://git.launchpad.net/livecd-rootfs
synced 2025-06-06 23:51:35 +00:00
add livecd.py beginnings
This commit is contained in:
parent
8e6007b171
commit
91ce9d3731
24
livecd.py
Normal file
24
livecd.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import os,sys
|
||||||
|
import atexit
|
||||||
|
|
||||||
|
class Mount:
|
||||||
|
def __init__(self):
|
||||||
|
atexit.register(self.cleanup,self)
|
||||||
|
self.mounts={}
|
||||||
|
self.losetupDev=None
|
||||||
|
|
||||||
|
def addMount(self,name):
|
||||||
|
self.mounts[name]=1
|
||||||
|
|
||||||
|
def losetup(self,name):
|
||||||
|
if self.losetupDev==None:
|
||||||
|
self.losetupDev=os.popen("losetup -f").read().strip()
|
||||||
|
os.system("losetup %s %s" % (self.losetupDev,name)
|
||||||
|
|
||||||
|
def unLosetup(self):
|
||||||
|
os.system("losetup -d %s"%self.losetupDev)
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
# XXX - need to unmount stuff
|
||||||
|
pass
|
49
livecd.sh
49
livecd.sh
@ -25,33 +25,44 @@ export TTY=unknown
|
|||||||
export TERM=vt100
|
export TERM=vt100
|
||||||
case $(hostname --fqdn) in
|
case $(hostname --fqdn) in
|
||||||
*.mmjgroup.com) MIRROR=http://ia/ubuntu;;
|
*.mmjgroup.com) MIRROR=http://ia/ubuntu;;
|
||||||
*.warthogs.hbd.com) MIRROR=http://jackass.warthogs.hbd.com;;
|
*.ubuntu.com) MIRROR=http://jackass.ubuntu.com;;
|
||||||
*.ubuntu.com) MIRROR=http://jackass.warthogs.hbd.com;;
|
*.buildd) MIRROR=http://jackass.ubuntu.com;;
|
||||||
*) MIRROR=http://archive.ubuntu.com/ubuntu;;
|
*) MIRROR=http://archive.ubuntu.com/ubuntu;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
while getopts :m: name; do case $name in
|
|
||||||
m) MIRROR="$OPTARG";;
|
|
||||||
\?) echo bad usage >&2; exit 2;;
|
|
||||||
\:) echo missing argument >&2; exit 2;;
|
|
||||||
esac; done;
|
|
||||||
shift $((OPTIND-1))
|
|
||||||
|
|
||||||
(( $# == 0 )) && set -- ubuntu || true
|
|
||||||
[ "X$1" = "Xall" ] && set -- ubuntu kubuntu || true
|
|
||||||
|
|
||||||
for arg in "$@"; do case "$arg" in
|
|
||||||
ubuntu|kubuntu) ;;
|
|
||||||
*) echo bad name >&2; exit 2;;
|
|
||||||
esac; done
|
|
||||||
|
|
||||||
for FS in "$@"; do
|
|
||||||
# How much space do we leave on the filesystem for the user?
|
# How much space do we leave on the filesystem for the user?
|
||||||
USZ="400*1024" # 400MB for the user
|
USZ="400*1024" # 400MB for the user
|
||||||
# And how many inodes? Default currently gives them > 100000
|
# And how many inodes? Default currently gives them > 100000
|
||||||
UINUM="" # blank (default), or number of inodes desired.
|
UINUM="" # blank (default), or number of inodes desired.
|
||||||
STE=hoary
|
STE=hoary
|
||||||
|
|
||||||
|
if /bin/false; then # not right now
|
||||||
|
while getopts :i:ms:: name; do case $name in
|
||||||
|
s) USZ=$(sanitize int "$OPTARG");;
|
||||||
|
i) UINUM=$(sanitize int "$OPTARG");;
|
||||||
|
m) MIRROR=$(sanitize url "$OPTARG");;
|
||||||
|
\?) echo bad usage >&2; exit 2;;
|
||||||
|
\:) echo missing argument >&2; exit 2;;
|
||||||
|
esac; done;
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( $# == 0 )) || [ "X$1" = "Xall" ]; then
|
||||||
|
set -- ubuntu kubuntu
|
||||||
|
fi
|
||||||
|
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
ubuntu|kubuntu)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo bad name >&2;
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
for FS in "$@"; do
|
||||||
ROOT=$(pwd)/chroot-livecd/ # trailing / is CRITICAL
|
ROOT=$(pwd)/chroot-livecd/ # trailing / is CRITICAL
|
||||||
IMG=livecd.fsimg
|
IMG=livecd.fsimg
|
||||||
MOUNTS="${ROOT}dev/pts ${ROOT}dev/shm ${ROOT}.dev ${ROOT}dev ${ROOT}proc"
|
MOUNTS="${ROOT}dev/pts ${ROOT}dev/shm ${ROOT}.dev ${ROOT}dev ${ROOT}proc"
|
||||||
@ -88,7 +99,7 @@ for FS in "$@"; do
|
|||||||
DIVERTS="usr/sbin/mkinitrd usr/sbin/invoke-rc.d sbin/udevd"
|
DIVERTS="usr/sbin/mkinitrd usr/sbin/invoke-rc.d sbin/udevd"
|
||||||
for file in $DIVERTS; do
|
for file in $DIVERTS; do
|
||||||
mkdir -p ${ROOT}${file%/*}
|
mkdir -p ${ROOT}${file%/*}
|
||||||
sudo chroot $ROOT dpkg-divert --add --local --divert /${file}.livecd --rename /${file}
|
chroot $ROOT dpkg-divert --add --local --divert /${file}.livecd --rename /${file}
|
||||||
cp /bin/true ${ROOT}$file
|
cp /bin/true ${ROOT}$file
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user