diff options
author | Leonardo Arena <rnalrd@alpinelinux.org> | 2011-08-16 11:26:52 +0000 |
---|---|---|
committer | Leonardo Arena <rnalrd@alpinelinux.org> | 2011-08-16 11:26:52 +0000 |
commit | 1fb30d930d4f7069c0b7b73dd9895c036e8d0f56 (patch) | |
tree | 51ddcc9e8edbc824ac3b40c0c866a6af878e655b /main/lxc/setup-lxc-template | |
parent | 6f18af728d40558a2744a05ad438686b921ea7a6 (diff) | |
download | aports-1fb30d930d4f7069c0b7b73dd9895c036e8d0f56.tar.bz2 aports-1fb30d930d4f7069c0b7b73dd9895c036e8d0f56.tar.xz |
testing/lxc: move to main
Diffstat (limited to 'main/lxc/setup-lxc-template')
-rwxr-xr-x | main/lxc/setup-lxc-template | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/main/lxc/setup-lxc-template b/main/lxc/setup-lxc-template new file mode 100755 index 000000000..f8e9fe4a3 --- /dev/null +++ b/main/lxc/setup-lxc-template @@ -0,0 +1,44 @@ +#!/bin/sh + +# create a lxc template +PROG=$0 + +usage() { + echo "usage: $PROG [-fhq] [-o OUTFILE] [-X repository] [packages...]" + exit $1 +} + +clean_exit() { + rm -rf "$tmpdir" + exit $1 +} + +outfile=template.tar.gz +fakeroot= +repos= +while getopts "ho:qX:" opt; do + case "$opt" in + h) usage 0;; + o) outfile="$OPTARG";; + q) quiet=-q;; + X) repos="$repos --repository $OPTARG";; + esac +done +shift $(( $OPTIND - 1 )) + +if [ "$(whoami)" != "root" ]; then + echo "Warning: you need root permissions" >&2 +fi + +tmpdir=$(mktemp -d ${TMPDIR:-/tmp}/setup-lxc-template-XXXXXX) + +apk add --root "$tmpdir" --initdb --keys-dir /etc/apk/keys -U \ + $quiet ${repos:---repositories-file /etc/apk/repositories} \ + alpine-base $@ \ + || clean_exit 1 + +tar -czf "$outfile" -C "$tmpdir" $(ls "$tmpdir") || clean_exit 1 + +[ -z "$quiet" ] && echo "Created $outfile" +clean_exit 0 + |