Fix invalid /etc/apk/repositories entry on device (#1189)

It used to have an entry for /mnt/pmbootstrap-packages, which only
makes sense while working on the chroot with pmbootstrap. After the
installation on the device, there's no repo in that path.
Furthermore, empty lines were added to the recovery installer script
for readability (thanks @ata2001!)
This commit is contained in:
Oliver Smith 2018-02-01 22:44:20 +00:00 committed by GitHub
parent e8c27795a8
commit 5eb75afc08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 10 deletions

View File

@ -1,5 +1,5 @@
pkgname=postmarketos-android-recovery-installer
pkgver=0.1.3
pkgver=0.1.4
pkgrel=0
pkgdesc="TWRP compatible postmarketOS installer script"
url="https://github.com/postmarketOS"
@ -29,6 +29,6 @@ package() {
sha512sums="f02e67d26f4f977c5098ff6eee51b53ec962982c41b8b33c1a206c218c483bd20f782c06622cf8d724a9a1cdb5b9cc1b76d3bf32e562c9b558747ca3f3408ffd build_zip.sh
6390fc1b1c7dc8e917bb675d2e59e479782ac7754e97c4781866360ff704afe2d04f173a0ac74e3129db45328fab4b6b77a8717ee2e17c6ff79febadaa8ea034 update-binary
f19c15fd99cc806d088ddf9c954111e48635f971ca500beeaa4893eb25d19fe0601210a57e9ab1a1dc7a6d79a3154765e696ee3329bbb1875b6d6df36a7b3fb3 pmos_chroot
895e5790924cf9deb74517627c78618eda5f0d53b5aa494b16f679c84cf414d6a2ec6847ef93158a5afdd70c5e2b053b3d4cd47047bab1c21790da08a4b45232 pmos_install
b932668aea823a98b7f7f3811413b1116e6444166a57f664f9b28687288e3cd39c31f5b272a632f30165b06974721a1bc880cbf7024ba091e8739ef30fcc2c6c pmos_install
36d8ca5ae092f8de0a9e2658581d3d1f83483b5076446aebaf5e1ab377e49615c31b81c00a23bc74d569de12a73977291c9a73e4f19b2faa694d981010c3eb35 pmos_install_functions
c6355b6d823dac883e1a352f59a9a2199e2934d78a73df72dc3c4fc14ef93765a15179203d4a8a2ca0d841b63cd4c25c4689b63c8cf4d4da2bcec1f8ff76bff5 pmos_setpw"

View File

@ -58,13 +58,17 @@ mountpoint -q /mnt/pmOS && umount -R /mnt/pmOS
ui_print "Symlinking block devices..."
ln -sf /dev/block/* /dev/
ui_print "Extracting partition table..."
extract_partition_table
ui_print "Unmounting /$INSTALL_PARTITION..."
umount_install_partition
ui_print "Creating partition table on $INSTALL_DEVICE..."
# parted returns nonzero even when command executed successfully
partition_install_device || :
ui_print "Creating mountpoint..."
mkdir -p /mnt/pmOS
@ -72,22 +76,29 @@ if [ "$FDE" = "true" ]
then
ui_print "Generating temporary keyfile with random data..."
dd bs=512 count=4 if=/dev/urandom of=/lukskey
ui_print "Initializing LUKS device..."
cryptsetup luksFormat --use-urandom -c "$CIPHER" -q "$ROOT_PARTITION" /lukskey
ui_print "Opening LUKS partition..."
cryptsetup luksOpen -d /lukskey "$ROOT_PARTITION" pm_crypt
ui_print "Formatting LUKS partition..."
mkfs.ext4 -L 'pmOS_root' /dev/mapper/pm_crypt
ui_print "Mounting LUKS partition..."
mount -t ext4 -rw /dev/mapper/pm_crypt /mnt/pmOS
else
ui_print "Formatting root partition..."
mkfs.ext4 -L 'pmOS_root' "$ROOT_PARTITION"
ui_print "Mounting root partition..."
mount -t ext4 -rw "$ROOT_PARTITION" /mnt/pmOS
fi
ui_print "Formatting pmOS_boot..."
mkfs.ext2 -q -L 'pmOS_boot' "$PMOS_BOOT"
ui_print "Mounting pmOS_boot..."
mkdir /mnt/pmOS/boot
mount -t ext2 -rw "$PMOS_BOOT" /mnt/pmOS/boot || {
@ -96,19 +107,27 @@ mount -t ext2 -rw "$PMOS_BOOT" /mnt/pmOS/boot || {
mkfs.ext4 -L 'pmOS_boot' "$PMOS_BOOT"
mount -t ext4 -rw "$PMOS_BOOT" /mnt/pmOS/boot
}
ui_print "Installing rootfs..."
unzip -p pmos.zip rootfs.tar.gz | tar -xz -C /mnt/pmOS
ui_print "Creating home folder..."
mkdir /mnt/pmOS/home
user="$(awk -F ':' '$3 == "1000" {print $1}' /mnt/pmOS/etc/passwd)"
cp -a /mnt/pmOS/etc/skel /mnt/pmOS/home/"$user"
chown -R 1000 /mnt/pmOS/home/"$user"
ui_print "Configuring apk..."
sed -i '/\/mnt\/pmbootstrap-packages/d' /mnt/pmOS/etc/apk/repositories
# Flash kernel
if [ "$FLASH_KERNEL" = "true" ]
then
if [ "$ISOREC" = "true" ]
then
ui_print "Flashing kernel..."
dd if=/mnt/pmOS/boot/vmlinuz-"$FLAVOR" of="$KERNEL_PARTITION"
ui_print "Flashing initfs..."
gunzip -c /mnt/pmOS/boot/initramfs-"$FLAVOR" | lzop \
> "$INITFS_PARTITION"
@ -117,9 +136,11 @@ then
dd if=/mnt/pmOS/boot/boot.img-"$FLAVOR" of="$BOOT_PARTITION"
fi
fi
if [ "$FDE" = "true" ]
then
ui_print "Do not forget to add a password to the LUKS partition!"
ui_print "Run the command: pmos_setpw from the terminal/adb shell!"
fi
ui_print "Installation done."

View File

@ -100,20 +100,31 @@ def copy_files_from_chroot(args):
working_dir=mountpoint)
def copy_files_other(args):
def create_home_from_skel(args):
"""
Copy over keys, create /home/{user}.
Create /home/{user} from /etc/skel
"""
rootfs = args.work + "/chroot_native/mnt/install"
homedir = rootfs + "/home/" + args.user
pmb.helpers.run.root(args, ["mkdir", rootfs + "/home"])
pmb.helpers.run.root(args, ["cp", "-a", rootfs + "/etc/skel", homedir])
pmb.helpers.run.root(args, ["chown", "-R", "1000", homedir])
def configure_apk(args):
"""
Copies over all keys used locally to compile packages, and disables the
/mnt/pmbootstrap-packages repository.
"""
# Copy over keys
rootfs = args.work + "/chroot_native/mnt/install"
for key in glob.glob(args.work + "/config_apk_keys/*.pub"):
pmb.helpers.run.root(args, ["cp", key, rootfs + "/etc/apk/keys/"])
# Create /home/{user} from /etc/skel
homedir = rootfs + "/home/" + args.user
pmb.helpers.run.root(args, ["mkdir", rootfs + "/home"])
pmb.helpers.run.root(args, ["cp", "-a", rootfs + "/etc/skel", homedir])
pmb.helpers.run.root(args, ["chown", "-R", "1000", homedir])
# Disable pmbootstrap repository
pmb.helpers.run.root(args, ["sed", "-i", "/\/mnt\/pmbootstrap-packages/d",
rootfs + "/etc/apk/repositories"])
pmb.helpers.run.user(args, ["cat", rootfs + "/etc/apk/repositories"])
def set_user(args):
@ -223,7 +234,8 @@ def install_system_image(args):
# Just copy all the files
logging.info("*** (4/5) FILL INSTALL BLOCKDEVICE ***")
copy_files_from_chroot(args)
copy_files_other(args)
create_home_from_skel(args)
configure_apk(args)
# If user has a ssh pubkey, offer to copy it to device
copy_ssh_key(args)