0
0
mirror of https://github.com/libretro/Lakka-LibreELEC.git synced 2024-12-15 01:40:01 +00:00
Lakka-LibreELEC/scripts/install_addon
Rudi Heitbaum c2a52dc4ac toolchain: migrate from p7zip to 7-zip
The -l option to 7za is not included the 7-Zip 22.01 version,
it was an option added to the p7zip version:

  don't store symlinks; store the files/directories they point to
  (CAUTION : the scanning stage can never end because of recursive
  symlinks like 'ln -s .. ldir')

The default for p7zip 16.02 7za was to store symlinks.
The default for 7-zip 22.01 7za is not to store symlinks.

test output is below and the -l option has been dropped from scripts/install_addon

$ ls -l test
total 4
-rw-r--r-- 1 docker docker 4 Jan 29 10:35 abc
lrwxrwxrwx 1 docker docker 3 Jan 29 10:35 def -> abc

7-Zip (a) 22.01 (x64) : Copyright (c) 1999-2022 Igor Pavlov : 2022-07-15
 64-bit locale=en_US.UTF-8 Threads:16
$ 7za a -mx9 -bsp0 -bso0 -tzip test.zip test
$ unzip -v test.zip
Archive:  test.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
       0  Stored        0   0% 2023-01-29 10:36 00000000  test/
       4  Stored        4   0% 2023-01-29 10:35 4788814e  test/abc
       4  Stored        4   0% 2023-01-29 10:35 4788814e  test/def
--------          -------  ---                            -------
       8                8   0%                            3 files

7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,16 CPUs x64)
$ 7za a -mx9 -bsp0 -bso0 -tzip test.zip test
$ unzip -v test.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
       0  Stored        0   0% 2023-01-29 10:35 00000000  test/
       4  Stored        4   0% 2023-01-29 10:35 4788814e  test/abc
       3  Stored        3   0% 2023-01-29 10:35 352441c2  test/def
--------          -------  ---                            -------
       7                7   0%                            3 files

7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,16 CPUs x64)
$ 7za a -l -mx9 -bsp0 -bso0 -tzip test.zip test
$ unzip -v test.zip
Archive:  test.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
       0  Stored        0   0% 2023-01-29 10:35 00000000  test/
       4  Stored        4   0% 2023-01-29 10:35 4788814e  test/abc
       4  Stored        4   0% 2023-01-29 10:35 4788814e  test/def
--------          -------  ---                            -------
       8                8   0%                            3 files
2023-02-04 03:03:19 +00:00

92 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
. config/options "${1}"
pkg_lock "${PKG_NAME}" "packadd"
pkg_lock_status "ACTIVE" "${PKG_NAME}" "packadd"
# cleanup old install path
rm -rf "${ADDON_BUILD}"
# install addon parts
if pkg_call_exists addon; then
pkg_call
else
install_binary_addon "${PKG_ADDON_ID}"
pkg_call_finish
fi
# Make sure we have a value for STRIP
setup_toolchain target
ADDON_DIRECTORY="${ADDON_BUILD}/${PKG_ADDON_ID}"
install_addon_files "${ADDON_DIRECTORY}"
debug_strip "${ADDON_DIRECTORY}"
# pack_addon()
ADDON_INSTALL_DIR="${TARGET_IMG}/${ADDONS}/${ADDON_VERSION}/${DEVICE:-${PROJECT}}/${TARGET_ARCH}/${PKG_ADDON_ID}"
ADDONVER="$(xmlstarlet sel -t -v "/addon/@version" ${ADDON_BUILD}/${PKG_ADDON_ID}/addon.xml)"
if [ -f ${ADDON_INSTALL_DIR}/${PKG_ADDON_ID}-${ADDONVER}.zip ]; then
if [ "${ADDON_OVERWRITE}" = "yes" ]; then
rm ${ADDON_INSTALL_DIR}/${PKG_ADDON_ID}-${ADDONVER}.zip
else
build_msg "CLR_WARNING" "*** WARNING: ${PKG_ADDON_ID}-${ADDONVER}.zip already exists. Not overwriting it. ***"
pkg_lock_status "UNLOCK" "${PKG_NAME}" "packadd" "already packed"
exit 0
fi
fi
cd ${ADDON_BUILD}
build_msg "CLR_INFO" "*** compressing addon ${PKG_ADDON_ID} ... ***"
${TOOLCHAIN}/bin/7za a -mx9 -bsp0 -bso0 -tzip ${PKG_ADDON_ID}-${ADDONVER}.zip ${PKG_ADDON_ID}
cd - &>/dev/null
mkdir -p ${ADDON_INSTALL_DIR}
cp ${ADDON_BUILD}/${PKG_ADDON_ID}-${ADDONVER}.zip ${ADDON_INSTALL_DIR}
if [ -f ${ADDON_BUILD}/${PKG_ADDON_ID}/changelog.txt ]; then
cp ${ADDON_BUILD}/${PKG_ADDON_ID}/changelog.txt ${ADDON_INSTALL_DIR}/changelog-${ADDONVER}.txt
fi
if [ -f ${ADDON_BUILD}/${PKG_ADDON_ID}/resources/icon.png ]; then
mkdir -p ${ADDON_INSTALL_DIR}/resources
cp ${ADDON_BUILD}/${PKG_ADDON_ID}/resources/icon.png ${ADDON_INSTALL_DIR}/resources/icon.png
fi
# workaround for kodi pvr addons
if [ -f ${ADDON_BUILD}/${PKG_ADDON_ID}/icon.png ]; then
cp ${ADDON_BUILD}/${PKG_ADDON_ID}/icon.png ${ADDON_INSTALL_DIR}/icon.png
fi
if [ -f ${ADDON_BUILD}/${PKG_ADDON_ID}/resources/fanart.png ]; then
mkdir -p ${ADDON_INSTALL_DIR}/resources
cp ${ADDON_BUILD}/${PKG_ADDON_ID}/resources/fanart.png ${ADDON_INSTALL_DIR}/resources/fanart.png
fi
for f in ${ADDON_BUILD}/${PKG_ADDON_ID}/resources/screenshot-*.{jpg,png}; do
if [ -f "${f}" ]; then
mkdir -p ${ADDON_INSTALL_DIR}/resources
cp ${f} ${ADDON_INSTALL_DIR}/resources
fi
done
# Jenkins add-on build
if [ "${ADDON_JENKINS}" = "yes" ]; then
ADDON_JENKINS_DIR="${TARGET_IMG}/jenkins"
ADDON_JENKINS_ADDON_NAME="${ADDON_VERSION}-${DEVICE:-${PROJECT}}-${TARGET_ARCH}-${PKG_ADDON_ID}-${ADDONVER}"
mkdir -p "${ADDON_JENKINS_DIR}"
cd ${ADDON_INSTALL_DIR}
${TOOLCHAIN}/bin/7za a -mx0 -bsp0 -bso0 -tzip ${ADDON_JENKINS_DIR}/${ADDON_JENKINS_ADDON_NAME}.zip ${PKG_ADDON_ID}-${ADDONVER}.zip resources/
( cd ${ADDON_JENKINS_DIR}
sha256sum ${ADDON_JENKINS_ADDON_NAME}.zip > ${ADDON_JENKINS_ADDON_NAME}.zip.sha256
)
build_msg "CLR_INFO" "*** creating ${ADDON_JENKINS_ADDON_NAME}.zip for Jenkins complete ***"
else
build_msg "CLR_INFO" "*** creating ${PKG_ADDON_ID} complete ***"
fi
pkg_lock_status "UNLOCK" "${PKG_NAME}" "packadd" "packed"