File: sbuild-qemu-create-modscript

package info (click to toggle)
sbuild 0.81.2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,756 kB
  • sloc: perl: 15,954; sh: 1,413; sql: 797; python: 401; makefile: 306; lisp: 304
file content (80 lines) | stat: -rwxr-xr-x 2,189 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright © 2020      Christian Kastner <ckk@debian.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see
# <http://www.gnu.org/licenses/>.
#
#######################################################################


set -e
umask 0022


VMROOT="$1"
if [ -z "$VMROOT" ]
then
	echo "$0 expects the mounted root of the VM as first argument." >&2
	exit 1
elif ! mountpoint -q "$VMROOT"
then
	echo "$VMROOT is not a mountpoint." >&2
	exit 1
fi


echo "### Customizing base image ###"

if [ -n "$QSC_SKEL" ]
then
	echo "Copying contents of $QSC_SKEL"
	if [ ! -d "$QSC_SKEL" ]
	then
		echo "$QSC_SKEL is not a directory." >&2
		exit 1
	fi
	cp -pr $QSC_SKEL/. $VMROOT/root
fi

if [ -n "$QSC_INSTALL_PACKAGES" ]
then
	echo "Installing additional packages"
	chroot $VMROOT apt-get install --quiet --assume-yes $QSC_INSTALL_PACKAGES
fi

if [ -n "$QSC_EXTRA_DEBS" ]
then
	echo "Installing extra .debs"
	VMTMP=`mktemp -d -p $VMROOT`
	cp -t $VMTMP $QSC_EXTRA_DEBS
	chroot $VMROOT dpkg --recursive -i `basename $VMTMP`
	chroot $VMROOT apt-get update
	rm -rf $VMTMP
fi

# Mount point for a shared folder, if the VM is launched with one
echo "Adding 9p to initramfs"
echo -e "9p\n9pnet\n9pnet_virtio" >> $VMROOT/etc/initramfs-tools/modules
chroot $VMROOT update-initramfs -u
echo "Adding shared folder to fstab"
mkdir -m 755 $VMROOT/shared
echo "qlaunch /shared 9p trans=virtio,version=9p2000.L,auto,nofail 0 0" >> $VMROOT/etc/fstab

echo "Updating GRUB menu"
echo "GRUB_TIMEOUT=1" >> $VMROOT/etc/default/grub
chroot $VMROOT update-grub

echo "### Customization of base image complete. ###"