2017-11-16 22:20:57 +00:00
|
|
|
#!/bin/sh
|
2017-08-24 21:07:36 +00:00
|
|
|
|
2017-11-16 22:20:57 +00:00
|
|
|
# Copyright 2017 Attila Szollosi
|
2017-08-24 21:07:36 +00:00
|
|
|
#
|
|
|
|
# This file is part of postmarketos-android-recovery-installer.
|
|
|
|
#
|
|
|
|
# postmarketos-android-recovery-installer is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# postmarketos-android-recovery-installer is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with postmarketos-android-recovery-installer. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2017-11-16 22:20:57 +00:00
|
|
|
DEVICE="$1"
|
|
|
|
|
2017-08-24 21:07:36 +00:00
|
|
|
# Copy files to the destination specified
|
|
|
|
# $1: files
|
|
|
|
# $2: destination
|
|
|
|
copy_files()
|
|
|
|
{
|
|
|
|
for file in $1; do
|
|
|
|
filename=$(basename "$file")
|
|
|
|
install -Dm755 "$file" "$2"/"$filename"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
check_whether_exists()
|
|
|
|
{
|
|
|
|
if [ ! -e "$1" ]
|
|
|
|
then
|
|
|
|
echo "$1 not found"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-04-17 16:34:42 +00:00
|
|
|
remove_existing_zip()
|
|
|
|
{
|
|
|
|
if [ ! -e "$1" ]
|
|
|
|
then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
rm "$1"
|
|
|
|
}
|
|
|
|
|
2017-11-16 22:20:57 +00:00
|
|
|
BINARIES="/bin/busybox /bin/umount /sbin/cryptsetup /sbin/findfs /sbin/kpartx /sbin/mkfs.ext2 /sbin/mkfs.ext4 \
|
2018-03-15 22:16:50 +00:00
|
|
|
/usr/sbin/parted /usr/sbin/partprobe /bin/tar"
|
2017-08-24 21:07:36 +00:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
LIBRARIES=$(lddtree -l $BINARIES | awk '/lib/ {print}' | sort -u)
|
2019-04-17 16:34:42 +00:00
|
|
|
ZIP_CONTENTS="chroot META-INF disable-warning pmos_chroot rootfs.tar.gz"
|
|
|
|
ZIP_FILE="pmos-$DEVICE.zip"
|
|
|
|
|
2017-11-16 22:20:57 +00:00
|
|
|
copy_files "$BINARIES" chroot/bin/
|
|
|
|
copy_files "$LIBRARIES" chroot/lib/
|
2017-08-24 21:07:36 +00:00
|
|
|
check_whether_exists rootfs.tar.gz
|
2019-04-17 16:34:42 +00:00
|
|
|
remove_existing_zip "$ZIP_FILE"
|
|
|
|
# zip command can't take a list of files wrapped in quotes
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
zip -0 -r "$ZIP_FILE" $ZIP_CONTENTS
|