##// END OF EJS Templates
fix: custom.d directory error
Jan Wagner -
r63:91f86cfb2544
parent child
Show More
@@ -1,302 +1,305
1 #!/bin/sh
1 #!/bin/sh
2
2
3 ########################################################################
3 ########################################################################
4 # rpi2-gen-image.sh ver2a 12/2015
4 # rpi2-gen-image.sh ver2a 12/2015
5 #
5 #
6 # Advanced debian "jessie" bootstrap script for RPi2
6 # Advanced debian "jessie" bootstrap script for RPi2
7 #
7 #
8 # This program is free software; you can redistribute it and/or
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
11 # of the License, or (at your option) any later version.
12 #
12 #
13 # some parts based on rpi2-build-image:
13 # some parts based on rpi2-build-image:
14 # Copyright (C) 2015 Ryan Finnie <ryan@finnie.org>
14 # Copyright (C) 2015 Ryan Finnie <ryan@finnie.org>
15 # Copyright (C) 2015 Luca Falavigna <dktrkranz@debian.org>
15 # Copyright (C) 2015 Luca Falavigna <dktrkranz@debian.org>
16 ########################################################################
16 ########################################################################
17
17
18 source ./functions.sh
18 source ./functions.sh
19
19
20 set -e
20 set -e
21 set -x
21 set -x
22
22
23 # Debian release
23 # Debian release
24 RELEASE=${RELEASE:=jessie}
24 RELEASE=${RELEASE:=jessie}
25 KERNEL=${KERNEL:=3.18.0-trunk-rpi2}
25 KERNEL=${KERNEL:=3.18.0-trunk-rpi2}
26
26
27 # Build settings
27 # Build settings
28 BASEDIR=$(pwd)/images/${RELEASE}
28 BASEDIR=$(pwd)/images/${RELEASE}
29 BUILDDIR=${BASEDIR}/build
29 BUILDDIR=${BASEDIR}/build
30
30
31 # General settings
31 # General settings
32 HOSTNAME=${HOSTNAME:=rpi2-${RELEASE}}
32 HOSTNAME=${HOSTNAME:=rpi2-${RELEASE}}
33 PASSWORD=${PASSWORD:=raspberry}
33 PASSWORD=${PASSWORD:=raspberry}
34 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
34 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
35 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
35 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
36 XKBMODEL=${XKBMODEL:=""}
36 XKBMODEL=${XKBMODEL:=""}
37 XKBLAYOUT=${XKBLAYOUT:=""}
37 XKBLAYOUT=${XKBLAYOUT:=""}
38 XKBVARIANT=${XKBVARIANT:=""}
38 XKBVARIANT=${XKBVARIANT:=""}
39 XKBOPTIONS=${XKBOPTIONS:=""}
39 XKBOPTIONS=${XKBOPTIONS:=""}
40 EXPANDROOT=${EXPANDROOT:=true}
40 EXPANDROOT=${EXPANDROOT:=true}
41
41
42 # Network settings
42 # Network settings
43 ENABLE_DHCP=${ENABLE_DHCP:=true}
43 ENABLE_DHCP=${ENABLE_DHCP:=true}
44 # NET_* settings are ignored when ENABLE_DHCP=true
44 # NET_* settings are ignored when ENABLE_DHCP=true
45 # NET_ADDRESS is an IPv4 or IPv6 address and its prefix, separated by "/"
45 # NET_ADDRESS is an IPv4 or IPv6 address and its prefix, separated by "/"
46 NET_ADDRESS=${NET_ADDRESS:=""}
46 NET_ADDRESS=${NET_ADDRESS:=""}
47 NET_GATEWAY=${NET_GATEWAY:=""}
47 NET_GATEWAY=${NET_GATEWAY:=""}
48 NET_DNS_1=${NET_DNS_1:=""}
48 NET_DNS_1=${NET_DNS_1:=""}
49 NET_DNS_2=${NET_DNS_2:=""}
49 NET_DNS_2=${NET_DNS_2:=""}
50 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
50 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
51 NET_NTP_1=${NET_NTP_1:=""}
51 NET_NTP_1=${NET_NTP_1:=""}
52 NET_NTP_2=${NET_NTP_2:=""}
52 NET_NTP_2=${NET_NTP_2:=""}
53
53
54 # APT settings
54 # APT settings
55 APT_PROXY=${APT_PROXY:=""}
55 APT_PROXY=${APT_PROXY:=""}
56 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
56 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
57
57
58 # Feature settings
58 # Feature settings
59 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
59 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
60 ENABLE_IPV6=${ENABLE_IPV6:=true}
60 ENABLE_IPV6=${ENABLE_IPV6:=true}
61 ENABLE_SSHD=${ENABLE_SSHD:=true}
61 ENABLE_SSHD=${ENABLE_SSHD:=true}
62 ENABLE_SOUND=${ENABLE_SOUND:=true}
62 ENABLE_SOUND=${ENABLE_SOUND:=true}
63 ENABLE_DBUS=${ENABLE_DBUS:=true}
63 ENABLE_DBUS=${ENABLE_DBUS:=true}
64 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
64 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
65 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
65 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
66 ENABLE_XORG=${ENABLE_XORG:=false}
66 ENABLE_XORG=${ENABLE_XORG:=false}
67 ENABLE_WM=${ENABLE_WM:=""}
67 ENABLE_WM=${ENABLE_WM:=""}
68 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
68 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
69 ENABLE_USER=${ENABLE_USER:=true}
69 ENABLE_USER=${ENABLE_USER:=true}
70 ENABLE_ROOT=${ENABLE_ROOT:=false}
70 ENABLE_ROOT=${ENABLE_ROOT:=false}
71 ENABLE_ROOT_SSH=${ENABLE_ROOT_SSH:=false}
71 ENABLE_ROOT_SSH=${ENABLE_ROOT_SSH:=false}
72
72
73 # Advanced settings
73 # Advanced settings
74 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
74 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
75 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
75 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
76 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
76 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
77 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
77 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
78 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
78 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
79
79
80 # Kernel compilation settings
80 # Kernel compilation settings
81 BUILD_KERNEL=${BUILD_KERNEL:=false}
81 BUILD_KERNEL=${BUILD_KERNEL:=false}
82 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
82 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
83
83
84 # Image chroot path
84 # Image chroot path
85 R=${BUILDDIR}/chroot
85 R=${BUILDDIR}/chroot
86 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
86 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
87
87
88 # Packages required for bootstrapping
88 # Packages required for bootstrapping
89 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git-core"
89 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git-core"
90
90
91 # Missing packages that need to be installed
91 # Missing packages that need to be installed
92 MISSING_PACKAGES=""
92 MISSING_PACKAGES=""
93
93
94 # Packages required in the chroot build environment
94 # Packages required in the chroot build environment
95 APT_INCLUDES=${APT_INCLUDES:=""}
95 APT_INCLUDES=${APT_INCLUDES:=""}
96 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,ca-certificates,debian-archive-keyring,dialog,sudo"
96 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,ca-certificates,debian-archive-keyring,dialog,sudo"
97
97
98 set +x
98 set +x
99
99
100 # Are we running as root?
100 # Are we running as root?
101 if [ "$(id -u)" -ne "0" ] ; then
101 if [ "$(id -u)" -ne "0" ] ; then
102 echo "this script must be executed with root privileges"
102 echo "this script must be executed with root privileges"
103 exit 1
103 exit 1
104 fi
104 fi
105
105
106 # Add packages required for kernel cross compilation
106 # Add packages required for kernel cross compilation
107 if [ "$BUILD_KERNEL" = true ] ; then
107 if [ "$BUILD_KERNEL" = true ] ; then
108 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
108 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
109 fi
109 fi
110
110
111 # Check if all required packages are installed
111 # Check if all required packages are installed
112 for package in $REQUIRED_PACKAGES ; do
112 for package in $REQUIRED_PACKAGES ; do
113 if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then
113 if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then
114 MISSING_PACKAGES="$MISSING_PACKAGES $package"
114 MISSING_PACKAGES="$MISSING_PACKAGES $package"
115 fi
115 fi
116 done
116 done
117
117
118 # Ask if missing packages should get installed right now
118 # Ask if missing packages should get installed right now
119 if [ -n "$MISSING_PACKAGES" ] ; then
119 if [ -n "$MISSING_PACKAGES" ] ; then
120 echo "the following packages needed by this script are not installed:"
120 echo "the following packages needed by this script are not installed:"
121 echo "$MISSING_PACKAGES"
121 echo "$MISSING_PACKAGES"
122
122
123 echo -n "\ndo you want to install the missing packages right now? [y/n] "
123 echo -n "\ndo you want to install the missing packages right now? [y/n] "
124 read confirm
124 read confirm
125 if [ "$confirm" != "y" ] ; then
125 if [ "$confirm" != "y" ] ; then
126 exit 1
126 exit 1
127 fi
127 fi
128 fi
128 fi
129
129
130 # Make sure all required packages are installed
130 # Make sure all required packages are installed
131 apt-get -qq -y install ${REQUIRED_PACKAGES}
131 apt-get -qq -y install ${REQUIRED_PACKAGES}
132
132
133 # Don't clobber an old build
133 # Don't clobber an old build
134 if [ -e "$BUILDDIR" ]; then
134 if [ -e "$BUILDDIR" ]; then
135 echo "directory $BUILDDIR already exists, not proceeding"
135 echo "directory $BUILDDIR already exists, not proceeding"
136 exit 1
136 exit 1
137 fi
137 fi
138
138
139 set -x
139 set -x
140
140
141 # Call "cleanup" function on various signals and errors
141 # Call "cleanup" function on various signals and errors
142 trap cleanup 0 1 2 3 6
142 trap cleanup 0 1 2 3 6
143
143
144 # Set up chroot directory
144 # Set up chroot directory
145 mkdir -p $R
145 mkdir -p $R
146
146
147 # Add required packages for the minbase installation
147 # Add required packages for the minbase installation
148 if [ "$ENABLE_MINBASE" = true ] ; then
148 if [ "$ENABLE_MINBASE" = true ] ; then
149 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools"
149 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools"
150 else
150 else
151 APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup"
151 APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup"
152 fi
152 fi
153
153
154 # Add parted package, required to get partprobe utility
154 # Add parted package, required to get partprobe utility
155 if [ "$EXPANDROOT" = true ] ; then
155 if [ "$EXPANDROOT" = true ] ; then
156 APT_INCLUDES="${APT_INCLUDES},parted"
156 APT_INCLUDES="${APT_INCLUDES},parted"
157 fi
157 fi
158
158
159 # Add dbus package, recommended if using systemd
159 # Add dbus package, recommended if using systemd
160 if [ "$ENABLE_DBUS" = true ] ; then
160 if [ "$ENABLE_DBUS" = true ] ; then
161 APT_INCLUDES="${APT_INCLUDES},dbus"
161 APT_INCLUDES="${APT_INCLUDES},dbus"
162 fi
162 fi
163
163
164 # Add iptables IPv4/IPv6 package
164 # Add iptables IPv4/IPv6 package
165 if [ "$ENABLE_IPTABLES" = true ] ; then
165 if [ "$ENABLE_IPTABLES" = true ] ; then
166 APT_INCLUDES="${APT_INCLUDES},iptables"
166 APT_INCLUDES="${APT_INCLUDES},iptables"
167 fi
167 fi
168
168
169 # Add openssh server package
169 # Add openssh server package
170 if [ "$ENABLE_SSHD" = true ] ; then
170 if [ "$ENABLE_SSHD" = true ] ; then
171 APT_INCLUDES="${APT_INCLUDES},openssh-server"
171 APT_INCLUDES="${APT_INCLUDES},openssh-server"
172 fi
172 fi
173
173
174 # Add alsa-utils package
174 # Add alsa-utils package
175 if [ "$ENABLE_SOUND" = true ] ; then
175 if [ "$ENABLE_SOUND" = true ] ; then
176 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
176 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
177 fi
177 fi
178
178
179 # Add rng-tools package
179 # Add rng-tools package
180 if [ "$ENABLE_HWRANDOM" = true ] ; then
180 if [ "$ENABLE_HWRANDOM" = true ] ; then
181 APT_INCLUDES="${APT_INCLUDES},rng-tools"
181 APT_INCLUDES="${APT_INCLUDES},rng-tools"
182 fi
182 fi
183
183
184 if [ "$ENABLE_USER" = true ]; then
184 if [ "$ENABLE_USER" = true ]; then
185 APT_INCLUDES="${APT_INCLUDES},sudo"
185 APT_INCLUDES="${APT_INCLUDES},sudo"
186 fi
186 fi
187
187
188 # Add fbturbo video driver
188 # Add fbturbo video driver
189 if [ "$ENABLE_FBTURBO" = true ] ; then
189 if [ "$ENABLE_FBTURBO" = true ] ; then
190 # Enable xorg package dependencies
190 # Enable xorg package dependencies
191 ENABLE_XORG=true
191 ENABLE_XORG=true
192 fi
192 fi
193
193
194 # Add user defined window manager package
194 # Add user defined window manager package
195 if [ -n "$ENABLE_WM" ] ; then
195 if [ -n "$ENABLE_WM" ] ; then
196 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
196 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
197
197
198 # Enable xorg package dependencies
198 # Enable xorg package dependencies
199 ENABLE_XORG=true
199 ENABLE_XORG=true
200 fi
200 fi
201
201
202 # Add xorg package
202 # Add xorg package
203 if [ "$ENABLE_XORG" = true ] ; then
203 if [ "$ENABLE_XORG" = true ] ; then
204 APT_INCLUDES="${APT_INCLUDES},xorg"
204 APT_INCLUDES="${APT_INCLUDES},xorg"
205 fi
205 fi
206
206
207 ## Main bootstrap
207 ## Main bootstrap
208 for i in bootstrap.d/*.sh; do
208 for i in bootstrap.d/*.sh; do
209 . $i
209 . $i
210 done
210 done
211
211
212 for i in custom.d/*.sh; do
212 ## Custom bootstrap scripts
213 . $i
213 if [ -d "custom.d" ]; then
214 done
214 for i in custom.d/*.sh; do
215 . $i
216 done
217 fi
215
218
216 # Invoke custom scripts
219 # Invoke custom scripts
217 if [ -n "${CHROOT_SCRIPTS}" ]; then
220 if [ -n "${CHROOT_SCRIPTS}" ]; then
218 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
221 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
219 LANG=C chroot $R bash -c 'for SCRIPT in /chroot_scripts/*; do if [ -f $SCRIPT -a -x $SCRIPT ]; then $SCRIPT; fi done;'
222 LANG=C chroot $R bash -c 'for SCRIPT in /chroot_scripts/*; do if [ -f $SCRIPT -a -x $SCRIPT ]; then $SCRIPT; fi done;'
220 rm -rf "${R}/chroot_scripts"
223 rm -rf "${R}/chroot_scripts"
221 fi
224 fi
222
225
223 ## Cleanup
226 ## Cleanup
224 chroot_exec apt-get -y clean
227 chroot_exec apt-get -y clean
225 chroot_exec apt-get -y autoclean
228 chroot_exec apt-get -y autoclean
226 chroot_exec apt-get -y autoremove
229 chroot_exec apt-get -y autoremove
227
230
228 # Unmount mounted filesystems
231 # Unmount mounted filesystems
229 umount -l $R/proc
232 umount -l $R/proc
230 umount -l $R/sys
233 umount -l $R/sys
231
234
232 # Clean up files
235 # Clean up files
233 rm -f $R/etc/apt/sources.list.save
236 rm -f $R/etc/apt/sources.list.save
234 rm -f $R/etc/resolvconf/resolv.conf.d/original
237 rm -f $R/etc/resolvconf/resolv.conf.d/original
235 rm -rf $R/run
238 rm -rf $R/run
236 mkdir -p $R/run
239 mkdir -p $R/run
237 rm -f $R/etc/*-
240 rm -f $R/etc/*-
238 rm -f $R/root/.bash_history
241 rm -f $R/root/.bash_history
239 rm -rf $R/tmp/*
242 rm -rf $R/tmp/*
240 rm -f $R/var/lib/urandom/random-seed
243 rm -f $R/var/lib/urandom/random-seed
241 [ -L $R/var/lib/dbus/machine-id ] || rm -f $R/var/lib/dbus/machine-id
244 [ -L $R/var/lib/dbus/machine-id ] || rm -f $R/var/lib/dbus/machine-id
242 rm -f $R/etc/machine-id
245 rm -f $R/etc/machine-id
243 rm -fr $R/etc/apt/apt.conf.d/10proxy
246 rm -fr $R/etc/apt/apt.conf.d/10proxy
244 rm -f $R/etc/resolv.conf
247 rm -f $R/etc/resolv.conf
245
248
246 # Calculate size of the chroot directory in KB
249 # Calculate size of the chroot directory in KB
247 CHROOT_SIZE=$(expr `du -s $R | awk '{ print $1 }'`)
250 CHROOT_SIZE=$(expr `du -s $R | awk '{ print $1 }'`)
248
251
249 # Calculate the amount of needed 512 Byte sectors
252 # Calculate the amount of needed 512 Byte sectors
250 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
253 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
251 BOOT_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
254 BOOT_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
252 ROOT_OFFSET=$(expr ${TABLE_SECTORS} + ${BOOT_SECTORS})
255 ROOT_OFFSET=$(expr ${TABLE_SECTORS} + ${BOOT_SECTORS})
253
256
254 # The root partition is EXT4
257 # The root partition is EXT4
255 # This means more space than the actual used space of the chroot is used.
258 # This means more space than the actual used space of the chroot is used.
256 # As overhead for journaling and reserved blocks 20% are added.
259 # As overhead for journaling and reserved blocks 20% are added.
257 ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 20) \* 1024 \/ 512)
260 ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 20) \* 1024 \/ 512)
258
261
259 # Calculate required image size in 512 Byte sectors
262 # Calculate required image size in 512 Byte sectors
260 IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${BOOT_SECTORS} + ${ROOT_SECTORS})
263 IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${BOOT_SECTORS} + ${ROOT_SECTORS})
261
264
262 # Prepare date string for image file name
265 # Prepare date string for image file name
263 DATE="$(date +%Y-%m-%d)"
266 DATE="$(date +%Y-%m-%d)"
264
267
265 # Prepare image file
268 # Prepare image file
266 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=${TABLE_SECTORS}
269 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=${TABLE_SECTORS}
267 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=0 seek=${IMAGE_SECTORS}
270 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=0 seek=${IMAGE_SECTORS}
268
271
269 # Write partition table
272 # Write partition table
270 sfdisk -q -f "$BASEDIR/${DATE}-debian-${RELEASE}.img" <<EOM
273 sfdisk -q -f "$BASEDIR/${DATE}-debian-${RELEASE}.img" <<EOM
271 unit: sectors
274 unit: sectors
272
275
273 1 : start= ${TABLE_SECTORS}, size= ${BOOT_SECTORS}, Id= c, bootable
276 1 : start= ${TABLE_SECTORS}, size= ${BOOT_SECTORS}, Id= c, bootable
274 2 : start= ${ROOT_OFFSET}, size= ${ROOT_SECTORS}, Id=83
277 2 : start= ${ROOT_OFFSET}, size= ${ROOT_SECTORS}, Id=83
275 3 : start= 0, size= 0, Id= 0
278 3 : start= 0, size= 0, Id= 0
276 4 : start= 0, size= 0, Id= 0
279 4 : start= 0, size= 0, Id= 0
277 EOM
280 EOM
278
281
279 # Set up temporary loop devices and build filesystems
282 # Set up temporary loop devices and build filesystems
280 VFAT_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)"
283 VFAT_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)"
281 EXT4_LOOP="$(losetup -o 65M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)"
284 EXT4_LOOP="$(losetup -o 65M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)"
282 mkfs.vfat "$VFAT_LOOP"
285 mkfs.vfat "$VFAT_LOOP"
283 mkfs.ext4 "$EXT4_LOOP"
286 mkfs.ext4 "$EXT4_LOOP"
284
287
285 # Mount the temporary loop devices
288 # Mount the temporary loop devices
286 mkdir -p "$BUILDDIR/mount"
289 mkdir -p "$BUILDDIR/mount"
287 mount "$EXT4_LOOP" "$BUILDDIR/mount"
290 mount "$EXT4_LOOP" "$BUILDDIR/mount"
288
291
289 mkdir -p "$BUILDDIR/mount/boot/firmware"
292 mkdir -p "$BUILDDIR/mount/boot/firmware"
290 mount "$VFAT_LOOP" "$BUILDDIR/mount/boot/firmware"
293 mount "$VFAT_LOOP" "$BUILDDIR/mount/boot/firmware"
291
294
292 # Copy all files from the chroot to the loop device mount point directory
295 # Copy all files from the chroot to the loop device mount point directory
293 rsync -a "$R/" "$BUILDDIR/mount/"
296 rsync -a "$R/" "$BUILDDIR/mount/"
294
297
295 # Unmount all temporary loop devices and mount points
298 # Unmount all temporary loop devices and mount points
296 cleanup
299 cleanup
297
300
298 # (optinal) create block map file for "bmaptool"
301 # (optinal) create block map file for "bmaptool"
299 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}.img"
302 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}.img"
300
303
301 # Image was successfully created
304 # Image was successfully created
302 echo "$BASEDIR/${DATE}-debian-${RELEASE}.img (${IMAGE_SIZE})" ": successfully created"
305 echo "$BASEDIR/${DATE}-debian-${RELEASE}.img (${IMAGE_SIZE})" ": successfully created"
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant