2017-11-16 22:20:57 +00:00
|
|
|
#!/sbin/sh
|
2017-12-22 18:39:44 +00:00
|
|
|
exec > /tmp/postmarketos/pmos.log 2>&1
|
2017-11-16 22:20:57 +00:00
|
|
|
set -ex
|
|
|
|
|
|
|
|
export CHROOT='/tmp/postmarketos/chroot'
|
|
|
|
|
|
|
|
# Extract chroot
|
|
|
|
unzip -o "$ZIP" chroot/* -d /tmp/postmarketos
|
|
|
|
|
|
|
|
# shellcheck source=/dev/null
|
|
|
|
. "$CHROOT"/install_options
|
|
|
|
if [ "$FDE" = 'true' ]
|
|
|
|
then
|
|
|
|
# Install password setting script
|
|
|
|
{
|
|
|
|
echo '#!/sbin/sh'
|
|
|
|
echo "chroot $CHROOT /bin/pmos_setpw"
|
|
|
|
} > /sbin/pmos_setpw
|
|
|
|
chmod 755 /sbin/pmos_setpw
|
|
|
|
fi
|
|
|
|
|
2017-12-22 18:39:44 +00:00
|
|
|
# Mount the logfile and pmos.zip so we can access it inside the chroot
|
|
|
|
for file in "pmos.log" "pmos.zip"
|
|
|
|
do
|
|
|
|
{ umount "$CHROOT"/"$file" ; rm "$CHROOT"/"$file" ; } || :
|
|
|
|
touch "$CHROOT"/"$file"
|
|
|
|
done
|
|
|
|
mount --bind /tmp/postmarketos/pmos.log "$CHROOT"/pmos.log
|
2017-11-16 22:20:57 +00:00
|
|
|
mount --bind "$ZIP" "$CHROOT"/pmos.zip
|
|
|
|
|
2018-08-16 21:21:45 +00:00
|
|
|
fstab_recovery="recovery.fstab"
|
|
|
|
# TWRP can use twrp.fstab instead of recovery.fstab (device specific)
|
|
|
|
# This check exists to support both formats.
|
|
|
|
if [ ! -e "/etc/"$fstab_recovery ]; then
|
|
|
|
fstab_recovery="twrp.fstab"
|
|
|
|
fi
|
|
|
|
|
2017-11-16 22:20:57 +00:00
|
|
|
# Create copy of fstab file provided by the recovery
|
2018-08-16 21:21:45 +00:00
|
|
|
if ! cp /etc/$fstab_recovery "$CHROOT"/$fstab_recovery; then
|
|
|
|
echo "Error copying $fstab_recovery , exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-11-16 22:20:57 +00:00
|
|
|
|
|
|
|
# Mount necessary filesystems for the chroot
|
|
|
|
for mountpoint in "/dev" "/proc" "/sys"
|
|
|
|
do
|
|
|
|
mkdir -p "$CHROOT""$mountpoint"
|
|
|
|
mount --bind "$mountpoint" "$CHROOT""$mountpoint"
|
|
|
|
done
|
|
|
|
|
2018-10-19 16:10:32 +00:00
|
|
|
# Copy Mediatek /emmc@partitionname symlinks to the chroot
|
|
|
|
cp -d /emmc@* "$CHROOT" || true
|
|
|
|
|
2017-11-16 22:20:57 +00:00
|
|
|
# Set permissions and start the installation script
|
|
|
|
chmod 755 "$CHROOT"/bin/*
|
2017-12-09 01:58:17 +00:00
|
|
|
chmod 755 "$CHROOT"/lib/*
|
2017-12-22 18:39:44 +00:00
|
|
|
chroot "$CHROOT" /bin/pmos_install
|