Skip to content

Commit

Permalink
fixed some stuff and switched to plasma
Browse files Browse the repository at this point in the history
  • Loading branch information
lainlives committed Dec 24, 2024
1 parent 60fc9c9 commit 6a84378
Show file tree
Hide file tree
Showing 19 changed files with 211 additions and 153 deletions.
20 changes: 17 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
#!/bin/bash
# ^ To trigger highlighting on this file

# Installed username
USER=pine

# Additional packages to install
CPACK="quasselclient micro can-utils"


# These will be created, make sure they don't exist already!
# Set defaults, but allow them to be overridden
PP_IMAGE=${PP_IMAGE:-/dev/loop1}
PP_IMAGE=${PP_IMAGE:-/dev/loop2}
PP_PARTA=${PP_PARTA:-${PP_IMAGE}p1}
PP_PARTB=${PP_PARTB:-${PP_IMAGE}p2}
PP_PARTC=${PP_PARTC:-${PP_IMAGE}p3}

FED_IMAGE=${FED_IMAGE:-/dev/loop0}
FED_IMAGE=${FED_IMAGE:-/dev/loop1}
# Output file name.
OUT_NAME=${OUT_NAME:-fedora.img}

# Only needed if you want a custom file, otherwise do not change.
# FEDORA_RAW_FILE=Fedora-Minimal-Rawhide-20200302.n.1.aarch64.raw.xz
FEDORA_RAW_SOURCE=${FEDORA_RAW_SOURCE:-https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Spins/aarch64/images}
KERNEL_RAW_DIR=${KERNEL_RAW_DIR:-pp1-5.7}
KERNEL_RAW_DIR=${KERNEL_RAW_DIR:-ppp-6.12}

export CPACK
export USER
export PP_IMAGE
export PP_PARTA
export PP_PARTB
export PP_PARTC
export OUT_NAME
export FEDORA_RAW_FILE
export FEDORA_RAW_SOURCE
Expand Down
4 changes: 2 additions & 2 deletions 00-create-empty-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ then
fi

# Create this as a sparse file
echo "Creating sparse blank 6GB file called $OUT_NAME."
dd if=/dev/zero of=$OUT_NAME bs=1 count=0 seek=6G && sync
echo "Creating sparse blank 10GB file called $OUT_NAME."
dd if=/dev/zero of=$OUT_NAME bs=1 count=0 seek=10G && sync

fi
4 changes: 2 additions & 2 deletions 01-partition-drive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ then
label: dos
unit: sectors
4MiB,252MiB,
256MiB,,
11MiB,1512MiB,
1517MiB,,
EOF
infecho "Image partitioned!"

Expand Down
10 changes: 4 additions & 6 deletions 02-install-rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@ then
mount $PP_PARTB rootfs

