Skip to content

Commit 670f18e

Browse files
committed
Update building images
1 parent b5dbcd2 commit 670f18e

File tree

8 files changed

+265
-86
lines changed

8 files changed

+265
-86
lines changed

build-server-image-chroot.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ _finish_up() {
3232
rm /home/alarm/smb.conf
3333
rm /root/type
3434
cp /home/alarm/config-server.service /etc/systemd/system/
35+
chmod +x /root/eos-ARM-server-config.sh
3536
cp /home/alarm/lsb-release /etc/
3637
cp /home/alarm/os-release /etc/
3738
sed -i 's/Arch/EndeavourOS/g' /etc/issue
3839
sed -i 's/Arch/EndeavourOS/g' /usr/share/factory/etc/issue
3940
systemctl enable config-server.service
4041
systemctl enable NetworkManager
41-
rm /home/alarm/config-server.service
42-
4342
printf "\n${CYAN}Ready to create an image.${NC}\n"
4443
} # end of function _finish_up
4544

@@ -48,6 +47,7 @@ _finish_up() {
4847
Main() {
4948

5049
PLATFORM_NAME=" "
50+
TYPE=" "
5151

5252
# Declare color variables
5353
GREEN='\033[0;32m'
@@ -58,9 +58,12 @@ Main() {
5858
# STARTS HERE
5959
dmesg -n 1 # prevent low level kernel messages from appearing during the script
6060

61-
# read in platformname passed by install-image-aarch64.sh
61+
# read in platformname and type passed by build-server-image-eos.sh
6262
file="/root/platformname"
6363
read -d $'\x04' PLATFORM_NAME < "$file"
64+
file="/root/type"
65+
read -d $'\x04' TYPE < "$file"
66+
6467
_check_if_root
6568
_check_internet_connection
6669
sed -i 's/#ParallelDownloads = 5/ParallelDownloads = 5/g' /etc/pacman.conf
@@ -87,11 +90,17 @@ Main() {
8790
sed -i '/SigLevel = PackageRequired/d' /etc/pacman.conf
8891
rm /etc/pacman.d/endeavouros-mirrorlist
8992
;;
90-
RPi64) cp /boot/config.txt /boot/config.txt.orig
93+
RPi4) cp /boot/config.txt /boot/config.txt.orig
9194
cp /home/alarm/rpi4-config.txt /boot/config.txt
9295
;;
9396
esac
9497

98+
if [ "$TYPE" == "Image" ]; then
99+
cp /root/resize-fs.service /etc/systemd/system/
100+
chmod +x /root/resize-fs.sh
101+
systemctl enable resize-fs.service
102+
fi
103+
95104
mkdir -p /etc/samba
96105
cp /home/alarm/smb.conf /etc/samba/
97106
_finish_up

build-server-image-eos.sh

Lines changed: 62 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ _copy_stuff_for_chroot() {
2222
mkdir $WORKDIR/MP/home/alarm
2323
cp build-server-image-chroot.sh $WORKDIR/MP/root/
2424
cp eos-ARM-server-config.sh $WORKDIR/MP/root/
25+
cp resize-fs.service $WORKDIR/MP/root
26+
cp resize-fs.sh $WORKDIR/MP/root
2527
cp smb.conf $WORKDIR/MP/home/alarm
2628
cp config-server.service $WORKDIR/MP/home/alarm/
2729
cp lsb-release $WORKDIR/MP/home/alarm
2830
cp os-release $WORKDIR/MP/home/alarm
29-
case $PLATFORM in
30-
RPi64) cp rpi4-config.txt $WORKDIR/MP/home/alarm/ ;;
31-
OdroidN2) cp n2-boot.ini $WORKDIR/MP/home/alarm ;;
32-
esac
31+
cp rpi4-config.txt $WORKDIR/MP/home/alarm/
32+
# case $PLATFORM in
33+
# RPi4) cp rpi4-config.txt $WORKDIR/MP/home/alarm/ ;;
34+
# OdroidN2) cp n2-boot.ini $WORKDIR/MP/home/alarm ;;
35+
# esac
3336
printf "$PLATFORM\n" > platformname
3437
cp platformname $WORKDIR/MP/root/
3538
rm platformname
@@ -38,6 +41,21 @@ _copy_stuff_for_chroot() {
3841
rm type
3942
}
4043

44+
_fstab_uuid() {
45+
46+
local fstabuuid=""
47+
48+
printf "\n${CYAN}Changing /etc/fstab to UUID numbers instead of a lable such as /dev/sda.${NC}\n"
49+
mv $WORKDIR/MP/etc/fstab $WORKDIR/MP/etc/fstab-bkup
50+
partition=$(sed 's#\/dev\/##g' <<< $PARTNAME1)
51+
fstabuuid="UUID="$(lsblk -o NAME,UUID | grep $partition | awk '{print $2}')
52+
# fstabuuid should be UUID=XXXX-XXXX
53+
printf "# /etc/fstab: static file system information.\n#\n# Use 'blkid' to print the universally unique identifier for a device; this may\n" > $WORKDIR/MP/etc/fstab
54+
printf "# be used with UUID= as a more robust way to name devices that works even if\n# disks are added and removed. See fstab(5).\n" >> $WORKDIR/MP/etc/fstab
55+
printf "#\n# <file system> <mount point> <type> <options> <dump> <pass>\n\n" >> $WORKDIR/MP/etc/fstab
56+
printf "$fstabuuid /boot vfat defaults 0 0\n\n" >> $WORKDIR/MP/etc/fstab
57+
} # end of fucntion _fstab_uuid
58+
4159
_install_OdroidN2_image() {
4260
local user_confirm
4361
if $DOWNLOAD ; then
@@ -52,30 +70,23 @@ _install_OdroidN2_image() {
5270

5371

5472
_install_RPi4_image() {
55-
pacstrap -cGM $WORKDIR/MP - < $WORKDIR/pkglist-rpi.txt
73+
pacstrap -cGM $WORKDIR/MP - < $WORKDIR/pkglist-rpi4.txt
5674
_copy_stuff_for_chroot
5775
case $TYPE in
5876
Rootfs) sed -i 's/mmcblk0/mmcblk1/' $WORKDIR/MP/etc/fstab
5977
;;
60-
Image) mv $WORKDIR/MP/etc/fstab $WORKDIR/MP/etc/fstab-bkup
61-
uuidno=$(lsblk -o UUID $PARTNAME1)
62-
uuidno=$(echo $uuidno | sed 's/ /=/g')
63-
printf "# /etc/fstab: static file system information.\n#\n# Use 'blkid' to print the universally unique identifier for a device; this may\n" >> $WORKDIR/MP/etc/fstab
64-
printf "# be used with UUID= as a more robust way to name devices that works even if\n# disks are added and removed. See fstab(5).\n" >> $WORKDIR/MP/etc/fstab
65-
printf "#\n# <file system> <mount point> <type> <options> <dump> <pass>\n\n" >> $WORKDIR/MP/etc/fstab
66-
printf "$uuidno /boot vfat defaults 0 0\n" >> $WORKDIR/MP/etc/fstab
67-
uuidno=$(lsblk -o UUID $PARTNAME2)
68-
uuidno=$(echo $uuidno | sed 's/ /=/g')
69-
old=$(awk '{print $1}') $WORKDIR/MP/boot/cmdline.txt
70-
new="root="$uuidno
71-
sed -i "s#$old#$new#" $WORKDIR/MP/boot/cmdline.txt
72-
;;
78+
Image) _fstab_uuid
79+
partition=$(sed 's#\/dev\/##g' <<< $PARTNAME2)
80+
uuidno="root=UUID="$(lsblk -o NAME,UUID | grep $partition | awk '{print $2}')
81+
# uuidno should now be "root=UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX
82+
old=$(cat $WORKDIR/MP/boot/cmdline.txt | grep root= | awk '{print $1}')
83+
sed -i "s#$old#$uuidno#" $WORKDIR/MP/boot/cmdline.txt
84+
;;
7385
esac
7486
} # End of function _install_RPi4_image
7587

