Commit | Line | Data |
---|---|---|
e36b4f25 MW |
1 | #! /bin/sh -e |
2 | ### | |
3 | ### Write `schroot' configuration for build chroots | |
4 | ### | |
5 | ### (c) 2018 Mark Wooding | |
6 | ### | |
7 | ||
8 | ###----- Licensing notice --------------------------------------------------- | |
9 | ### | |
10 | ### This file is part of the distorted.org.uk chroot maintenance tools. | |
11 | ### | |
12 | ### distorted-chroot is free software: you can redistribute it and/or | |
13 | ### modify it under the terms of the GNU General Public License as | |
14 | ### published by the Free Software Foundation; either version 2 of the | |
15 | ### License, or (at your option) any later version. | |
16 | ### | |
17 | ### distorted-chroot is distributed in the hope that it will be useful, | |
18 | ### but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 | ### General Public License for more details. | |
21 | ### | |
22 | ### You should have received a copy of the GNU General Public License | |
23 | ### along with distorted-chroot. If not, write to the Free Software | |
24 | ### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
25 | ### USA. | |
26 | ||
27 | . state/config.sh # @@@config@@@ | |
28 | ||
29 | ## Parse the command-line. | |
30 | badp=nil | |
31 | while getopts "" opt; do badp=t; done | |
32 | shift $(( $OPTIND - 1 )) | |
33 | case $# in 0) ;; *) badp=t ;; esac | |
34 | case $badp in t) echo >&2 "usage: $0"; exit 2 ;; esac | |
35 | ||
36 | for arg in $ALL_CHROOTS; do | |
37 | case $arg in *-*-*) echo >&2 "$0: bad chroot name \`$arg'"; exit 2 ;; esac | |
38 | done | |
39 | if [ ! -d /dev/$VG/ ]; then echo >&2 "$0: no volume group \`$VG'"; exit 2; fi | |
40 | ||
41 | ## Start producing output. | |
42 | cat <<EOF | |
43 | ### -*-conf-*- GENERATED by mkchrootconf | |
44 | EOF | |
45 | for arg in $ALL_CHROOTS; do | |
46 | ||
47 | ## Parse the chroot name into its compoments, and retrieve the distribution | |
48 | ## nickname list. | |
49 | dist=${arg%-*} arch=${arg#*-} | |
50 | eval "nick=\$nickmap_$dist" | |
51 | ||
52 | ## Start the stanza for chroot D-A. | |
53 | cat <<EOF | |
54 | ||
55 | [$LVPREFIX$arg] | |
56 | EOF | |
57 | ||
58 | ## Prepare the alias list. For each nickname N for distribution D, there's | |
59 | ## a chroot alias N-A. If A is the default architecture then there are | |
60 | ## aliases D and N for each N.. If D is the default distribution then | |
61 | ## there is an alias A. | |
62 | unset alias | |
63 | for n in $nick; do alias=${alias+$alias,}$LVPREFIX$n-$arch; done | |
64 | case $arch in | |
65 | $MYARCH) for n in $dist $nick; do alias=${alias+$alias,}$LVPREFIX$n; done ;; | |
66 | esac | |
67 | case $dist in | |
68 | $PRIMARY_DIST) alias=${alias+$alias,}$LVPREFIX$arch ;; | |
69 | esac | |
70 | case ${alias+t} in | |
71 | t) | |
72 | cat <<EOF | |
73 | aliases=$alias | |
74 | EOF | |
75 | ;; | |
76 | esac | |
77 | ||
78 | ## Architecture-specific foibles. For `i386' and `amd64', explicitly set | |
79 | ## the personality so that `config.guess' doesn't get confused by | |
80 | ## surprising utsname(2) output. | |
81 | case $arch in | |
82 | i386) | |
83 | cat <<EOF | |
84 | personality=linux32 | |
85 | EOF | |
86 | ;; | |
87 | amd64) | |
88 | cat <<EOF | |
89 | personality=linux | |
90 | EOF | |
91 | ;; | |
92 | esac | |
93 | ||
94 | ## The rest of the configuration. | |
95 | cat <<EOF | |
96 | type=lvm-snapshot | |
97 | description=Debian $dist/$arch autobuilder | |
98 | device=/dev/$VG/$LVPREFIX$dist-$arch | |
3e5b03e2 | 99 | lvm-snapshot-options=$SNAPOPT |
a98c9dba | 100 | lvm.suppress-fd-warnings=t |
e36b4f25 MW |
101 | mount-options=-onosuid,data=writeback,barrier=0,commit=3600,noatime |
102 | location=/fs | |
103 | groups=root,sbuild | |
104 | root-groups=root,sbuild | |
105 | source-groups=root | |
106 | source-root-groups=root | |
107 | profile=sbuild | |
108 | EOF | |
109 | done | |
110 | ||
111 | ###----- That's all, folks -------------------------------------------------- |