From b7588a01e354d1412c6c517feb0362a6a9b851ef Mon Sep 17 00:00:00 2001 From: rvstry <68084797+rvstry@users.noreply.github.com> Date: Fri, 3 Dec 2021 14:23:33 +0000 Subject: [PATCH 1/8] fs: build less broken Fedora images --- fs/build | 26 ++++++++++++++++++++++++++ fs/fedora/install-to-emmc | 1 + 2 files changed, 27 insertions(+) create mode 100644 fs/fedora/install-to-emmc diff --git a/fs/build b/fs/build index 642cfe54..6f3dd8d1 100755 --- a/fs/build +++ b/fs/build @@ -83,6 +83,32 @@ case "$ROOTFS" in chroot root/ $qemu /bin/apt install -y vim network-manager debootstrap parted f2fs-tools libudev-dev build-essential git firmware-ath9k-htc kmscube weston [ $BOOTFW = depthcharge ] && chroot root/ $qemu /bin/apt install -y vboot-utils ;; + fedora) + echo "Installing Fedora Linux" + case "$ARCH_UNAME" in # TODO: option to choose Fedora release in config + arm) # FIXME: wrong processor + IMAGE_URL="https://download.fedoraproject.org/pub/fedora/linux/releases/35/Spins/armhfp/images/Fedora-Minimal-35-1.2.armhfp.raw.xz" + ;; + aarch64) + IMAGE_URL="https://download.fedoraproject.org/pub/fedora-secondary/releases/35/Spins/aarch64/images/Fedora-Minimal-35-1.2.aarch64.raw.xz" + ;; + esac + if [ ! -f "Fedora-$ARCH_UNAME.ext4" ]; then + # rootfs is 3rd partiton of raw image + wget $IMAGE_URL -O fedora-$ARCH_UNAME.raw.xz + xz -vdk fedora-$ARCH_UNAME.raw.xz + IMAGE_LOOP=$(losetup -f -P fedora*.raw --show) + dd if=${IMAGE_LOOP}p3 of=Fedora-$ARCH_UNAME.ext4 status=progress + losetup -d $IMAGE_LOOP + fi + # TODO: write rootfs image to rootpart instead of copying over files + mkdir -p fedorarootfsimg + mount Fedora-$ARCH_UNAME.ext4 fedorarootfsimg/ + cp -a fedorarootfsimg/* $CADMIUMROOT/tmp/root + umount fedorarootfsimg + # FIXME: boots to emergency shell + # TODO: add rootpart uuid to the rootfs fstab, remove boot and efi + ;; # let's explain this: when void is set, $V is set to -v, so it does 'grep -v musl', printing link without musl # when $V is not set, grep is 'grep musl', printing only link with musl void) diff --git a/fs/fedora/install-to-emmc b/fs/fedora/install-to-emmc new file mode 100644 index 00000000..0fb2d2b7 --- /dev/null +++ b/fs/fedora/install-to-emmc @@ -0,0 +1 @@ +## TODO: install to emmc support \ No newline at end of file From bcbd4bcbca11daf41b1cdb017975456314dd255d Mon Sep 17 00:00:00 2001 From: rvstry <68084797+rvstry@users.noreply.github.com> Date: Fri, 3 Dec 2021 20:10:09 +0000 Subject: [PATCH 2/8] fs: fix Fedora fstab --- fs/build | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/build b/fs/build index 6f3dd8d1..84230a53 100755 --- a/fs/build +++ b/fs/build @@ -105,9 +105,8 @@ case "$ROOTFS" in mkdir -p fedorarootfsimg mount Fedora-$ARCH_UNAME.ext4 fedorarootfsimg/ cp -a fedorarootfsimg/* $CADMIUMROOT/tmp/root - umount fedorarootfsimg - # FIXME: boots to emergency shell - # TODO: add rootpart uuid to the rootfs fstab, remove boot and efi + for x in {1..3}; do sed -i '$d' root/etc/fstab; sleep 1; done # remove / , /boot, /boot/efi from fstab + umount fedorarootfsimg/ ;; # let's explain this: when void is set, $V is set to -v, so it does 'grep -v musl', printing link without musl # when $V is not set, grep is 'grep musl', printing only link with musl From 00cc61f662e9fa17ad5c5c48c98616f7004c35b6 Mon Sep 17 00:00:00 2001 From: rvstry <68084797+rvstry@users.noreply.github.com> Date: Fri, 3 Dec 2021 20:30:03 +0000 Subject: [PATCH 3/8] treewide: add $ARCH_FED --- HACKING.md | 1 + baseboard/gru/boardinfo | 1 + baseboard/kukui/boardinfo | 1 + baseboard/lemote2f/boardinfo | 1 + baseboard/trogdor/boardinfo | 1 + baseboard/veyron/boardinfo | 1 + fs/build | 14 +++++++------- 7 files changed, 13 insertions(+), 7 deletions(-) diff --git a/HACKING.md b/HACKING.md index 0da872d0..97a165e1 100644 --- a/HACKING.md +++ b/HACKING.md @@ -30,6 +30,7 @@ - ```ARCH``` uses kernel's naming, ```arm```, ```arm64``` etc. - ```ARCH_UNAME``` is what appears in uname -m, ```armv7l```, ```aarch64``` etc. - ```ARCH_DEB``` is whatever debian calls the architecture of device, ```armhf```, ```arm64``` +- ```ARCH_FED``` is what fedora calls the architecture of device, ```armhfp```, ```aarch64``` - YES ALL THIS ARCH STUFF IS A GIANT MESS - ```CROSS_COMPILE``` is self-explanatory - ```SOC``` - self explanatory diff --git a/baseboard/gru/boardinfo b/baseboard/gru/boardinfo index 5bec526f..80fecd04 100644 --- a/baseboard/gru/boardinfo +++ b/baseboard/gru/boardinfo @@ -4,6 +4,7 @@ export ARCH=arm64 export ARCH_UNAME=aarch64 export ARCH_DEB=arm64 +export ARCH_FED=aarch64 export CROSS_COMPILE=aarch64-linux-gnu- export EMMC_OFFSET=0 diff --git a/baseboard/kukui/boardinfo b/baseboard/kukui/boardinfo index ceaf7a4d..9ebf34ca 100644 --- a/baseboard/kukui/boardinfo +++ b/baseboard/kukui/boardinfo @@ -4,6 +4,7 @@ export ARCH=arm64 export ARCH_UNAME=aarch64 export ARCH_DEB=arm64 +export ARCH_FED=aarch64 export CROSS_COMPILE=aarch64-linux-gnu- export EMMC_OFFSET=0 diff --git a/baseboard/lemote2f/boardinfo b/baseboard/lemote2f/boardinfo index f9f05049..c7ee5c78 100644 --- a/baseboard/lemote2f/boardinfo +++ b/baseboard/lemote2f/boardinfo @@ -4,6 +4,7 @@ export ARCH=mips export ARCH_UNAME=mips64el export ARCH_DEB=mips64el +export ARCH_FED=0 export CROSS_COMPILE=mips64el-linux-gnuabi64- export EMMC_OFFSET=0 diff --git a/baseboard/trogdor/boardinfo b/baseboard/trogdor/boardinfo index 4aa4da88..f2b225dd 100644 --- a/baseboard/trogdor/boardinfo +++ b/baseboard/trogdor/boardinfo @@ -4,6 +4,7 @@ export ARCH=arm64 export ARCH_UNAME=aarch64 export ARCH_DEB=arm64 +export ARCH_FED=aarch64 export CROSS_COMPILE=aarch64-linux-gnu- export EMMC_OFFSET=0 diff --git a/baseboard/veyron/boardinfo b/baseboard/veyron/boardinfo index 2c4bd69b..ac7f2327 100644 --- a/baseboard/veyron/boardinfo +++ b/baseboard/veyron/boardinfo @@ -4,6 +4,7 @@ export ARCH=arm export ARCH_UNAME=armv7l export ARCH_DEB=armhf +export ARCH_FED=armhfp export CROSS_COMPILE=arm-linux-gnueabihf- export EMMC_OFFSET=16384 diff --git a/fs/build b/fs/build index 84230a53..c6ef7217 100755 --- a/fs/build +++ b/fs/build @@ -85,25 +85,25 @@ case "$ROOTFS" in ;; fedora) echo "Installing Fedora Linux" - case "$ARCH_UNAME" in # TODO: option to choose Fedora release in config - arm) # FIXME: wrong processor + case "$ARCH_FED" in # TODO: option to choose Fedora release in config + armhfp) IMAGE_URL="https://download.fedoraproject.org/pub/fedora/linux/releases/35/Spins/armhfp/images/Fedora-Minimal-35-1.2.armhfp.raw.xz" ;; aarch64) IMAGE_URL="https://download.fedoraproject.org/pub/fedora-secondary/releases/35/Spins/aarch64/images/Fedora-Minimal-35-1.2.aarch64.raw.xz" ;; esac - if [ ! -f "Fedora-$ARCH_UNAME.ext4" ]; then + if [ ! -f "Fedora-$ARCH_FED.ext4" ]; then # rootfs is 3rd partiton of raw image - wget $IMAGE_URL -O fedora-$ARCH_UNAME.raw.xz - xz -vdk fedora-$ARCH_UNAME.raw.xz + wget $IMAGE_URL -O fedora-$ARCH_FED.raw.xz + xz -vdk fedora-$ARCH_FED.raw.xz IMAGE_LOOP=$(losetup -f -P fedora*.raw --show) - dd if=${IMAGE_LOOP}p3 of=Fedora-$ARCH_UNAME.ext4 status=progress + dd if=${IMAGE_LOOP}p3 of=Fedora-$ARCH_FED.ext4 status=progress losetup -d $IMAGE_LOOP fi # TODO: write rootfs image to rootpart instead of copying over files mkdir -p fedorarootfsimg - mount Fedora-$ARCH_UNAME.ext4 fedorarootfsimg/ + mount Fedora-$ARCH_FED.ext4 fedorarootfsimg/ cp -a fedorarootfsimg/* $CADMIUMROOT/tmp/root for x in {1..3}; do sed -i '$d' root/etc/fstab; sleep 1; done # remove / , /boot, /boot/efi from fstab umount fedorarootfsimg/ From 410621edbaa192ea635a3410e5f697f46d283076 Mon Sep 17 00:00:00 2001 From: rvstry <68084797+rvstry@users.noreply.github.com> Date: Fri, 3 Dec 2021 23:11:23 +0000 Subject: [PATCH 4/8] fs: rename Fedora emmc middle --- fs/fedora/install-to-emmc | 1 - fs/fedora/install-to-emmc-middle | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 fs/fedora/install-to-emmc create mode 100644 fs/fedora/install-to-emmc-middle diff --git a/fs/fedora/install-to-emmc b/fs/fedora/install-to-emmc deleted file mode 100644 index 0fb2d2b7..00000000 --- a/fs/fedora/install-to-emmc +++ /dev/null @@ -1 +0,0 @@ -## TODO: install to emmc support \ No newline at end of file diff --git a/fs/fedora/install-to-emmc-middle b/fs/fedora/install-to-emmc-middle new file mode 100644 index 00000000..7442433c --- /dev/null +++ b/fs/fedora/install-to-emmc-middle @@ -0,0 +1 @@ +## TODO: install to emmc support From a1b511e45ec6dbbb3f3ecca72cd41084c6fd252b Mon Sep 17 00:00:00 2001 From: rvstry <68084797+rvstry@users.noreply.github.com> Date: Sat, 4 Dec 2021 10:15:04 +0000 Subject: [PATCH 5/8] fs: waste less storage building Fedora --- fs/build | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/fs/build b/fs/build index c6ef7217..d80761f9 100755 --- a/fs/build +++ b/fs/build @@ -93,20 +93,18 @@ case "$ROOTFS" in IMAGE_URL="https://download.fedoraproject.org/pub/fedora-secondary/releases/35/Spins/aarch64/images/Fedora-Minimal-35-1.2.aarch64.raw.xz" ;; esac - if [ ! -f "Fedora-$ARCH_FED.ext4" ]; then - # rootfs is 3rd partiton of raw image + if [ ! -f "fedora-$ARCH_FED.raw" ]; then wget $IMAGE_URL -O fedora-$ARCH_FED.raw.xz - xz -vdk fedora-$ARCH_FED.raw.xz - IMAGE_LOOP=$(losetup -f -P fedora*.raw --show) - dd if=${IMAGE_LOOP}p3 of=Fedora-$ARCH_FED.ext4 status=progress - losetup -d $IMAGE_LOOP + xz -vd fedora-$ARCH_FED.raw.xz fi - # TODO: write rootfs image to rootpart instead of copying over files + # rootfs is 3rd partiton of raw image + IMAGE_LOOP=$(losetup -f -P fedora-$ARCH_FED.raw --show) mkdir -p fedorarootfsimg - mount Fedora-$ARCH_FED.ext4 fedorarootfsimg/ + mount ${IMAGE_LOOP}p3 fedorarootfsimg/ cp -a fedorarootfsimg/* $CADMIUMROOT/tmp/root for x in {1..3}; do sed -i '$d' root/etc/fstab; sleep 1; done # remove / , /boot, /boot/efi from fstab umount fedorarootfsimg/ + losetup -d $IMAGE_LOOP ;; # let's explain this: when void is set, $V is set to -v, so it does 'grep -v musl', printing link without musl # when $V is not set, grep is 'grep musl', printing only link with musl From 876ede3b623ecb3a5b3731b1ae9ae6ea0f518744 Mon Sep 17 00:00:00 2001 From: rvstry <68084797+rvstry@users.noreply.github.com> Date: Fri, 10 Dec 2021 18:46:00 +0000 Subject: [PATCH 6/8] fs: add Fedora eMMC installs + use rsync --- fs/build | 23 ++++++++++++----- fs/fedora/install-to-emmc-middle | 17 ++++++++++++- fs/install-to-emmc-begin | 14 ++++------- fs/install-to-emmc-end | 43 +++++++++++++++++++++----------- 4 files changed, 66 insertions(+), 31 deletions(-) diff --git a/fs/build b/fs/build index d80761f9..f6278867 100755 --- a/fs/build +++ b/fs/build @@ -92,19 +92,30 @@ case "$ROOTFS" in aarch64) IMAGE_URL="https://download.fedoraproject.org/pub/fedora-secondary/releases/35/Spins/aarch64/images/Fedora-Minimal-35-1.2.aarch64.raw.xz" ;; + 0) + echo "Fedora is not supported for $SOC devices" + return 1 esac - if [ ! -f "fedora-$ARCH_FED.raw" ]; then + if [ ! -f "fedora-$ARCH_FED.rootfs" ]; then wget $IMAGE_URL -O fedora-$ARCH_FED.raw.xz xz -vd fedora-$ARCH_FED.raw.xz + IMAGE_LOOP=$(losetup -f -P fedora-$ARCH_FED.raw --show) + dd if=${IMAGE_LOOP}p3 of=fedora-$ARCH_FED.rootfs + losetup -d $IMAGE_LOOP fi # rootfs is 3rd partiton of raw image - IMAGE_LOOP=$(losetup -f -P fedora-$ARCH_FED.raw --show) mkdir -p fedorarootfsimg - mount ${IMAGE_LOOP}p3 fedorarootfsimg/ - cp -a fedorarootfsimg/* $CADMIUMROOT/tmp/root + mount fedora-$ARCH_FED.rootfs fedorarootfsimg/ + rsync -aHAX fedorarootfsimg/* $CADMIUMROOT/tmp/root for x in {1..3}; do sed -i '$d' root/etc/fstab; sleep 1; done # remove / , /boot, /boot/efi from fstab + cp fedora-$ARCH_FED.rootfs root/fedora-$ARCH_FED.rootfs + # disable inital-setup and unlock root account + unlink root/etc/systemd/system/graphical.target.wants/initial-setup.service + unlink root/etc/systemd/system/multi-user.target.wants/initial-setup.service + chroot root/ $qemu /bin/passwd -f -u root + # FIXME: installing NetworkManager-tui breaks wifi?? use nmcli in the meantime + dnf install -y --installroot=$CADMIUMROOT/tmp/root/ --forcearch=aarch64 --releasever=35 vboot-utils parted f2fs-tools make git rsync umount fedorarootfsimg/ - losetup -d $IMAGE_LOOP ;; # let's explain this: when void is set, $V is set to -v, so it does 'grep -v musl', printing link without musl # when $V is not set, grep is 'grep musl', printing only link with musl @@ -136,7 +147,7 @@ case "$ROOTFS" in esac # remove root password, this is install medium so it's ok, not needed in ubports -[ ! "$ROOTFS" = "ubports" ] && chroot root/ $qemu /bin/passwd -d root +[ ! "$ROOTFS" = "ubports" ] && chroot root/ $qemu /bin/passwd -f -d root # workaround bad touchpad experience on certain boards mkdir -p $CADMIUMROOT/tmp/root/etc/libinput diff --git a/fs/fedora/install-to-emmc-middle b/fs/fedora/install-to-emmc-middle index 7442433c..72faef60 100644 --- a/fs/fedora/install-to-emmc-middle +++ b/fs/fedora/install-to-emmc-middle @@ -1 +1,16 @@ -## TODO: install to emmc support +# start of install-to-emmc-middle + +export SYSTEMD=1 +export EUDEV=0 +export SKIP_CD_USER_SETUP=1 + +mkdir -p fedorarootfsimg +mount /fedora-$ARCH_FED.rootfs fedorarootfsimg/ + +rsync -aHAX fedorarootfsimg/* /mnt/ +for x in {1..3}; do sed -i '$d' /mnt/etc/fstab; sleep 1; done # remove / , /boot, /boot/efi from fstab + +umount fedorarootfsimg +rm -rf fedorarootfsimg + +# end of install-to-emmc-middle diff --git a/fs/install-to-emmc-begin b/fs/install-to-emmc-begin index d49b8f94..c909b27d 100755 --- a/fs/install-to-emmc-begin +++ b/fs/install-to-emmc-begin @@ -18,9 +18,12 @@ if [ "$BASEBOARD" = "trogdor" ]; then fi # we need internet, TODO: make this run on voidlinux +# FIXME: installing NetworkManager-tui breaks wifi on the Fedora installer nmcli device wifi rescan -sleep 4 # wait for it to show up -nmtui connect +nmcli device wifi list +read -p "Enter SSID: "; SSID=$REPLY +read -p "Enter password: "; WIFI_PASS=$REPLY +nmcli device wifi connect $SSID password $WIFI_PASS # a fancy hack MMCDEV=$(ls /dev/mmcblk* | grep -F boot0 | sed 's/boot0//') @@ -106,13 +109,6 @@ fi mount $ROOTPART /mnt -mkdir -p /mnt/lib/firmware/ -cp -r /lib/firmware/* /mnt/lib/firmware/ - -# copy modules over -mkdir -p /mnt/lib/modules/$(uname -r)/ -cp -r /lib/modules/$(uname -r)/* /mnt/lib/modules/$(uname -r)/ - # copy kernel from usb pendrive/hdd to internal emmc dd if=/dev/zero of=$KERNPART >/dev/null 2>&1 || true diff --git a/fs/install-to-emmc-end b/fs/install-to-emmc-end index 2945f8b9..a97e9dde 100755 --- a/fs/install-to-emmc-end +++ b/fs/install-to-emmc-end @@ -2,20 +2,32 @@ mount proc /mnt/proc -t proc # just in case something((gdm)) wants it -echo "Enter root password:" -until chroot /mnt passwd; do +if [ ! "$SKIP_CD_USER_SETUP" = "1" ]; then + + echo "Enter root password:" -done + until chroot /mnt passwd; do + echo "Enter root password:" + done -read -p "Enter username, no spaces or big letters: " -chroot /mnt useradd -G sudo,video,audio,render -s /bin/bash -m $REPLY + read -p "Enter username, no spaces or big letters: " + chroot /mnt useradd -G sudo,video,audio,render -s /bin/bash -m $REPLY -echo "Enter user password:" -until chroot /mnt passwd $REPLY; do echo "Enter user password:" -done + until chroot /mnt passwd $REPLY; do + echo "Enter user password:" + done + + export USERNAME=$REPLY + +fi + +mkdir -p /mnt/lib/firmware/ +cp -r /lib/firmware/* /mnt/lib/firmware/ -export USERNAME=$REPLY +# copy modules over +mkdir -p /mnt/lib/modules/$(uname -r)/ +cp -r /lib/modules/$(uname -r)/* /mnt/lib/modules/$(uname -r)/ # default libinput config for touchpad is bad # let's override it @@ -42,12 +54,12 @@ fi cp -r /CdFiles /mnt/CdFiles if [ $BASEBOARD = trogdor ]; then - chroot /mnt make -C /CdFiles/qmic clean - chroot /mnt make -C /CdFiles/qrtr clean - chroot /mnt make -C /CdFiles/rmtfs clean - chroot /mnt make -C /CdFiles/qmic prefix=/usr install - chroot /mnt make -C /CdFiles/qrtr prefix=/usr install - chroot /mnt make -C /CdFiles/rmtfs prefix=/usr install + make -C /mnt/CdFiles/qmic clean + make -C /mnt/CdFiles/qrtr clean + make -C /mnt/CdFiles/rmtfs clean + make -C /CdFiles/qmic prefix=/mnt/usr install + make -C /CdFiles/qrtr prefix=/mnt/usr install + make -C /CdFiles/rmtfs prefix=/mnt/usr install chroot /mnt systemctl enable rmtfs fi @@ -62,6 +74,7 @@ export INST_EMMC=1 source ~/ui/install # copy over ucm files +mkdir -p /mnt/usr/share/alsa/ucm2/ cp -r /ucm/* /mnt/usr/share/alsa/ucm2/ From 17e43c8173fb1c8cc7090361e400dd421714d96e Mon Sep 17 00:00:00 2001 From: rvstry <68084797+rvstry@users.noreply.github.com> Date: Fri, 10 Dec 2021 19:41:16 +0000 Subject: [PATCH 7/8] README: add Fedora dependencies --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7003ea5f..541e3e61 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Once you have this out, continue with instructions: - Recent Linux distribution - Binfmt when Debian rootfs is used - ```debootstrap``` when Debian rootfs is used +- ```dnf``` when Fedora rootfs is used (add repos and GPG keys with ```fedora-repos``` and ```fedora-gpg-keys``` RPMs) - ```qemu-user-static``` when build machine can't run binaries for target machine - ```vboot-utils u-boot-tools``` (vbutil_kernel, cgpt and mkimage) to pack kernel into format understandable by depthcharge - ```gcc-aarch64-linux-gnu``` for compiling to ARM64 or ```gcc-arm-linux-gnueabihf``` for compiling to ARMv7 From 25ca92cba8f0e0abd9b211e8d4358a7f966f7631 Mon Sep 17 00:00:00 2001 From: rvstry <68084797+rvstry@users.noreply.github.com> Date: Fri, 10 Dec 2021 19:41:38 +0000 Subject: [PATCH 8/8] config: add fedora --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index aa61216c..98d8039a 100644 --- a/config +++ b/config @@ -11,7 +11,7 @@ else fi # RootFS type -# One of: debian, void, void-musl, ubuntu +# One of: debian, fedora, void, void-musl, ubuntu ROOTFS=debian # FS type