@@ -9,8 +9,8 @@ apt-get install -y --no-install-recommends ubuntu-keyring ca-certificates deboot
9
9
# Make sure cross-running ARM ELF executables is enabled
10
10
update-binfmts --enable
11
11
12
- rootdir=` pwd`
13
- basedir=` pwd` /artifacts/elementary-rpi
12
+ rootdir=$( pwd)
13
+ basedir=$( pwd) /artifacts/elementary-rpi
14
14
15
15
# Free space on rootfs in MiB
16
16
free_space=" 500"
@@ -24,8 +24,8 @@ version=6.0
24
24
YYYYMMDD=" $( date +%Y%m%d) "
25
25
imagename=elementaryos-$version -$channel -rpi-$YYYYMMDD
26
26
27
- mkdir -p ${basedir}
28
- cd ${basedir}
27
+ mkdir -p " ${basedir} "
28
+ cd " ${basedir} "
29
29
30
30
# Bootstrap an ubuntu minimal system
31
31
debootstrap --foreign --arch $architecture $codename elementary-$architecture http://ports.ubuntu.com/ubuntu-ports
@@ -37,7 +37,7 @@ cp /usr/bin/qemu-arm-static elementary-$architecture/usr/bin/
37
37
LANG=C chroot elementary-$architecture /debootstrap/debootstrap --second-stage
38
38
39
39
# Copy Raspberry Pi specific files
40
- cp -r ${rootdir} /rpi/rootfs/writable/* elementary-${architecture} /
40
+ cp -r " ${rootdir} " /rpi/rootfs/writable/* elementary-${architecture} /
41
41
42
42
# Add the rest of the ubuntu repos
43
43
cat << EOF > elementary-$architecture /etc/apt/sources.list
@@ -46,9 +46,9 @@ deb http://ports.ubuntu.com/ubuntu-ports $codename-updates main restricted unive
46
46
EOF
47
47
48
48
# Copy in the elementary PPAs/keys/apt config
49
- for f in ${rootdir} /etc/config/archives/* .list; do cp -- " $f " " elementary-$architecture /etc/apt/sources.list.d/$( basename -- $f ) " ; done
50
- for f in ${rootdir} /etc/config/archives/* .key; do cp -- " $f " " elementary-$architecture /etc/apt/trusted.gpg.d/$( basename -- $f ) .asc" ; done
51
- for f in ${rootdir} /etc/config/archives/* .pref; do cp -- " $f " " elementary-$architecture /etc/apt/preferences.d/$( basename -- $f ) " ; done
49
+ for f in " ${rootdir} " /etc/config/archives/* .list; do cp -- " $f " " elementary-$architecture /etc/apt/sources.list.d/$( basename -- " $f " ) " ; done
50
+ for f in " ${rootdir} " /etc/config/archives/* .key; do cp -- " $f " " elementary-$architecture /etc/apt/trusted.gpg.d/$( basename -- " $f " ) .asc" ; done
51
+ for f in " ${rootdir} " /etc/config/archives/* .pref; do cp -- " $f " " elementary-$architecture /etc/apt/preferences.d/$( basename -- " $f " ) " ; done
52
52
53
53
# Set codename/channel in added repos
54
54
sed -i " s/@CHANNEL/$channel /" elementary-$architecture /etc/apt/sources.list.d/* .list*
@@ -121,22 +121,23 @@ chmod +x elementary-$architecture/hardware
121
121
LANG=C chroot elementary-$architecture /hardware
122
122
123
123
# Copy in any file overrides
124
- cp -r ${rootdir} /etc/config/includes.chroot/* elementary-$architecture /
124
+ cp -r " ${rootdir} " /etc/config/includes.chroot/* elementary-$architecture /
125
125
126
126
mkdir elementary-$architecture /hooks
127
- cp ${rootdir} /etc/config/hooks/live/* .chroot elementary-$architecture /hooks
127
+ cp " ${rootdir} " /etc/config/hooks/live/* .chroot elementary-$architecture /hooks
128
128
129
- for f in elementary-$architecture /hooks/*
129
+ hook_files=" elementary-$architecture /hooks/*"
130
+ for f in $hook_files
130
131
do
131
- base=` basename ${f} `
132
+ base=$( basename " ${f} " )
132
133
LANG=C chroot elementary-$architecture " /hooks/${base} "
133
134
done
134
135
135
136
rm -r " elementary-$architecture /hooks"
136
137
137
138
# Add a oneshot service to grow the rootfs on first boot
138
- install -m 755 -o root -g root ${rootdir} /rpi/files/resizerootfs " elementary-$architecture /usr/sbin/resizerootfs"
139
- install -m 644 -o root -g root ${rootdir} /pinebookpro/files/resizerootfs.service " elementary-$architecture /etc/systemd/system"
139
+ install -m 755 -o root -g root " ${rootdir} /rpi/files/resizerootfs" " elementary-$architecture /usr/sbin/resizerootfs"
140
+ install -m 644 -o root -g root " ${rootdir} /pinebookpro/files/resizerootfs.service" " elementary-$architecture /etc/systemd/system"
140
141
mkdir -p " elementary-$architecture /etc/systemd/system/systemd-remount-fs.service.requires/"
141
142
ln -s /etc/systemd/system/resizerootfs.service " elementary-$architecture /etc/systemd/system/systemd-remount-fs.service.requires/resizerootfs.service"
142
143
@@ -154,42 +155,42 @@ EOF
154
155
155
156
# Calculate the space to create the image.
156
157
root_size=$( du -s -B1K elementary-$architecture | cut -f1)
157
- raw_size=$(( $((${ free_space} * 1024 )) +${ root_size} ))
158
+ raw_size=$(( $((free_space* 1024 )) +root_size))
158
159
159
160
# Create the disk and partition it
160
161
echo " Creating image file"
161
162
162
163
# Sometimes fallocate fails if the filesystem or location doesn't support it, fallback to slower dd in this case
163
- if ! fallocate -l $( echo ${raw_size} Ki | numfmt --from=iec-i --to=si --format=%.1f) ${basedir} /${imagename} .img
164
+ if ! fallocate -l " $( echo ${raw_size} Ki | numfmt --from=iec-i --to=si --format=%.1f) " " ${basedir} /${imagename} .img"
164
165
then
165
- dd if=/dev/zero of=${basedir} /${imagename} .img bs=1024 count=${raw_size}
166
+ dd if=/dev/zero of=" ${basedir} /${imagename} .img" bs=1024 count=${raw_size}
166
167
fi
167
168
168
- parted ${imagename} .img --script -- mklabel msdos
169
- parted ${imagename} .img --script -- mkpart primary fat32 0 256
170
- parted ${imagename} .img --script -- mkpart primary ext4 256 -1
169
+ parted " ${imagename} .img" --script -- mklabel msdos
170
+ parted " ${imagename} .img" --script -- mkpart primary fat32 0 256
171
+ parted " ${imagename} .img" --script -- mkpart primary ext4 256 -1
171
172
172
173
# Set the partition variables
173
- loopdevice=` losetup -f --show ${basedir} /${imagename} .img`
174
- device=` kpartx -va $loopdevice | sed -E ' s/.*(loop[0-9])p.*/\1/g' | head -1`
174
+ loopdevice=$( losetup -f --show " ${basedir} /${imagename} .img" )
175
+ device=$( kpartx -va " $loopdevice " | sed -E ' s/.*(loop[0-9])p.*/\1/g' | head -1)
175
176
device=" /dev/mapper/${device} "
176
177
bootp=${device} p1
177
178
rootp=${device} p2
178
179
179
180
# Create file systems
180
- mkfs.vfat -n system-boot $bootp
181
- mkfs.ext4 -L writable $rootp
181
+ mkfs.vfat -n system-boot " $bootp "
182
+ mkfs.ext4 -L writable " $rootp "
182
183
183
184
# Create the dirs for the partitions and mount them
184
- mkdir -p ${basedir} /bootp ${basedir} /root
185
- mount -t vfat $bootp ${basedir} /bootp
186
- mount $rootp ${basedir} /root
185
+ mkdir -p " ${basedir} /bootp" " ${basedir} /root"
186
+ mount -t vfat " $bootp " " ${basedir} /bootp"
187
+ mount " $rootp " " ${basedir} /root"
187
188
188
189
mkdir -p elementary-$architecture /boot/firmware
189
- mount -o bind ${basedir} /bootp/ elementary-$architecture /boot/firmware
190
+ mount -o bind " ${basedir} /bootp/" elementary-$architecture /boot/firmware
190
191
191
192
# Copy Raspberry Pi specific files
192
- cp -r ${rootdir} /rpi/rootfs/system-boot/* elementary-${architecture} /boot/firmware/
193
+ cp -r " ${rootdir} " /rpi/rootfs/system-boot/* elementary-${architecture} /boot/firmware/
193
194
194
195
# Copy kernels and firemware to boot partition
195
196
cat << EOF > elementary-$architecture /hardware
@@ -210,31 +211,31 @@ LANG=C chroot elementary-$architecture /hardware
210
211
211
212
# Grab some updated firmware from the Raspberry Pi foundation
212
213
git clone -b ' 1.20201022' --single-branch --depth 1 https://github.com/raspberrypi/firmware raspi-firmware
213
- cp raspi-firmware/boot/* .elf ${basedir} /bootp/
214
- cp raspi-firmware/boot/* .dat ${basedir} /bootp/
215
- cp raspi-firmware/boot/bootcode.bin ${basedir} /bootp/
214
+ cp raspi-firmware/boot/* .elf " ${basedir} /bootp/"
215
+ cp raspi-firmware/boot/* .dat " ${basedir} /bootp/"
216
+ cp raspi-firmware/boot/bootcode.bin " ${basedir} /bootp/"
216
217
217
218
umount elementary-$architecture /dev/pts
218
219
umount elementary-$architecture /dev/
219
220
umount elementary-$architecture /proc
220
221
umount elementary-$architecture /boot/firmware
221
222
222
223
echo " Rsyncing rootfs into image file"
223
- rsync -HPavz -q ${basedir} /elementary-$architecture / ${basedir} /root/
224
+ rsync -HPavz -q " ${basedir} /elementary-$architecture /" " ${basedir} /root/"
224
225
225
226
# Unmount partitions
226
- umount $bootp
227
- umount $rootp
228
- kpartx -dv $loopdevice
229
- losetup -d $loopdevice
227
+ umount " $bootp "
228
+ umount " $rootp "
229
+ kpartx -dv " $loopdevice "
230
+ losetup -d " $loopdevice "
230
231
231
232
echo " Compressing ${imagename} .img"
232
- xz -T0 -z ${basedir} /${imagename} .img
233
+ xz -T0 -z " ${basedir} /${imagename} .img"
233
234
234
235
cd " ${basedir} "
235
236
236
- md5sum ${imagename} .img.xz > ${imagename} .md5.txt
237
- sha256sum ${imagename} .img.xz > ${imagename} .sha256.txt
237
+ md5sum " ${imagename} .img.xz" > " ${imagename} .md5.txt"
238
+ sha256sum " ${imagename} .img.xz" > " ${imagename} .sha256.txt"
238
239
239
240
cd " ${rootdir} "
240
241
0 commit comments