7688
_partition_format_mount() {
7789

78-
# fallocate -l 6G test.img
7990
fallocate -l 7.5G test.img
8091
fallocate -d test.img
8192

@@ -84,7 +95,9 @@ _partition_format_mount() {
8495
printf "\n${CYAN} DEVICENAME ${NC}\n"
8596
echo $DEVICENAME
8697
echo $DVN
87-
98+
printf "\nlosetup -a = "
99+
losetup -a
100+
read z
88101
##### Determine data device size in MiB and partition ###
89102
printf "\n${CYAN}Partitioning, & formatting storage device...${NC}\n"
90103
DEVICESIZE=$(fdisk -l | grep "Disk $DEVICENAME" | awk '{print $5}')
@@ -93,7 +106,7 @@ _partition_format_mount() {
93106
printf "\n${CYAN}Partitioning storage device $DEVICENAME...${NC}\n"
94107

95108
case $PLATFORM in
96-
RPi64) _partition_RPi4 ;;
109+
RPi4) _partition_RPi4 ;;
97110
OdroidN2) _partition_OdroidN2 ;;
98111
esac
99112

@@ -137,22 +150,21 @@ _arch_chroot(){
137150

138151
_create_image(){
139152
case $PLATFORM in
140-
OdroidN2)# time bsdtar --use-compress-program=zstdmt -cf $IMAGEDIR/enosARM-server-odroid-n2-latest.tar.zst *
153+
OdroidN2)
154+
xz -kvfT0 -2 $WORKDIR/test.img
141155
time bsdtar -cf - * | zstd -z --rsyncable -10 -T0 -of /$IMAGEDIR/enosARM-server-odroid-n2-latest.tar.zst
142156
printf "\n\nbsdtar is finished creating the image.\nand will calculate a sha512sum\n\n"
143157
dir=$(pwd)
144158
cd /home/$USERNAME/endeavouros-arm/test-images/
145159
sha512sum enosARM-server-odroid-n2-latest.tar.zst > enosARM-server-odroid-n2-latest.tar.zst.sha512sum
146160
cd $dir ;;
147-
RPi64)
161+
RPi4)
148162
xz -kvfT0 -2 $WORKDIR/test.img
149-
cp $WORKDIR/test.img.xz /home/$USERNAME/pudges-place/server-images/enosARM-server-rpi-latest.img.xz
150-
printf "\n\nFinished creating the image.\nand will calculate a sha512sum\n\n"
151-
cd $WORKDIR
152-
dir=$(pwd)
153-
cd /home/$USERNAME/pudges-place/server-images/
154-
sha512sum enosARM-server-rpi-latest.img.xz > enosARM-server-rpi-latest.img.xz.sha512sum
155-
cd $dir ;;
163+
cp $WORKDIR/test.img.xz /home/$USERNAME/endeavouros-arm/test-images/enosARM-server-rpi4-latest.img.xz
164+
printf "\n\nCreating the image is finished.\nand will calculate a sha512sum\n\n"
165+
cd /home/$USERNAME/endeavouros-arm/test-images/
166+
sha512sum enosARM-server-rpi4-latest.img.xz > "enosARM-server-rpi4-latest.img.xz.sha512sum"
167+
cd $WORKDIR ;;
156168
esac
157169
} # end of function _create_image
158170