infecho "Copying files..."
if [ ! -z "$PS1" ]; then
rsync -a --progress imgfs/* rootfs/
else
rsync -a imgfs/* rootfs/
fi
rsync -a imgfs/* rootfs/


infecho "Deleting contents of /boot..."
rm -rf rootfs/boot/*

infecho "Unmounting everything..."
sync
umount ${FED_IMAGE}p3
losetup -d ${FED_IMAGE}
umount $PP_PARTB
Expand Down
13 changes: 7 additions & 6 deletions 03-install-kernel.sh → 03-install-bootloader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
source .env

echo "===================="
echo "03-install-kernel.sh"
echo "03-install-bootloader.sh"
echo "===================="

# Functions
Expand Down Expand Up @@ -44,18 +44,19 @@ then
cd uboot

infecho "Writing bootloader..."
dd if=u-boot-sunxi-with-spl.bin of=$PP_IMAGE bs=1024 seek=8
dd if=u-boot-rockchip.bin of=$PP_IMAGE bs=1024 seek=8


infecho "Changing directory back..."
cd ../

infecho "Mounting SD card partitions..."
mkdir -p bootfs
mount $PP_PARTA bootfs

infecho "Copying boot.scr..."
cp files/boot.scr bootfs/

infecho "Repopulating /boot..."
cp -rf uboot/boot/* bootfs/
infecho "Unmounting SD card partitions..."
umount $PP_PARTA
rmdir bootfs
Expand Down
3 changes: 0 additions & 3 deletions 04-edit-fstab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ then
infecho "Fixing /etc/fstab..."
cat files/fstab > rootfs/etc/fstab

infecho "Ensuring kernel updates won't break everything..."
cat files/yum/fedora.repo > rootfs/etc/yum.repos.d/fedora.repo

infecho "Tweaking gschemas..."
mkdir -p rootfs/usr/share/glib-2.0/schemas/files/
touch rootfs/usr/share/glib-2.0/schemas/files/90_pinephone.gschema.override
Expand Down
41 changes: 37 additions & 4 deletions 05-setup-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ echo "================"
infecho () {
echo "[Info] $1"
}
errecho () {
echo "[Error] $1" 1>&2
exit 1
}

# Notify User
infecho "The env vars that will be used in this script..."
Expand Down Expand Up @@ -51,29 +55,58 @@ then
infecho "Installing qemu in rootfs..."
cp /usr/bin/qemu-aarch64-static rootfs/usr/bin
fi


echo "USER=$USER" > rootfs/root/.user
echo "CPACK=\"$CPACK\"" >> rootfs/root/.user
echo "export USER" >> rootfs/root/.user
echo "export CPACK" >> rootfs/root/.user
cp phone-scripts/* rootfs/root
{
echo '#!/bin/bash'
echo 'set -e'
echo 'echo "======================"'
echo 'echo "01-create-sudo-user.sh"'
echo 'echo "======================"'
echo 'source /root/.user'
echo '# Functions'
echo 'infecho () {'
echo ' echo "[Info] $1"'
echo '}'
echo 'infecho "Adding user $USER..."'
echo 'adduser $USER'
echo 'groupadd feedbackd'
echo 'usermod -aG wheel,video,feedbackd $USER'
echo 'bash /root/02-install-packages.sh'
echo 'rm /etc/tmp-resolv.conf'
echo 'rm /etc/resolv.conf'
} > rootfs/root/01-create-sudo-user.sh
chmod +x rootfs/root/01-create-sudo-user.sh

infecho "Copy resolv.conf /etc/tmp-resolv.conf"
cp /etc/resolv.conf rootfs/etc/tmp-resolv.conf

if [[ $HOSTARCH != "aarch64" ]]; then
infecho "Chrooting with qemu into rootfs..."
systemd-nspawn -D rootfs qemu-aarch64-static /bin/bash /root/all.sh

systemd-nspawn -D rootfs qemu-aarch64-static /bin/bash /root/01-create-sudo-user.sh
infecho "KILLING ALL QEMU PROCESSES, MAKE SURE YOU HAVE NO MORE RUNNING!"
killall -9 /usr/bin/qemu-aarch64-static || true

infecho "Removing qemu binary, so it doesn't stay in image"
rm -f rootfs/usr/bin/qemu-aarch64-static
else
infecho "Chrooting into rootfs..."
chroot rootfs /bin/bash /root/all.sh
chroot rootfs /bin/bash /root/01-create-sudo-user.sh
fi

infecho "Unmounting rootfs..."

rm -f rootfs/root/*
sleep 3
umount $PP_PARTA
umount $PP_PARTB
rmdir rootfs
fi
infecho "COMPLETE! Flashable image is at: $PWD/fedora.img"

exit 0
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Fedora_logo.svg/200px-Fedora_logo.svg.png" width="25" height="25"> PinePhone Fedora Setup

A collection of scripts that correctly sets up Fedora to run off your PinePhone SD card. Soon to be part of the Fedora Mobility SIG.

## **🚨🚨🚨 WARNING! 🚨🚨🚨**
This is a **barely tested** collection of scripts written by someone who has never written a bash script for other people to use! It involves the **dd** command and **sudo**. This is **VERY DANGEROUS** - please do not run it unless you have read and fully understood what it will do. Better yet, read the scripts to learn how to install the image manually.

For prebuilt images, see the [releases](https://github.com/nikhiljha/pp-fedora-sdsetup/releases) page. All images after Nov 2020 were built by @Torbuntu.
These scripts generate a 10gb fedora rawhide image with far too many plasma-desktop and plasma-mobile packages.

## Dependencies

Expand Down
2 changes: 1 addition & 1 deletion all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ bash 00-selftest.sh
bash 00-create-empty-image.sh
bash 01-partition-drive.sh
bash 02-install-rootfs.sh
bash 03-install-kernel.sh
bash 03-install-bootloader.sh
bash 04-edit-fstab.sh
bash 05-setup-user.sh
5 changes: 3 additions & 2 deletions download-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
# Download kernel
wget https://xff.cz/kernels/5.16/pp.tar.gz -O pp.tar.gz
tar xf pp.tar.gz
# wget https://xff.cz/kernels/6.12/ppp.tar.gz -O ppp.tar.gz
# tar xf ppp.tar.gz

# Get latest rawhide from repo when not set in .env
if [ -z "$FEDORA_RAW_FILE" ]
then
echo "Searching for latest Fedora Rawhide..."
FEDORA_RAW_VER=$(wget -q $FEDORA_RAW_SOURCE -O - | grep -Po '(?<=Fedora-Minimal-Rawhide-).*?(?=.aarch64)' | head -n 1)

if [ ! -z "$FEDORA_RAW_VER" ]
then
echo "Downloading latest Fedora version: $FEDORA_RAW_VER"
Expand Down
37 changes: 0 additions & 37 deletions files/yum/fedora.repo

This file was deleted.

18 changes: 0 additions & 18 deletions phone-scripts/01-create-sudo-user.sh

This file was deleted.

Loading

0 comments on commit 6a84378

Please sign in to comment.