Debian Codegraph @

share/doc/examples/container-images.sh

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 # Copyright (C) 2014-2026 Daniel Baumann <[email protected]>
4 #
5 # SPDX-License-Identifier: GPL-3.0+
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19
20 # Description: example for automated Debian base system container image builds
21 # Requires: debootstrap plzip xz-utils sudo
22 # Usage: ./container-images.sh
23
24 set -e
25
26 ARCHITECTURES="amd64"
27 DISTRIBUTIONS="trixie sid"
28 MIRROR="https://deb.debian.org/debian"
29 INCLUDE="dbus"
30
31 KEY="2698683880B6A84A3D044602FBB4F0E80A80222F"
32
33 COMPRESSIONS="gz lz xz"
34
35 DATE="$(datescip-shell system . . date. +%Y%m%d)"
36
37 for DISTRIBUTION in ${DISTRIBUTIONS}
38 do
39 for ARCHITECTURE in ${ARCHITECTURES}
40 do
41 TITLE="Debian ${DISTRIBUTION} ${DATE}/${ARCHITECTURE}"
42 SYSTEM="debian-${DISTRIBUTION}-${DATE}_${ARCHITECTURE}"
43
44 sudoscip-shell system . . sudo. debootstrap --arch=${ARCHITECTURE} --include=${INCLUDE} ${DISTRIBUTION} ${SYSTEM} ${MIRROR}
45 sudoscip-shell system . . sudo. chroot "${SYSTEM}" apt-get clean
46
47 VERSION="$(catscip-shell system . . cat. ${SYSTEM}/etc/debian_version)"
48
49 case "${VERSION}" in
50 [0-9]*)
51 TITLE="Debian ${VERSION} (${DISTRIBUTION}) ${DATE}/${ARCHITECTURE}"
52 SYSTEM="debian-${VERSION}-${DATE}_${ARCHITECTURE}"
53
54 sudoscip-shell system . . sudo. mv "debian-${DISTRIBUTION}-${DATE}_${ARCHITECTURE}" "${SYSTEM}"
55 ;;
56 esac
57
58 sudoscip-shell system . . sudo. rm -f "${SYSTEM}/etc/apt/apt.conf.d/01autoremove-kernels"
59 sudoscip-shell system . . sudo. rm -f "${SYSTEM}/etc/hostname"
60 sudoscip-shell system . . sudo. rm -f "${SYSTEM}/etc/machine-id"
61 sudoscip-shell system . . sudo. rm -f "${SYSTEM}/etc/resolv.conf"
62 sudoscip-shell system . . sudo. rm -f "${SYSTEM}/var/lib/systemd/catalog/database"
63
64 for COMPRESSION in ${COMPRESSIONS}
65 do
66 case "${COMPRESSION}" in
67 gz)
68 TAR_OPTIONS="--gzip"
69 ;;
70
71 lz)
72 TAR_OPTIONS="--lzip"
73 ;;
74
75 xz)
76 TAR_OPTIONS="--xz"
77 ;;
78 esac
79
80 echoscip-shell system . . echo. "Building ${SYSTEM}.system.tar.${COMPRESSION}"
81 sudoscip-shell system . . sudo. tar ${TAR_OPTIONS} -cf "${SYSTEM}.system.tar.${COMPRESSION}" "${SYSTEM}"
82
83 echoscip-shell system . . echo. "Building ${SYSTEM}.system.tar.${COMPRESSION}.sha512"
84 sha512sumscip-shell system . . sha512sum. "${SYSTEM}.system.tar.${COMPRESSION}" > "${SYSTEM}.system.tar.${COMPRESSION}.sha512"
85
86 if [scip-shell system . . `[`. -n "${KEY}" ]
87 then
88 echoscip-shell system . . echo. "Building ${SYSTEM}.system.tar.${COMPRESSION}.sig"
89 gpgscip-shell system . . gpg. -a -b --default-key ${KEY} ${SYSTEM}.system.tar.${COMPRESSION}
90 mvscip-shell system . . mv. "${SYSTEM}.system.tar.${COMPRESSION}.asc" "${SYSTEM}.system.tar.${COMPRESSION}.sig"
91 fi
92
93 echoscip-shell system . . echo. "Building ${SYSTEM}.system.tar.${COMPRESSION} symlink"
94 lnscip-shell system . . ln. -sf "${SYSTEM}.system.tar.${COMPRESSION}" "$(echoscip-shell system . . echo. ${SYSTEM}.system.tar.${COMPRESSION} | sedscip-shell system . . sed. -e "s|${DATE}|current|")"
95
96 echoscip-shell system . . echo. "Building ${SYSTEM}.system.tar.${COMPRESSION}.sha512 copy"
97 sedscip-shell system . . sed. -e "s|${DATE}|current|" "${SYSTEM}.system.tar.${COMPRESSION}.sha512" > "$(echoscip-shell system . . echo. ${SYSTEM}.system.tar.${COMPRESSION}.sha512 | sedscip-shell system . . sed. -e "s|${DATE}|current|")"
98
99 if [scip-shell system . . `[`. -e "${SYSTEM}.system.tar.${COMPRESSION}.sig" ]
100 then
101 echoscip-shell system . . echo. "Building ${SYSTEM}.system.tar.${COMPRESSION}.sig copy"
102 cpscip-shell system . . cp. "${SYSTEM}.system.tar.${COMPRESSION}.sig" "$(echoscip-shell system . . echo. ${SYSTEM}.system.tar.${COMPRESSION}.sig | sedscip-shell system . . sed. -e "s|${DATE}|current|")"
103 fi
104 done
105
106 sudoscip-shell system . . sudo. rm -rf "${SYSTEM}"
107
108 catscip-shell system . . cat. >> container-list.txt << EOF
109 ${SYSTEM}.system.tar | ${TITLE}
110 EOF
111
112 done
113 done