@@ -166,14 +178,14 @@ _create_rootfs(){
166178
cd /home/$USERNAME/endeavouros-arm/test-images/
167179
sha512sum enosLinuxARM-odroid-n2-latest.tar.zst > enosLinuxARM-odroid-n2-latest.tar.zst.sha512sum
168180
cd $dir ;;
169-
RPi64) # time bsdtar --use-compress-program=zstdmt -cf /home/$USERNAME/endeavouros-arm/test-images/enosLinuxARM-rpi-latest.tar.zst *
170-
time bsdtar -cf - * | zstd -z --rsyncable -10 -T0 -of /home/$USERNAME/pudges-place/server-images/enosARM-server-rpi-latest.tar.zst
181+
RPi4) # time bsdtar --use-compress-program=zstdmt -cf /home/$USERNAME/endeavouros-arm/test-images/enosLinuxARM-rpi4-latest.tar.zst *
182+
time bsdtar -cf - * | zstd -z --rsyncable -10 -T0 -of /home/$USERNAME/pudges-place/server-images/enosARM-server-rpi4-latest.tar.zst
171183
printf "\n${CYAN}bsdtar is finished creating the image.\nand will calculate a sha512sum${NC}\n"
172184

173185
cd $WORKDIR
174186
dir=$(pwd)
175187
cd /home/$USERNAME/pudges-place/server-images/
176-
sha512sum enosARM-server-rpi-latest.tar.zst > enosARM-server-rpi-latest.tar.zst.sha512sum
188+
sha512sum enosARM-server-rpi4-latest.tar.zst > enosARM-server-rpi4-latest.tar.zst.sha512sum
177189
cd $dir ;;
178190
esac
179191
} # end of function _create_rootfs
@@ -185,10 +197,10 @@ _help() {
185197
printf "options:\n"
186198
printf " -h Print this Help.\n\n"
187199
printf "These options are required\n"
188-
printf " -p enter platform: rpi or odn\n"
200+
printf " -p enter platform: rpi4 or odn\n"
189201
printf " -t image type: r (for rootfs) or i (for image) \n"
190202
printf " -c create image: (y) or n\n"
191-
printf "example: sudo ./build-server-image-eos.sh -p rpi -t i -c y \n"
203+
printf "example: sudo ./build-server-image-eos.sh -p rpi4 -t i -c y \n"
192204
printf "Ensure that the directory $IMAGEDIR exists\n\n"
193205
}
194206

