Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 132 lines (102 sloc) 3.79 KB
#!/bin/bash -e
# depends: https://github.com/livenson/pfff.git
# Copyright (c) 2011-2015 TurnKey GNU/Linux - http://www.turnkeylinux.org
#
# This file is part of buildtasks.
#
# Buildtasks is free software; you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
fatal() { echo "FATAL [$(basename $0)]: $@" 1>&2; exit 1; }
warning() { echo "WARNING [$(basename $0)]: $@"; }
info() { echo "INFO [$(basename $0)]: $@"; }
usage() {
cat<<EOF
Syntax: $(basename $0) [--publish] appname-version
Converts appliance appname-version to container template
Arguments::
appname-version - e.g., core-14.2-jessie-amd64
Options::
--publish - if set, image and meta files will be published
Environment::
BT_DEBUG - turn on debugging
EOF
exit 1
}
while [ "$1" != "" ]; do
case $1 in
--help|-h ) usage;;
--publish) publish="yes";;
*) if [ -n "$appver" ]; then usage; else appver=$1; fi ;;
esac
shift
done
[ -n "$appver" ] || usage
[ -n "$BT_DEBUG" ] && set -x
export BT=$(dirname $(readlink -f $0))
export BT_CONFIG=$BT/config
. $BT_CONFIG/common.cfg
if [ "$publish" == "yes" ]; then
[ -n "$BT_PUBLISH_IMGS" ] || fatal "BT_PUBLISH_IMGS not set"
[ -n "$BT_PUBLISH_META" ] || fatal "BT_PUBLISH_META not set"
else
warning "--publish was not specified"
fi
parsed_appname_version=$($BT/bin/parse-appname-version $appver)
read appname appversion codename arch <<< "$parsed_appname_version"
export BT_VERSION=${appversion}-${codename}-${arch}
os_arch=$(dpkg --print-architecture)
[ "$arch" == "$os_arch" ] || fatal "os_arch mismatch: $arch != $os_arch"
case "$appname" in
canvas) export ON_MEMORY=0.50 ;;
gitlab) export ON_MEMORY=0.50 ;;
jenkins) export ON_MEMORY=0.50 ;;
clipbucket) export ON_MEMORY=0.50 ;;
tkldev) export ON_MEMORY=0.50 ;;
moodle) export ON_MEMORY=0.33 ;;
tomcat-apache) export ON_MEMORY=0.33 ;;
appengine-java) export ON_MEMORY=0.33 ;;
*) export ON_MEMORY=0.25 ;;
esac
case "$codename" in
squeeze) debianversion="debian-6" ;;
wheezy) debianversion="debian-7" ;;
jessie) debianversion="debian-8" ;;
stretch) debianversion="debian-9" ;;
buster) debianversion="debian-10" ;;
*) fatal "debianversion could not be determined" ;;
esac
O=$BT_BUILDS/container
mkdir -p $O
isofile=turnkey-${appname}-${BT_VERSION}.iso
name=turnkey-${appname}-${BT_VERSION}
rootfs=$name.rootfs
cdroot=$name.cdroot
$BT/bin/iso-download $BT_ISOS $BT_VERSION $appname
$BT/bin/iso-verify $BT_ISOS $BT_VERSION $appname
cd $O
tklpatch-extract-iso $BT_ISOS/$isofile
tklpatch-apply $rootfs $BT/patches/headless
tklpatch-apply $rootfs $BT/patches/container
$BT/bin/rootfs-cleanup $rootfs
$BT/bin/aptconf-tag $rootfs proxmox
$BT/bin/build-tag $rootfs proxmox
# bundle proxmox tarball using stupid naming convention
stupidname="${debianversion}-turnkey-${appname}_${appversion}-1_${arch}"
info "creating Proxmox container build ($stupidname.tar.gz)"
tar -C $rootfs -zcf $stupidname.tar.gz .
$BT/bin/generate-signature $O/$stupidname.tar.gz
$BT/bin/generate-buildenv container $BT_ISOS/$isofile.hash > $O/$stupidname.tar.gz.buildenv
# publish if specified
if [ "$publish" == "yes" ]; then
export PUBLISH_DEST=${BT_PUBLISH_IMGS}/proxmox/
$BT/bin/publish-files $O/$stupidname.tar.gz
export PUBLISH_DEST=${BT_PUBLISH_META}/
$BT/bin/publish-files $O/$stupidname.{tar.gz.hash,tar.gz.buildenv}
fi
if [ -z "$BT_DEBUG" ] && ! (mount | grep -q $(basename $rootfs)); then
rm -rf $rootfs
rm -rf $cdroot
[ "$publish" != "yes" ] || $BT/bin/clean container $appver
fi
You can’t perform that action at this time.