mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-04-22 13:37:18 +00:00

changes to put all the boot/installer files in one place instead of scattering them over multiple packages, and removing the 3rdparty folder from the .tar file as it’s +12MB and nobody is ever going to use them
112 lines
3.3 KiB
Bash
Executable File
112 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
################################################################################
|
|
# This file is part of OpenELEC - http://www.openelec.tv
|
|
# Copyright (C) 2009-2014 Christian Hewitt (chewitt@openelec.tv)
|
|
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
|
#
|
|
# OpenELEC 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 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# OpenELEC 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 OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
|
################################################################################
|
|
|
|
################################################################################
|
|
# variables such as $ROOT $PATH must be passed via env from scripts/image - the
|
|
# mkimage-atv script also requires 'kpartx' to be installed.
|
|
################################################################################
|
|
|
|
# set variables:
|
|
VERBOSE="FALSE"
|
|
IMGSIZE="200" # size of BOOT in MB
|
|
IMGUSB="$IMAGE_NAME-usb.img"
|
|
IMGHDD="$IMAGE_NAME-hdd.img"
|
|
|
|
# set verbose output on/off:
|
|
if [ "${VERBOSE}" = "TRUE" ]; then
|
|
exec 3>&1
|
|
exec 4>&2
|
|
else
|
|
exec 3> /dev/null
|
|
exec 4> /dev/null
|
|
fi
|
|
|
|
# check for kpartx
|
|
KPARTX=$(which kpartx)
|
|
if [ -z "$KPARTX" ]; then
|
|
echo "kpartx was not found, exiting!"
|
|
exit 1
|
|
fi
|
|
|
|
# loop through image options
|
|
for IMAGE in $IMGUSB $IMGHDD; do
|
|
|
|
# set the installer function
|
|
IMGFILE="$IMAGE"
|
|
if [ "$IMGFILE" = "$IMGUSB" ]; then
|
|
FUNCTION="install-usb"
|
|
else
|
|
FUNCTION="install-hdd"
|
|
fi
|
|
|
|
# create USB image
|
|
echo "Creating $IMGFILE"
|
|
dd if=/dev/zero of=$IMGFILE bs=1M count=$IMGSIZE 1>&3 2>&4
|
|
parted -s $IMGFILE mklabel gpt 1>&3 2>&4
|
|
parted -s $IMGFILE mkpart primary HFS 40s 100% 1>&3 2>&4
|
|
parted -s $IMGFILE name 1 OPENELEC 1>&3 2>&4
|
|
parted -s $IMGFILE set 1 atvrecv on 1>&3 2>&4
|
|
kpartx -a $IMGFILE 1>&3 2>&4
|
|
mkfs.hfsplus -s -v OPENELEC /dev/mapper/loop0p1 1>&3 2>&4
|
|
fsck.hfsplus -f /dev/mapper/loop0p1 1>&3 2>&4
|
|
|
|
# mount the image file
|
|
OE_TMP=$(mktemp -d)
|
|
mount /dev/mapper/loop0p1 $OE_TMP 1>&3 2>&4
|
|
|
|
# copy recovery files
|
|
cp -Rv $BUILD/atvboot-*/* $OE_TMP 1>&3 2>&4
|
|
echo $FUNCTION > $OE_TMP/function
|
|
|
|
# copy MACH_KERNEL/SYSTEM/.md5 files
|
|
cp $RELEASE_DIR/target/* $OE_TMP
|
|
|
|
# unmount the image file
|
|
sync 1>&3 2>&4
|
|
sleep 2
|
|
umount $OE_TMP 1>&3 2>&4
|
|
rm -rf $OE_TMP 1>&3 2>&4
|
|
|
|
# sync everything up
|
|
echo y | gptsync /dev/loop0 1>&3 2>&4
|
|
sleep 2
|
|
kpartx -d $IMGFILE 1>&3 2>&4
|
|
sync 1>&3 2>&4
|
|
|
|
# wait a bit
|
|
sleep 2
|
|
|
|
# gzip the image file and move to target/
|
|
gzip $IMGFILE
|
|
IMGFILE="$IMGFILE.gz"
|
|
|
|
# change file owner to match target/
|
|
USR=$(ls -dl $ROOT/target | awk '{print $3}')
|
|
GRP=$(ls -dl $ROOT/target | awk '{print $4}')
|
|
chown $USR:$GRP $IMGFILE
|
|
|
|
# move to target/
|
|
mv $IMGFILE target/
|
|
|
|
# close the loop
|
|
done
|
|
|