summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlocalcowbuilder-fork157
-rwxr-xr-xlocalqemubuilder-create192
2 files changed, 349 insertions, 0 deletions
diff --git a/localcowbuilder-fork b/localcowbuilder-fork
new file mode 100755
index 0000000..d513548
--- /dev/null
+++ b/localcowbuilder-fork
@@ -0,0 +1,157 @@
+#!/bin/sh
+set -x
+#
+# Copyright © 2006-2008 Jonas Smedegaard <dr@jones.dk>
+# Description: Update Copy-On-Write environment
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+#
+# Depends: cowdancer, sudo
+
+set -e
+
+PRG=$(basename "$0")
+LOCALMIRROR="deb http://127.0.0.1:9999/jones @@DIST@@ @@TOPIC@@"
+
+showhelp() {
+ cat <<EOF
+Usage: $PRG OLDPOOL POOL DISTRIBUTION [ OTHERMIRROR | LOCALTOPIC ]
+
+Examples:
+ $PRG sid sid-copy sid
+ $PRG sid sid+mm sid 'deb http://debian-multimedia.org/ sid main'
+ $PRG sid-ia32 sid-ia32+tweaks sid tweaks
+
+OTHERMIRROR is a full APT line, LOCALTOPIC is expanded using the
+following skeleton:
+
+ $LOCALMIRROR
+
+All APT sources are replaced: all original sources must be redeclared.
+EOF
+}
+
+exit1() {
+ echo "ERROR: $1"
+ exit 1
+}
+
+ask() {
+ echo -n "$1 (y/N)? "
+ read response
+ case "$response" in
+ y|Y)
+ :
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+ return
+}
+
+if [ $# -lt 3 ]; then
+ showhelp
+ exit1 "not enough parameters"
+fi
+
+oldpool=
+pool=
+distro=
+while [ $# -gt 0 ]; do
+ case $1 in
+ -h|--help)
+ showhelp
+ exit 0
+ ;;
+ --)
+ shift
+ break
+ ;;
+ --*|-*)
+# opts="$opts $1"
+# shift
+ exit1 "options are curently unsupported"
+ ;;
+ *)
+ if [ -z "$oldpool" ]; then
+ oldpool="$1"
+ elif [ -z "$pool" ]; then
+ pool="$1"
+ elif [ -z "$distro" ]; then
+ distro="$1"
+ else
+ if echo "$1" | egrep -vq '[^[:blank:]][[:blank:]]+[^[:blank:]]'; then
+ mirror="$(echo "$LOCALMIRROR" | sed "s/@@DIST@@/$distro/g;s/@@TOPIC@@/$1/g")"
+ else
+ mirror="$1"
+ fi
+ othermirrors="${othermirrors:+$othermirrors|}""$mirror"
+ fi
+ shift
+ ;;
+ esac
+done
+
+if [ -z "$oldpool" ]; then
+ exit1 "no oldpool provided"
+fi
+
+if [ -z "$pool" ]; then
+ exit1 "no pool provided"
+fi
+
+if [ -z "$distro" ]; then
+ exit1 "no distribution provided"
+fi
+
+oldbasepath="/var/cache/pbuilder/cow-$oldpool"
+basepath="/var/cache/pbuilder/cow-$pool"
+aptcache=""
+buildresult="$HOME/src/pbuild-$pool/"
+
+[ -d "$oldbasepath" ] || \
+ exit1 "oldpool \"$oldbasepath\" does not exist"
+
+makepaths=''
+for path in "$buildresult"; do
+ if [ ! -d "$path" ]; then
+ echo "W: Needed path \"$path\" does not exist"
+ makepaths='yes'
+ fi
+done
+if [ "$makepaths" = 'yes' ]; then
+ [ "$force" = 'yes' ] \
+ || ask 'Create the missing path(s)' \
+ || exit1 "Cannot continue without those missing paths"
+fi
+
+if [ -d "$basepath" ]; then
+ echo "W: Needed path \"$path\" already exists"
+ [ "$force" = 'yes' ] \
+ || ask 'Remove the path' \
+ || exit1 "Cannot continue with that path already there"
+fi
+
+mkdir -p "$buildresult"
+sudo rm -rf "$basepath"
+sudo cp -al "$oldbasepath" "$basepath"
+
+export DEBIAN_FRONTEND="noninteractive"
+export LANG=C
+
+echo "$othermirrors" | perl -e "while (<>) {chomp; /\w/ and unshift @m, '--othermirror', \$_};"\
+"exec 'sudo', 'cowbuilder', '--update', '--distribution', '$distro', '--basepath', '$basepath', '--aptcache', '$aptcache', '--override-config', @m"
diff --git a/localqemubuilder-create b/localqemubuilder-create
new file mode 100755
index 0000000..4ed389b
--- /dev/null
+++ b/localqemubuilder-create
@@ -0,0 +1,192 @@
+#!/bin/sh
+#
+# Copyright © 2006-2009 Jonas Smedegaard <dr@jones.dk>
+# Description: Create QEMU environment
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+#
+# Depends: qemu, sudo
+
+set -e
+
+PRG=$(basename "$0")
+
+showhelp() {
+ cat <<EOF
+Usage: $PRG POOL [ DISTRIBUTION [ OTHERMIRROR] ]
+
+Examples:
+ $PRG sid
+ $PRG sid+mm sid 'deb http://debian-multimedia.org/ sid main'
+ $PRG sid-ia32 sid --arch i386
+EOF
+}
+
+exit1() {
+ echo "ERROR: $1"
+ exit 1
+}
+
+ask() {
+ echo -n "$1 (y/N)? "
+ read response
+ case "$response" in
+ y|Y)
+ :
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+ return
+}
+
+if [ $# -eq 0 ]; then
+ showhelp
+ exit1 "not enough parameters"
+fi
+
+pool=
+distro=
+arch=
+newline='
+'
+while [ $# -gt 0 ]; do
+ case $1 in
+ -h|--help)
+ showhelp
+ exit 0
+ ;;
+ --arch|-a)
+ arch="$2"
+ shift 2 || exit1 "option \"--arg\" requires an argument"
+ ;;
+ --)
+ shift
+ break
+ ;;
+ --*|-*)
+# opts="$opts $1"
+# shift
+ exit1 "options (apart from --arch) are curently unsupported"
+ ;;
+ *)
+ if [ -z "$pool" ]; then
+ pool="$1"
+ elif [ -z "$distro" ]; then
+ distro="$1"
+ else
+ othermirrors="${othermirrors:+$othermirrors$newline}$1"
+ fi
+ shift
+ ;;
+ esac
+done
+
+if [ -z "$pool" ]; then
+ exit1 "no pool provided"
+fi
+if [ -z "$distro" ]; then
+ distro="$pool"
+fi
+
+case $arch in
+ armel)
+# kernelurl="http://yoush.homelinux.org:8079/nikita/armel-qemubuilder/vmlinuz-2.6.26-versatile-qemu"
+# kernelref="http://yoush.homelinux.org:8079/tech/setting-up-armel-qemubuilder"
+ kernelurl="http://people.debian.org/~aurel32/qemu/armel/vmlinuz-2.6.26-1-versatile"
+ initrdurl="http://people.debian.org/~aurel32/qemu/armel/initrd.img-2.6.26-1-versatile"
+ kernelref="http://people.debian.org/~aurel32/qemu/armel/"
+ ;;
+ mipsel)
+ kernelurl="http://people.debian.org/~aurel32/qemu/mipsel/vmlinux-2.6.26-1-4kc-malta"
+ kernelref="http://people.debian.org/~aurel32/qemu/mipsel/"
+ ;;
+ *)
+ exit1 "unsupported architecture: \"$arch\""
+ ;;
+esac
+
+basepath="/var/cache/pbuilder/base-$pool.qemu"
+aptcache=""
+buildresult="$HOME/src/pbuild-$pool/"
+qemudir="/var/cache/pbuilder/qemu-$pool/"
+
+makepaths=''
+for path in "$buildresult" "$qemudir"; do
+ if [ ! -d "$path" ]; then
+ echo "W: Needed path \"$path\" does not exist"
+ makepaths='yes'
+ fi
+done
+if [ "$makepaths" = 'yes' ]; then
+ [ "$force" = 'yes' ] \
+ || ask 'Create the missing path(s)' \
+ || exit1 "Cannot continue without those missing paths"
+ mkdir -p "$buildresult"
+ sudo mkdir -p "$qemudir"
+fi
+
+if [ -f "$basepath" ]; then
+ echo "W: Needed path \"$basepath\" already exists"
+ [ "$force" = 'yes' ] \
+ || ask 'Remove the path' \
+ || exit1 "Cannot continue with that path already there"
+ sudo rm "$basepath"
+fi
+
+for url in $kernelurl $initrdurl; do
+ file="$qemudir/$(basename $url)"
+ if [ -f "$file" ]; then
+ echo "W: file \"$file\" already exists"
+ if [ "$force" = 'yes' ] || ask 'Replace old file'; then
+ sudo rm "$file"
+ fi
+ fi
+done
+for url in $kernelurl $initrdurl; do
+ file="$qemudir/$(basename $url)"
+ if ! [ -f "$qemudir/$kernel" ]; then
+ sudo wget -O "$file" "$kernelurl"
+ fi
+done
+
+if [ -f "$qemudir/cfg" ]; then
+ echo "W: Configfile \"$qemydir/cfg\" already exists"
+ if [ "$force" = 'yes' ] || ask 'Overwrite old config'; then
+ sudo rm "$qemudir/cfg"
+ fi
+fi
+
+if ! [ -f "$qemudir/cfg" ]; then
+ sudo sh -c "cat >\"$qemudir/cfg\"" <<EOF
+# kernel origin: $kernelurl
+# more info: $kernelref
+ARCH=$arch
+MEMORY_MEGS=256
+${kernelurl:+KERNEL_IMAGE=$qemudir/$(basename $kernelurl)}
+${initrdurl:+INITRD=$qemudir/$(basename $initrdurl)}
+MIRRORSITE=http://auryn:9999/debian
+#ARCH_DISKDEVICE=sd
+EOF
+fi
+
+if [ -n "$othermirrors" ]; then
+echo "$othermirrors" | perl -e "while (<>) {/\w/ and unshift @m, '--othermirror', \$_};"\
+"exec 'sudo', 'qemubuilder', '--create', '--buildresult', '$buildresult', '--distribution', '$distro', '--basepath', '$basepath', '--aptcache', '$aptcache', '--configfile', '$qemudir/cfg', @m"
+else
+perl -e "exec 'sudo', 'qemubuilder', '--create', '--buildresult', '$buildresult', '--distribution', '$distro', '--basepath', '$basepath', '--aptcache', '$aptcache', '--configfile', '$qemudir/cfg'"
+fi