@@ -234,7 +246,7 @@ _read_options() {
234246
shift $((OPTIND-1))
235247

236248
case $PLAT in
237-
rpi) PLATFORM="RPi64" ;;
249+
rpi4) PLATFORM="RPi4" ;;
238250
odn) PLATFORM="OdroidN2" ;;
239251
*) PLAT1=true;;
240252
esac
@@ -258,7 +270,7 @@ _read_options() {
258270
Main() {
259271
# VARIABLES
260272
PLAT=""
261-
PLATFORM=" " # e.g. OdroidN2, RPi4b, etc.
273+
PLATFORM=" " # e.g. OdroidN2, RPi4, etc.
262274
DEVICENAME=" " # storage device name e.g. /dev/sda
263275
DEVICESIZE="1"
264276
PARTNAME1=" "
@@ -285,7 +297,7 @@ Main() {
285297

286298
_partition_format_mount # function to partition, format, and mount a uSD card or eMMC card
287299
case $PLATFORM in
288-
RPi64) _install_RPi4_image ;;
300+
RPi4) _install_RPi4_image ;;
289301
OdroidN2) _install_OdroidN2_image ;;
290302
esac
291303

@@ -298,34 +310,25 @@ Main() {
298310
esac
299311

300312
if $CREATE ; then
301-
case $TYPE in
302-
Rootfs)
303-
printf "\n${CYAN}Creating Rootfs${NC}\n"
304-
cd $WORKDIR/MP
305-
_create_rootfs
306-
printf "\n${CYAN}Created Rootfs${NC}\n" ;;
307-
Image)
308-
printf "\n${CYAN}Creating Image${NC}\n"
309-
cd $WORKDIR/MP
310-
_create_image
311-
printf "\n${CYAN}Created Image${NC}\n" ;;
312-
esac
313+
if [ "$TYPE" == "Rootfs" ]; then
314+
printf "\n\n${CYAN}Creating Rootfs${NC}\n\n"
315+
_create_rootfs
316+
printf "\n\n${CYAN}Created Rootfs${NC}\n\n"
317+
fi
313318
fi
314319

315-
# rm $WORKDIR/MP/root/type
316-
# rm $WORKDIR/test.img
317320
umount $WORKDIR/MP/boot $WORKDIR/MP
318321
rm -rf $WORKDIR/MP
319322

320323
losetup -d /dev/loop0
321324

322-
# if $CREATE ; then
323-
# if [ "$TYPE" == "Image" ]; then
324-
# printf "\n${CYAN}Creating Image${NC}\n"
325-
# _create_image
326-
# printf "\n${CYAN}Created Image${NC}\n"
327-
# fi
328-
# fi
325+
if $CREATE ; then
326+
if [ "$TYPE" == "Image" ]; then
327+
printf "\n${CYAN}Creating Image${NC}\n"
328+
_create_image
329+
printf "\n${CYAN}Created Image${NC}\n"
330+
fi
331+
fi
329332

330333
exit
331334
}

