From: Peter Palfrader Date: Thu, 20 Jun 2013 11:17:37 +0000 (+0200) Subject: auto-create and update porter chroots X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=6c1ddb4d3292d02659f13442e82a89a63ab006ae;p=mirror%2Fdsa-puppet.git auto-create and update porter chroots --- diff --git a/modules/porterbox/files/setup-all-dchroots b/modules/porterbox/files/setup-all-dchroots new file mode 100755 index 000000000..93d9c8b25 --- /dev/null +++ b/modules/porterbox/files/setup-all-dchroots @@ -0,0 +1,66 @@ +#!/bin/bash + +## +## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE. +## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git +## + +# Copyright (c) 2013 Peter Palfrader +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, +# copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following +# conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +DPKGARCH=$(dpkg --print-architecture) +UNAMEARCH=$(uname -m) + +get_suites() { + case "$1" in + armel|s390x) + echo "sid jessie wheezy" + ;; + *) + echo "sid jessie wheezy squeeze" + ;; + esac +} + +archs="$DPKGARCH" +case "$DPKGARCH" in + amd64) + archs="$archs i386" + ;; + armhf) + archs="$archs armel" + ;; + s390|s390x) + archs="s390 s390x" + ;; +esac + +err=0 + +for a in $archs; do + for s in `get_suites "$a"`; do + setup-dchroot -f -a "$a" "$s" || err=1 + done +done + +exit $err diff --git a/modules/porterbox/files/setup-dchroot b/modules/porterbox/files/setup-dchroot index 78405ff2c..40ca8fe32 100755 --- a/modules/porterbox/files/setup-dchroot +++ b/modules/porterbox/files/setup-dchroot @@ -123,6 +123,16 @@ EOF esac } +do_config() { + local tmpschrootconf=$(tempfile) + cleanup+=("rm -f $tmpschrootconf") + genschrootconf "$suite" "$arch" "$target" > "$tmpschrootconf" + if ! [ -e "$schrootconfig" ] || ! diff "$schrootconfig" "$tmpschrootconf" > /dev/null; then + mv "$tmpschrootconf" "$schrootconfig" + chmod 644 "$schrootconfig" + fi +} + set -e set -u @@ -217,9 +227,11 @@ schrootconfig="/etc/schroot/chroot.d/${tuple}-dchroot" # # let's go # -genschrootconf "$suite" "$arch" "$target" | tee "$schrootconfig" -if [ -n "$configonly" ]; then exit 0; fi +if [ -n "$configonly" ]; then + do_config + exit 0 +fi rootdir=$(mktemp -d "$builddir/create-$suite-XXXXXX") cleanup+=("rm -r $rootdir") @@ -263,3 +275,5 @@ umount "$rootdir/sys" || true tartmp=$(tempfile --directory "$basedir" --suffix=".tar.gz") cleanup+=("rm -f $tartmp") (cd "$rootdir" && tar caf "$tartmp" . && mv "$tartmp" "$target") + +do_config diff --git a/modules/porterbox/manifests/init.pp b/modules/porterbox/manifests/init.pp index 4d4d3a90d..6362158b2 100644 --- a/modules/porterbox/manifests/init.pp +++ b/modules/porterbox/manifests/init.pp @@ -33,4 +33,11 @@ class porterbox { mode => 555, source => 'puppet:///modules/porterbox/setup-dchroot', } + file { '/usr/local/sbin/setup-all-dchroots': + mode => 555, + source => 'puppet:///modules/porterbox/setup-all-dchroots', + } + file { '/etc/cron.d/puppet-update-dchroots': + content => '0 3 * * 0 root PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin chronic setup-all-dchroots', + } }