lxc-opensuse.in revision da9ca6569a250f42c35292a0b5eb6731c89860e2
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# template script for generating OpenSUSE container for LXC
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# lxc: linux Container library
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# Daniel Lezcano <daniel.lezcano@free.fr>
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# Frederic Crozat <fcrozat@suse.com>
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# Michael H. Warfield <mhw@WittsEnd.com>
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# Johannes Kastl <mail@ojkastl.de>
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# This library is free software; you can redistribute it and/or
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# modify it under the terms of the GNU Lesser General Public
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# License as published by the Free Software Foundation; either
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# version 2.1 of the License, or (at your option) any later version.
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# This library is distributed in the hope that it will be useful,
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# but WITHOUT ANY WARRANTY; without even the implied warranty of
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# Lesser General Public License for more details.
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# You should have received a copy of the GNU Lesser General Public
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# License along with this library; if not, write to the Free Software
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# Detect use under userns (unsupported)
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo if [ "$arg" = "--mapped-uid" -o "$arg" = "--mapped-gid" ]; then
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo echo "This template can't be used for unprivileged containers." 1>&2
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo echo "You may want to try the \"download\" template instead." 1>&2
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo# Make sure the usual locations are in PATH
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo # set first network adapter as dhcp. This is the most common config.
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae Yoo cat <<EOF > $rootfs/etc/sysconfig/network/ifcfg-eth0
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae YooSTARTMODE='auto'
2b371b262f7272266ff18cc2aff65176a2c16383Sungbae YooBOOTPROTO='dhcp'
sed -e 's/ConditionPathExists=.*//' /usr/lib/systemd/system/getty@.service > $rootfs/etc/systemd/system/getty@.service
ln -s -f ../getty@.service $rootfs/etc/systemd/system/getty.target.wants/getty@tty1.service
# see https://wiki.archlinux.org/index.php/Linux_Containers#Container_cannot_be_shutdown_if_using_systemd
cache=$1
arch=$2
if [ ! -x ${BUILD} ]; then
if [ $? -ne 0 ]; then
zypper --quiet --root $cache/partial-$arch-packages --non-interactive ar http://download.opensuse.org/distribution/$DISTRO/repo/oss/ repo-oss || return 1
zypper --quiet --root $cache/partial-$arch-packages --non-interactive ar http://download.opensuse.org/update/$DISTRO/oss/ update || return 1
zypper --quiet --root $cache/partial-$arch-packages --non-interactive ar http://download.opensuse.org/update/$DISTRO/ update || return 1
zypper --quiet --root $cache/partial-$arch-packages --non-interactive --gpg-auto-import-keys update || return 1
zypper --root $cache/partial-$arch-packages --non-interactive in --auto-agree-with-licenses --download-only zypper lxc patterns-openSUSE-base bash iputils sed tar rsyslog || return 1
[ -d $cache/partial-$arch-packages/var/cache/zypp/packages/update/noarch ] || mkdir -p $cache/partial-$arch-packages/var/cache/zypp/packages/update/noarch
CLEAN_BUILD=1 BUILD_ARCH="$arch" BUILD_ROOT="$cache/partial-$arch" BUILD_DIST="$cache/partial-$arch-packages/opensuse.conf" PATH="$PATH:$BUILD_DIR" $BUILD_DIR/init_buildsystem --clean --configdir $BUILD_DIR/configs --cachedir $cache/partial-$arch-cache --repository $cache/partial-$arch-packages/var/cache/zypp/packages/repo-oss/suse/$arch --repository $cache/partial-$arch-packages/var/cache/zypp/packages/repo-oss/suse/noarch --repository $cache/partial-$arch-packages/var/cache/zypp/packages/update/$arch --repository $cache/partial-$arch-packages/var/cache/zypp/packages/update/noarch || return 1
chroot $cache/partial-$arch /usr/bin/zypper --quiet --non-interactive ar http://download.opensuse.org/distribution/$DISTRO/repo/oss repo-oss || return 1
chroot $cache/partial-$arch /usr/bin/zypper --quiet --non-interactive ar http://download.opensuse.org/update/$DISTRO/oss update || return 1
chroot $cache/partial-$arch /usr/bin/zypper --quiet --non-interactive ar http://download.opensuse.org/update/$DISTRO/ update || return 1
if [ $? -ne 0 ]; then
cache=$1
arch=$2
rootfs=$3
rootfs=$1
mkdir -p @LOCALSTATEDIR@/lock/subsys/
flock -x 9
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
path=$1
rootfs=$2
name=$3
while read LINE
done < $path/config.def
rm -f $path/config.def
lxc.include = @LXCTEMPLATECONFIG@/opensuse.common.conf
if [ $? -ne 0 ]; then
if [ ! -e $cache ]; then
flock -x 9
cat <<EOF
eval set -- "$options"
if [ -z "$path" ]; then
echo "Building openSUSE containers with your version of the build package is broken. Please install the update to version 20141120 or newer."
if [ -z "$DISTRO" ]; then
if [ -z "$rootfs" ]; then
if [ ! -z "$clean" ]; then