eos-ARM-server-config.sh

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -178,20 +178,10 @@ _change_user_alarm() {
178178
local tmpfile
179179

180180
printf "\n${CYAN}Delete default username (alarm) and Creating a user...${NC}"
181-
userdel -r alarm #delete the default user from the image
182-
case $INSTALLTYPE in
183-
desktop) useradd -c "$FULLNAME" -m -G users -s /bin/bash -u 1000 "$USERNAME"
184-
printf "\n${CYAN}Adding user $USERNAME to sudo wheel...${NC}"
185-
printf "$USERNAME ALL=(ALL:ALL) ALL" >> /etc/sudoers
186-
gpasswd -a $USERNAME wheel ;; # add user to group wheel
187-
server) useradd -m -G users -s /bin/bash -u 1000 "$USERNAME" ;;
188-
esac
181+
userdel -rf alarm #delete the default user from the image
182+
useradd -m -G users -s /bin/bash -u 1000 "$USERNAME"
189183
printf "\n${CYAN} Updating user password...\n\n"
190184
echo "${USERNAME}:${USERPASSWD}" | chpasswd
191-
tmpfile=/etc/lightdm/lightdm.conf
192-
if [ -f $tmpfile ]; then
193-
gpasswd -a $USERNAME lightdm
194-
fi
195185
} # End of function _change_user_alarm
196186

197187
_clean_up() {
@@ -674,7 +664,6 @@ Main() {
674664
_precheck_setup # check various conditions before continuing the script
675665
pacman-key --init
676666
pacman-key --populate archlinuxarm
677-
# pacman -Syy
678667
_find_mirrorlist
679668
_find_keyring
680669
pacman-key --lsign-key EndeavourOS
@@ -697,9 +686,13 @@ Main() {
697686
_install_ssd
698687
_completed_notification
699688
read -n1 x
700-
rm -rf /root/eos-ARM-server-config.sh
689+
systemctl disable resize-fs.service
690+
rm /etc/systemd/system/resize-fs.service
691+
rm /root/resize-fs.service
692+
rm /root/resize-fs.sh
701693
systemctl disable config-server.service
702694
rm /etc/systemd/system/config-server.service
695+
rm /root/eos-ARM-server-config.sh
703696
systemctl reboot
704697
} # end of Main
705698

n2-boot.ini

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ setenv condev "console=ttyAML0,115200n8 console=tty1"
2121
## or
2222
## Set to an empty string to let the kernel automatically
2323
## choose a resolution for you.
24-
setenv preferred_resolution "1920x1080@60"
24+
setenv preferred_resolution ""
2525

2626
## petitboot_edid
2727
## if you experience issues of display not showing any
@@ -34,7 +34,7 @@ setenv preferred_resolution "1920x1080@60"
3434
## or
3535
## Set to an empty string to use the display provided
3636
## edid information.
37-
setenv petitboot_edid "1920x1080"
37+
setenv petitboot_edid ""
3838

3939
## Uncomment to force petitboot been always set as
4040
## active to always force the edid overwrite.
@@ -60,12 +60,13 @@ setenv initrd_loadaddr "0x4080000"
6060

6161
# Load kernel, dtb and initrd
6262
load mmc ${devno}:1 ${loadaddr} /Image
63-
if test "${variant}" = "n2_plus"; then
64-
load mmc ${devno}:1 ${dtb_loadaddr} /dtbs/amlogic/meson64_odroidn2_plus.dtb
63+
if test "${variant}" = "n2-plus"; then
64+
load mmc ${devno}:1 ${dtb_loadaddr} /dtbs/amlogic/meson-g12b-odroid-n2-plus.dtb
6565
else
66-
load mmc ${devno}:1 ${dtb_loadaddr} /dtbs/amlogic/meson64_odroidn2.dtb
66+
load mmc ${devno}:1 ${dtb_loadaddr} /dtbs/amlogic/meson-g12b-odroid-n2.dtb
6767
fi
6868
load mmc ${devno}:1 ${initrd_loadaddr} /initramfs-linux.uimg
6969

7070
# boot
7171
booti ${loadaddr} ${initrd_loadaddr} ${dtb_loadaddr}
72+

0 commit comments

Comments
 (0)