Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 621 lines (512 sloc) 21.6 KB
#!/bin/bash
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2016 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/>.
################################################################################
unset _CACHE_PACKAGE_LOCAL _CACHE_PACKAGE_GLOBAL
. config/options $1
show_config
setup_toolchain target
$SCRIPTS/checkdeps
$SCRIPTS/build toolchain
$SCRIPTS/build squashfs:host
$SCRIPTS/build dosfstools:host
$SCRIPTS/build fakeroot:host
$SCRIPTS/build kmod:host
$SCRIPTS/build mtools:host
$SCRIPTS/build populatefs:host
BUILD_DATE=`date +%Y%m%d%H%M%S`
GIT_HASH=$(git rev-parse HEAD)
if [ "$LIBREELEC_VERSION" = "devel" ]; then
if ! GIT_BUILD=$(git rev-list --count HEAD 2>/dev/null)
then
GIT_BUILD=$(git rev-list HEAD | wc -l)
fi
GIT_ABBREV=$(git log -1 --pretty=format:%h)
DEVEL_VERSION=$LIBREELEC_VERSION
LIBREELEC_VERSION=$LIBREELEC_VERSION-$BUILD_DATE-r$GIT_BUILD-g$GIT_ABBREV
echo "$LIBREELEC_VERSION" > $BUILD/BUILD_FILENAME
fi
# Get origin url, fix git:// and git@github.com: urls if necessary
ORIGIN_URL="$(git remote -v | awk '$1 == "origin" { print $2 }' | head -1 | sed 's#\.git$##;s#^git:#https:#;s#^git@github\.com:#https://github.com/#')"
if [ "$OFFICIAL" = "yes" ]; then
LIBREELEC_BUILD="official"
else
LIBREELEC_BUILD="community"
fi
if [ -n "$CUSTOM_VERSION" ]; then
LIBREELEC_VERSION="$CUSTOM_VERSION"
fi
if [ -n "$CUSTOM_GIT_HASH" ]; then
GIT_HASH="$CUSTOM_GIT_HASH"
fi
# Lakka specific naming scheme
if [ -n "$SYSTEM" ]; then
LIBREELEC_ARCH="$PROJECT.$SYSTEM.$TARGET_ARCH"
elif [ -n "$BOARD" ]; then
LIBREELEC_ARCH="$PROJECT.$BOARD.$TARGET_ARCH"
elif [ -n "$DEVICE" ]; then
LIBREELEC_ARCH="$PROJECT.$DEVICE.$TARGET_ARCH"
else
LIBREELEC_ARCH="$PROJECT.$TARGET_ARCH"
fi
TARGET_VERSION="$LIBREELEC_ARCH-$LIBREELEC_VERSION"
IMAGE_NAME="$DISTRONAME-$TARGET_VERSION"
if [ "$DEVEL_VERSION" = "devel" ] ; then
IMAGE_NAME="$DISTRONAME-$LIBREELEC_ARCH-$OS_VERSION-$LIBREELEC_VERSION"
fi
if [ -n "$CUSTOM_IMAGE_NAME" ]; then
IMAGE_NAME="$CUSTOM_IMAGE_NAME"
fi
if [ -n "$IMAGE_SUFFIX" ]; then
IMAGE_NAME="$IMAGE_NAME-$IMAGE_SUFFIX"
fi
# setup fakeroot
rm -rf $FAKEROOT_SCRIPT # remove $FAKEROOT_SCRIPT if it exist
touch $FAKEROOT_SCRIPT # create an empty $FAKEROOT_SCRIPT
chmod +x $FAKEROOT_SCRIPT # make $FAKEROOT_SCRIPT executable
echo "chown -R 0:0 $INSTALL" >> $FAKEROOT_SCRIPT
# clean old install dirs
rm -rf $INSTALL
rm -rf $STAMPS_INSTALL
mkdir -p $INSTALL
# create baselayout
mkdir -p $INSTALL/etc
mkdir -p $INSTALL/dev
mkdir -p $INSTALL/proc
mkdir -p $INSTALL/run
mkdir -p $INSTALL/sys
mkdir -p $INSTALL/tmp
mkdir -p $INSTALL/usr
mkdir -p $INSTALL/var
mkdir -p $INSTALL/flash
mkdir -p $INSTALL/storage
ln -sf /var/media $INSTALL/media
ln -sf /usr/lib $INSTALL/lib
ln -sf /usr/bin $INSTALL/bin
ln -sf /usr/sbin $INSTALL/sbin
if [ "$TARGET_ARCH" = "x86_64" -o "$TARGET_ARCH" = "powerpc64" ]; then
ln -s /usr/lib $INSTALL/lib64
mkdir -p $INSTALL/usr
ln -s /usr/lib $INSTALL/usr/lib64
fi
echo "$TARGET_VERSION" > $INSTALL/etc/release
# create /etc/os-release
echo -e "NAME=\"$DISTRONAME\"" > $INSTALL/etc/os-release
echo -e "VERSION=\"$LIBREELEC_VERSION\"" >> $INSTALL/etc/os-release
echo -e "ID=\"libreelec\"" >> $INSTALL/etc/os-release
echo -e "VERSION_ID=\"$OS_VERSION\"" >> $INSTALL/etc/os-release
echo -e "PRETTY_NAME=\"$DISTRONAME ($LIBREELEC_BUILD): $LIBREELEC_VERSION\"" >> $INSTALL/etc/os-release
echo -e "HOME_URL=\"https://libreelec.tv\"" >> $INSTALL/etc/os-release
echo -e "BUG_REPORT_URL=\"$ORIGIN_URL\"" >> $INSTALL/etc/os-release
echo -e "BUILD_ID=\"$GIT_HASH\"" >> $INSTALL/etc/os-release
echo -e "OPENELEC_ARCH=\"$LIBREELEC_ARCH\"" >> $INSTALL/etc/os-release
echo -e "LIBREELEC_ARCH=\"$LIBREELEC_ARCH\"" >> $INSTALL/etc/os-release
echo -e "LIBREELEC_BUILD=\"$LIBREELEC_BUILD\"" >> $INSTALL/etc/os-release
# create /etc/issue
echo "$GREETING0" > $INSTALL/etc/issue
echo "$GREETING1" >> $INSTALL/etc/issue
echo "$GREETING2" >> $INSTALL/etc/issue
echo "$GREETING3" >> $INSTALL/etc/issue
echo "$GREETING4" >> $INSTALL/etc/issue
echo "$DISTRONAME ($LIBREELEC_BUILD): $LIBREELEC_VERSION ($LIBREELEC_ARCH)" >> $INSTALL/etc/issue
ln -sf /etc/issue $INSTALL/etc/motd
# Basissystem...
$SCRIPTS/install libc
$SCRIPTS/install gcc
$SCRIPTS/install linux
$SCRIPTS/install linux-drivers
$SCRIPTS/install linux-firmware
$SCRIPTS/install $BOOTLOADER
$SCRIPTS/install busybox
$SCRIPTS/install util-linux
$SCRIPTS/install corefonts
$SCRIPTS/install network
# Graphic support
[ "$DISPLAYSERVER" = "x11" ] && $SCRIPTS/install x11
[ "$DISPLAYSERVER" = "wayland" ] && $SCRIPTS/install wayland-weston
# Multimedia support
[ ! "$MEDIACENTER" = "no" ] && $SCRIPTS/install mediacenter
# Sound support
[ "$ALSA_SUPPORT" = "yes" ] && $SCRIPTS/install alsa
# Automounter support
[ "$UDEVIL" = "yes" ] && $SCRIPTS/install udevil
# NTFS 3G support
[ "$EXFAT" = "yes" ] && $SCRIPTS/install fuse-exfat
# NTFS 3G support
[ "$NTFS3G" = "yes" ] && $SCRIPTS/install ntfs-3g_ntfsprogs
# Remote support
[ "$REMOTE_SUPPORT" = "yes" ] && $SCRIPTS/install remote
# Virtual image creation support
[ "$PROJECT" = "Generic" ] && $SCRIPTS/install virtual
# Installer support
[ "$INSTALLER_SUPPORT" = "yes" ] && $SCRIPTS/install installer
# Devtools... (not for Release)
[ "$TESTING" = "yes" ] && $SCRIPTS/install testing
# Install gdb in all builds, including releases
$SCRIPTS/install debug
# OEM packages
[ "$OEM_SUPPORT" = "yes" ] && $SCRIPTS/install oem
# copy project related files to filesystem
if [ -d "$PROJECT_DIR/$PROJECT/filesystem" ]; then
cp -PR $PROJECT_DIR/$PROJECT/filesystem/* $INSTALL
# install project specific systemd services
for service in $PROJECT_DIR/$PROJECT/filesystem/usr/lib/systemd/system/*.service ; do
if [ -f "$service" ] ; then
enable_service $(basename $service)
fi
done
fi
# copy device related files to filesystem
if [ -n "$DEVICE" -a -d "$PROJECT_DIR/$PROJECT/devices/$DEVICE/filesystem" ]; then
cp -PR $PROJECT_DIR/$PROJECT/devices/$DEVICE/filesystem/* $INSTALL
# install device specific systemd services
for service in $PROJECT_DIR/$PROJECT/devices/$DEVICE/filesystem/usr/lib/systemd/system/*.service ; do
if [ -f "$service" ] ; then
enable_service $(basename $service)
fi
done
fi
# copy board related files to filesystem
if [ -n "$BOARD" -a -d "$PROJECT_DIR/$PROJECT/boards/$BOARD/filesystem" ]; then
cp -PR $PROJECT_DIR/$PROJECT/boards/$BOARD/filesystem/* $INSTALL
# install board specific systemd services
for service in $PROJECT_DIR/$PROJECT/boards/$BOARD/filesystem/usr/lib/systemd/system/*.service ; do
if [ -f "$service" ] ; then
enable_service $(basename $service)
fi
done
fi
# run depmod
MODVER=$(basename $(ls -d $INSTALL/usr/lib/modules/*))
find $INSTALL/usr/lib/modules/$MODVER/ -name *.ko | \
sed -e "s,$INSTALL/usr/lib/modules/$MODVER/,," > $INSTALL/usr/lib/modules/$MODVER/modules.order
$TOOLCHAIN/bin/depmod -b $INSTALL/usr -a -e -F "$BUILD/linux-$(kernel_version)/System.map" $MODVER
# strip kernel modules
if [ "$TARGET_KERNEL_ARCH" = "arm64" -a "$TARGET_ARCH" = "arm" ]; then
export PATH=$TOOLCHAIN/lib/gcc-linaro-aarch64-elf/bin/:$PATH
STRIP=aarch64-elf-strip
fi
for MOD in `find $INSTALL/usr/lib/modules/ -type f -name *.ko`; do
$STRIP --strip-debug $MOD
done
# make target dir
mkdir -p $TARGET_IMG
rm -rf $TARGET_IMG/$IMAGE_NAME.kernel
# copy kernel to target dir
if [ "$BUILD_ANDROID_BOOTIMG" = "yes" ]; then
echo "Building Amlogic DeviceTreeBlobs and injecting them to kernel..."
pushd "$BUILD/linux-$(kernel_version)" > /dev/null
rm -rf arch/$TARGET_KERNEL_ARCH/boot/dts/amlogic/*.dtb arch/$TARGET_KERNEL_ARCH/boot/dtb.img arch/$TARGET_KERNEL_ARCH/boot/boot.img
for extra_target in $KERNEL_UBOOT_EXTRA_TARGET; do
LDFLAGS="" make $extra_target > /dev/null
done
DTB_BLOBS=($(ls arch/$TARGET_KERNEL_ARCH/boot/dts/amlogic/*.dtb 2>/dev/null || true))
DTB_BLOBS_COUNT="${#DTB_BLOBS[@]}"
DTB_BLOB_OUTPUT="arch/$TARGET_KERNEL_ARCH/boot/dtb.img"
ANDROID_BOOTIMG_SECOND="--second $DTB_BLOB_OUTPUT"
if [ "$DTB_BLOBS_COUNT" -gt 1 ]; then
$ROOT/tools/dtbTool/dtbTool -o arch/$TARGET_KERNEL_ARCH/boot/dtb.img -p scripts/dtc/ arch/$TARGET_KERNEL_ARCH/boot/dts/amlogic/
ANDROID_BOOTIMG_SECOND="--second arch/$TARGET_KERNEL_ARCH/boot/dtb.img"
elif [ "$DTB_BLOBS_COUNT" -eq 1 ]; then
ANDROID_BOOTIMG_SECOND="--second $DTB_BLOBS"
else
ANDROID_BOOTIMG_SECOND=""
fi
mkbootimg --kernel arch/$TARGET_KERNEL_ARCH/boot/$KERNEL_TARGET --ramdisk $BUILD/image/initramfs.cpio \
$ANDROID_BOOTIMG_SECOND $ANDROID_BOOTIMG_OPTIONS --output arch/$TARGET_KERNEL_ARCH/boot/boot.img
if [ -f $DTB_BLOB_OUTPUT ]; then
cp -f $DTB_BLOB_OUTPUT $TARGET_IMG/$IMAGE_NAME.dtb
fi
echo "...done"
popd > /dev/null
cp -PR $BUILD/linux-$(kernel_version)/arch/$TARGET_KERNEL_ARCH/boot/boot.img $TARGET_IMG/$IMAGE_NAME.kernel
else
cp -PR $BUILD/linux-$(kernel_version)/arch/$TARGET_KERNEL_ARCH/boot/$KERNEL_TARGET $TARGET_IMG/$IMAGE_NAME.kernel
fi
chmod 0644 $TARGET_IMG/$IMAGE_NAME.kernel
# create squashfs file, default to gzip if no compression configured
echo "rm -rf \"$TARGET_IMG/$IMAGE_NAME.system\"" >> $FAKEROOT_SCRIPT
echo "$TOOLCHAIN/bin/mksquashfs \"$BUILD/image/system\" \"$TARGET_IMG/$IMAGE_NAME.system\" -noappend -comp ${SQUASHFS_COMPRESSION:-gzip}" >> $FAKEROOT_SCRIPT
# run fakeroot
$TOOLCHAIN/bin/fakeroot -- $FAKEROOT_SCRIPT
rm -rf $FAKEROOT_SCRIPT
# set permissions
chmod 0644 $TARGET_IMG/$IMAGE_NAME.system
if [ "$1" = "release" -o "$1" = "mkimage" -o "$1" = "amlpkg" -o "$1" = "noobs" ]; then
RELEASE_DIR="target/$IMAGE_NAME"
if [ -n "$DEVICE" -a -d "$PROJECT_DIR/$PROJECT/devices/$DEVICE/install" ]; then
INSTALL_SRC_DIR="$PROJECT_DIR/$PROJECT/devices/$DEVICE/install"
else
INSTALL_SRC_DIR="$PROJECT_DIR/$PROJECT/install"
fi
MKIMAGE_TOOL_CMD="$(which mkimage) -A $TARGET_KERNEL_ARCH -O linux -T script -C none -d"
# cleanup
rm -rf $RELEASE_DIR
# create release dir
mkdir -p $RELEASE_DIR
# remove n previous created release image
rm -rf $TARGET_IMG/$IMAGE_NAME.img.gz
if [ -n "$BOOTLOADER" ]; then
BOOTLOADER_DIR="$(get_pkg_directory "$BOOTLOADER")"
if [ -d $BOOTLOADER_DIR/files ]; then
cp -R $BOOTLOADER_DIR/files/* $RELEASE_DIR
fi
if [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/bootloader/release ]; then
. $PROJECT_DIR/$PROJECT/devices/$DEVICE/bootloader/release
elif [ -f $PROJECT_DIR/$PROJECT/bootloader/release ]; then
. $PROJECT_DIR/$PROJECT/bootloader/release
elif [ -f $BOOTLOADER_DIR/release ]; then
. $BOOTLOADER_DIR/release
fi
fi
# MfgTool2 for TBS Matrix support (add it to .tar)
# only for matrix system or all? (one tar for all updates?)
if [ "$PROJECT" == "imx6" -a "$SYSTEM" == "matrix" ]; then
$SCRIPTS/unpack imx6-mfgtool2-tbs-matrix
mkdir -p $RELEASE_DIR/MfgTool2-TBS-Matrix
cp -PR $BUILD/imx6-mfgtool2-tbs-matrix-*/* $RELEASE_DIR/MfgTool2-TBS-Matrix
fi
cp $ROOT/README* $RELEASE_DIR
cp $ROOT/CHANGELOG* $RELEASE_DIR
echo "$TARGET_VERSION" > $RELEASE_DIR/RELEASE
if [ -n "$MEDIACENTER" ] ; then
echo "Kodi commit: `scripts/git_version $MEDIACENTER`" >> $RELEASE_DIR/RELEASE
fi
mkdir -p $RELEASE_DIR/licenses
cp $ROOT/licenses/* $RELEASE_DIR/licenses
mkdir -p $RELEASE_DIR/target
cp $TARGET_IMG/$IMAGE_NAME.system $RELEASE_DIR/target/SYSTEM
cp $TARGET_IMG/$IMAGE_NAME.kernel $RELEASE_DIR/target/KERNEL
# create md5sum's
( cd $RELEASE_DIR;
md5sum -t target/SYSTEM > target/SYSTEM.md5;
md5sum -t target/KERNEL > target/KERNEL.md5;
)
# create target directory
mkdir -p $TARGET_IMG
# remove an previous created release tarball
rm -rf $TARGET_IMG/$IMAGE_NAME.tar
# create release tarball
tar cf $TARGET_IMG/$IMAGE_NAME.tar -C target $IMAGE_NAME
# create image files if requested
if [[ ( "$1" = "amlpkg" || "$1" = "noobs" || "$1" = "mkimage" ) && -n "$BOOTLOADER" ]]; then
# projects can set KERNEL_NAME (kernel.img)
if [ -z "$KERNEL_NAME" ] ; then
KERNEL_NAME="KERNEL"
fi
UBOOT_SYSTEM=""
if [ "$PROJECT" == "imx6" ]; then
if [ -n "$SYSTEM" ]; then
UBOOT_SYSTEM="$SYSTEM"
else
UBOOT_SYSTEM="cuboxi"
fi
elif [ "$PROJECT" == "Allwinner" ]; then
if [ -n "$SYSTEM" ]; then
UBOOT_SYSTEM="$SYSTEM"
else
UBOOT_SYSTEM="opi2"
fi
fi
# variables used in image script must be passed
env \
PATH="$PATH:/sbin" \
ROOT="$ROOT" \
TOOLCHAIN="$TOOLCHAIN" \
PROJECT_DIR="$PROJECT_DIR" \
PROJECT="$PROJECT" \
DEVICE="$DEVICE" \
DISTRO="$DISTRO" \
DISTRONAME="$DISTRONAME" \
TARGET_IMG="$TARGET_IMG" \
IMAGE_NAME="$IMAGE_NAME" \
INSTALL_SRC_DIR="$INSTALL_SRC_DIR" \
BOOTLOADER="$BOOTLOADER" \
KERNEL_NAME="$KERNEL_NAME" \
MKIMAGE_TOOL_CMD="$MKIMAGE_TOOL_CMD" \
RELEASE_DIR=$RELEASE_DIR \
UUID_STORAGE="$(uuidgen)" \
UBOOT_SYSTEM="$UBOOT_SYSTEM" \
UBOOT_DTB="$UBOOT_DTB" \
EXTRA_CMDLINE="$EXTRA_CMDLINE" \
SYSTEM_SIZE="$SYSTEM_SIZE" \
SYSTEM_PART_START="$SYSTEM_PART_START" \
$SCRIPTS/mkimage
fi
# cleanup release dir
rm -rf $RELEASE_DIR
# create WeTek Play (Amlogic) ZIP update and auto-install packages if requested
if [ "$1" = "amlpkg" ]; then
echo "Creating Amlogic ZIP update package"
AML_PKG_DIR="$RELEASE_DIR/ampl-pkg"
# create package directory
mkdir -p "$AML_PKG_DIR"
# copy system and kernel images
mkdir -p "$AML_PKG_DIR/system"
cp $TARGET_IMG/$IMAGE_NAME.system $AML_PKG_DIR/system/SYSTEM
cp $TARGET_IMG/$IMAGE_NAME.kernel $AML_PKG_DIR/KERNEL
# copy update-binary and updater-script
META_INF_DIR="$AML_PKG_DIR/META-INF/com/google/android"
mkdir -p "$META_INF_DIR"
cp $INSTALL_SRC_DIR/update-binary $META_INF_DIR
cp $INSTALL_SRC_DIR/updater-script $META_INF_DIR
# copy other files if any
if [ -d "$INSTALL_SRC_DIR/files" ]; then
cp -PR $INSTALL_SRC_DIR/files/* $AML_PKG_DIR
fi
# copy device tree image if any
if [ -f "$INSTALL/usr/share/bootloader/dtb.img" ]; then
cp "$INSTALL/usr/share/bootloader/dtb.img" $AML_PKG_DIR/dtb.img
fi
# create the update package
pushd "$AML_PKG_DIR" > /dev/null
zip -rq update.zip *
# sign the update package
echo "Signing the update package"
mkdir -p sign
SIGNAPK_DIR="$ROOT/tools/signapk"
java -Xmx1024m -jar $SIGNAPK_DIR/signapk.jar -w $SIGNAPK_DIR/testkey.x509.pem $SIGNAPK_DIR/testkey.pk8 update.zip sign/$IMAGE_NAME-update.zip
# create the auto-install package
echo "Creating Amlogic ZIP auto-install package"
pushd sign > /dev/null
echo --update_package=/sdcard/$IMAGE_NAME-update.zip > factory_update_param.aml
echo --wipe_data >> factory_update_param.aml
echo --wipe_cache >> factory_update_param.aml
if [ -f "$INSTALL_SRC_DIR/files/recovery.img" ]; then
cp $INSTALL_SRC_DIR/files/recovery.img .
fi
if [ -f $INSTALL_SRC_DIR/files/aml_autoscript ]; then
cp $INSTALL_SRC_DIR/files/aml_autoscript .
fi
# copy device tree image if any
if [ -f "$INSTALL/usr/share/bootloader/dtb.img" ]; then
cp "$INSTALL/usr/share/bootloader/dtb.img" .
fi
zip -q $TARGET_IMG/$IMAGE_NAME.zip *
popd > /dev/null
popd > /dev/null
elif [ "$1" = "noobs" ]; then
echo "Creating \"$1\" release tarball..."
if [ "$BOARD" != "" ]; then
RELEASE_NAME="$BOARD"
else
RELEASE_NAME="$PROJECT"
fi
RELEASE_DIR="$TARGET_IMG/${IMAGE_NAME}-$1"
# create release dir
mkdir -p $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}
if [ -f $DISTRO_DIR/$DISTRO/${DISTRONAME}_40x40.png ]; then
cp -PR $DISTRO_DIR/$DISTRO/${DISTRONAME}_40x40.png $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/${DISTRONAME}_${RELEASE_NAME}.png
else
cp -PR $DISTRO_DIR/$DISTRO/${DISTRONAME}.png $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/${DISTRONAME}_${RELEASE_NAME}.png
fi
cp -PR $ROOT/config/noobs/os.json $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}
cp -PR $ROOT/config/noobs/partition_setup.sh $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}
cp -PR $ROOT/config/noobs/partitions.json $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}
if [ -d $DISTRO_DIR/$DISTRO/noobs/marketing ]; then
tar cf $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/marketing.tar -C $DISTRO_DIR/$DISTRO/noobs/marketing .
else
tar cf $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/marketing.tar -C $ROOT/config/noobs/marketing .
fi
cp $ROOT/README* $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}
cp $ROOT/CHANGELOG $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/release_notes.txt
# create System dir
mkdir -p $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System
BOOTLOADER_DIR="$(get_pkg_directory "$BOOTLOADER")"
if [ -d $BOOTLOADER_DIR/files/3rdparty/bootloader/ ]; then
cp -PR $BOOTLOADER_DIR/files/3rdparty/bootloader/* $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System
fi
# RPi4 distroconfig.txt
if [ "$BOARD" == "RPi4" ]; then
cp -PR $PROJECT_DIR/$PROJECT/boards/$BOARD/config/* $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System
fi
# copy Bootloader
cp -PR $BUILD/bcm2835-bootloader-*/LICENCE* $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/
cp -PR $BUILD/bcm2835-bootloader-*/bootcode.bin $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/
if [ "$BOARD" == "RPi4" ]; then
cp -PR $BUILD/bcm2835-bootloader-*/fixup4x.dat $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/fixup.dat
cp -PR $BUILD/bcm2835-bootloader-*/start4x.elf $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/start.elf
else
cp -PR $BUILD/bcm2835-bootloader-*/fixup_x.dat $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/fixup.dat
cp -PR $BUILD/bcm2835-bootloader-*/start_x.elf $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/start.elf
fi
[ -f $BUILD/bcm2835-bootloader-*/dt-blob.bin ] && cp -PR $BUILD/bcm2835-bootloader-*/dt-blob.bin $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/dt-blob.bin
# copy system files
cp $TARGET_IMG/$IMAGE_NAME.system $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/SYSTEM
cp $TARGET_IMG/$IMAGE_NAME.kernel $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/kernel.img
for dtb in $INSTALL/usr/share/bootloader/*.dtb ; do
if [ -f $dtb ]; then
cp -PR $dtb $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System
fi
done
for overlay in $INSTALL/usr/share/bootloader/overlays/* ; do
if [ -f $overlay ]; then
mkdir -p $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/overlays
cp -PR $overlay $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/overlays
fi
done
# create md5sum's
( cd $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System;
md5sum -t SYSTEM > SYSTEM.md5;
md5sum -t kernel.img > kernel.img.md5;
)
# copy additional files
mkdir -p $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/licenses
cp $ROOT/licenses/* $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/licenses
# create Storage dir
mkdir -p $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/Storage
# remove an previous created release tarball
rm -rf $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System.tar.xz
rm -rf $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/Storage.tar.xz
# create filesystem tarballs
tar cJf $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System.tar.xz -C $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System/ .
tar cJf $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/Storage.tar.xz -C $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/Storage/ .
# populate os.json
NOOBS_SYSTEM_SIZE=$(stat --printf="%s" $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System.tar.xz)
NOOBS_STORAGE_SIZE=$(stat --printf="%s" $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/Storage.tar.xz)
PINN_DOWNLOAD_SIZE=$((NOOBS_SYSTEM_SIZE+NOOBS_STORAGE_SIZE))
sed -e "s%@DISTRONAME@%$DISTRONAME%g" \
-e "s%@RELEASE_NAME@%$RELEASE_NAME%g" \
-e "s%@PROJECT@%$PROJECT%g" \
-e "s%@LIBREELEC_VERSION@%$LIBREELEC_VERSION%g" \
-e "s%@RELEASE_DATE@%$(date +%F)%g" \
-e "s%@KERNEL_VERSION@%$(kernel_version)%g" \
-e "s%@DESCRIPTION@%$DESCRIPTION%g" \
-e "s%@ROOT_PASSWORD@%$ROOT_PASSWORD%g" \
-e "s%@NOOBS_SUPPORTED_MODELS@%$NOOBS_SUPPORTED_MODELS%g" \
-e "s%@NOOBS_HEX@%$NOOBS_HEX%g" \
-e "s%@PINN_URL@%$DISTRO_WEBSITE%g" \
-e "s%@PINN_GROUP@%$DISTRO_PINN_GROUP%g" \
-e "s%@PINN_DOWNLOAD_SIZE@%$PINN_DOWNLOAD_SIZE%g" \
-i $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/os.json
sed -e "s%@DISTRONAME@%$DISTRONAME%g" \
-e "s%@PROJECT@%$PROJECT%g" \
-e "s%@SYSTEM_SIZE@%$SYSTEM_SIZE%g" \
-i $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/partitions.json
# remove an filesystem dirs
rm -rf $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/System
rm -rf $RELEASE_DIR/${DISTRONAME}_${RELEASE_NAME}/Storage
# remove an previous created release tarball
rm -rf $TARGET_IMG/${IMAGE_NAME}-$1.tar
# create release tarball
tar cf $TARGET_IMG/${IMAGE_NAME}-$1.tar -C $TARGET ${IMAGE_NAME}-$1
fi
if [ -d $RELEASE_DIR ]; then
# cleanup release dir
rm -rf $RELEASE_DIR
fi
fi
You can’t perform that action at this time.