pmaports/main/postmarketos-android-recovery-installer/build_zip.sh

53 lines
1.6 KiB
Bash

#!/bin/ash
# shellcheck shell=dash
# Copyright 2017 Attila Szöllősi
#
# 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
# 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
}
# shellcheck disable=SC1091
. ./install_options
BINARIES="/sbin/cryptsetup /sbin/kpartx /usr/sbin/parted /usr/sbin/partprobe /sbin/findfs /sbin/mkfs.ext2 /sbin/mkfs.ext4"
# shellcheck disable=SC2086
LIBRARIES=$(lddtree -l $BINARIES | awk '/lib/ {print}' | sort -u)
copy_files "$BINARIES" bin/
copy_files "$LIBRARIES" lib/
check_whether_exists rootfs.tar.gz
[ "$FLASH_BOOT" = "true" ] && check_whether_exists boot.img
zip -0 -r "pmos-$DEVICE.zip" .