forked from Spark/builder
cleanup
This commit is contained in:
parent
0e280608cc
commit
7f34912c09
|
@ -1,4 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# Depends on lxf
|
||||||
|
|
||||||
|
cleanup() { lxf umount "$cnt"; }
|
||||||
|
|
||||||
buildscript() {
|
buildscript() {
|
||||||
cat <<- EOF
|
cat <<- EOF
|
||||||
|
@ -24,29 +27,25 @@ buildscript() {
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Config
|
||||||
wrk_dir='/home/lxc'
|
wrk_dir='/home/lxc'
|
||||||
|
|
||||||
|
# Parameters
|
||||||
pkg_url=$1
|
pkg_url=$1
|
||||||
pkg_dest=$2
|
pkg_dest=$2
|
||||||
|
|
||||||
cnt="_makepkg.$$"
|
cnt="_makepkg.$$"
|
||||||
cnt_dir="$wrk_dir/containers/$cnt"
|
cnt_dir="$wrk_dir/containers/$cnt"
|
||||||
|
|
||||||
# Unmount the thing in any case
|
|
||||||
cleanup() { lxf umount "$cnt"; }
|
|
||||||
trap 'cleanup' INT TERM EXIT
|
|
||||||
|
|
||||||
# Create new container
|
# Create new container
|
||||||
lxf -r builder -i base new "$cnt"
|
lxf -r builder -i base new "$cnt"
|
||||||
|
|
||||||
|
# Unmount the thing in any case
|
||||||
|
trap 'cleanup' INT TERM EXIT
|
||||||
|
|
||||||
# Add the build script
|
# Add the build script
|
||||||
buildscript > "$cnt_dir/rootfs/init"
|
buildscript > "$cnt_dir/rootfs/init"
|
||||||
chmod 755 "$cnt_dir/rootfs/init"
|
chmod 755 "$cnt_dir/rootfs/init"
|
||||||
|
|
||||||
# Tell it where to fetch the package
|
|
||||||
echo "$pkg_url" > "$cnt_dir/rootfs/repo"
|
|
||||||
|
|
||||||
export PKG_GIT_URL="$pkg_url"
|
|
||||||
|
|
||||||
# Start the container
|
# Start the container
|
||||||
lxc-start -n "$cnt" -F /init; lxc_exit=$?
|
lxc-start -n "$cnt" -F /init; lxc_exit=$?
|
||||||
(( lxc_exit )) && exit "$lxc_exit"
|
(( lxc_exit )) && exit "$lxc_exit"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user