]> git.donarmstrong.com Git - dsa-puppet.git/commitdiff
auto-create and update porter chroots
authorPeter Palfrader <peter@palfrader.org>
Thu, 20 Jun 2013 11:17:37 +0000 (13:17 +0200)
committerPeter Palfrader <peter@palfrader.org>
Thu, 20 Jun 2013 11:17:37 +0000 (13:17 +0200)
modules/porterbox/files/setup-all-dchroots [new file with mode: 0755]
modules/porterbox/files/setup-dchroot
modules/porterbox/manifests/init.pp

diff --git a/modules/porterbox/files/setup-all-dchroots b/modules/porterbox/files/setup-all-dchroots
new file mode 100755 (executable)
index 0000000..93d9c8b
--- /dev/null
@@ -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
index 78405ff2cb722ad200e2cc07e2bdea0d3c59a7b2..40ca8fe329f9f154333b5320ac55ffd5eed8b9c1 100755 (executable)
@@ -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
index 4d4d3a90d32a28a07e7471f81d91048533a0b1c6..6362158b2cb5d0c8bf43b2ff76ad7fe6c99be54e 100644 (file)
@@ -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',
+       }
 }