chiark / gitweb /
More work in progress.
[distorted-chroot] / bin / mkchrootconf
CommitLineData
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.
30badp=nil
31while getopts "" opt; do badp=t; done
32shift $(( $OPTIND - 1 ))
33case $# in 0) ;; *) badp=t ;; esac
34case $badp in t) echo >&2 "usage: $0"; exit 2 ;; esac
35
36for arg in $ALL_CHROOTS; do
37 case $arg in *-*-*) echo >&2 "$0: bad chroot name \`$arg'"; exit 2 ;; esac
38done
39if [ ! -d /dev/$VG/ ]; then echo >&2 "$0: no volume group \`$VG'"; exit 2; fi
40
41## Start producing output.
42cat <<EOF
43### -*-conf-*- GENERATED by mkchrootconf
44EOF
45for 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]
56EOF
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
73aliases=$alias
74EOF
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
84personality=linux32
85EOF
86 ;;
87 amd64)
88 cat <<EOF
89personality=linux
90EOF
91 ;;
92 esac
93
94 ## The rest of the configuration.
95 cat <<EOF
96type=lvm-snapshot
97description=Debian $dist/$arch autobuilder
98device=/dev/$VG/$LVPREFIX$dist-$arch
3e5b03e2 99lvm-snapshot-options=$SNAPOPT
e36b4f25
MW
100mount-options=-onosuid,data=writeback,barrier=0,commit=3600,noatime
101location=/fs
102groups=root,sbuild
103root-groups=root,sbuild
104source-groups=root
105source-root-groups=root
106profile=sbuild
107EOF
108done
109
110###----- That's all, folks --------------------------------------------------