2021-08-29 10:15:55 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ ! -e "src/api/api.h" ]; then
|
|
|
|
echo "Please run this script from the root directory of Lite XL."; exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
source scripts/common.sh
|
|
|
|
|
|
|
|
show_help() {
|
|
|
|
echo
|
|
|
|
echo "Usage: $0 <OPTIONS>"
|
|
|
|
echo
|
|
|
|
echo "Available options:"
|
|
|
|
echo
|
2023-04-11 17:33:34 +02:00
|
|
|
echo "-b --builddir DIRNAME Sets the name of the build directory (not path)."
|
|
|
|
echo " Default: '$(get_default_build_dir)'."
|
|
|
|
echo "-d --destdir DIRNAME Set the name of the package directory (not path)."
|
|
|
|
echo " Default: 'lite-xl'."
|
|
|
|
echo "-h --help Show this help and exit."
|
|
|
|
echo "-p --prefix PREFIX Install directory prefix. Default: '/'."
|
|
|
|
echo "-v --version VERSION Sets the version on the package name."
|
|
|
|
echo "-a --addons Install 3rd party addons."
|
|
|
|
echo " --debug Debug this script."
|
|
|
|
echo "-A --appimage Create an AppImage (Linux only)."
|
|
|
|
echo "-B --binary Create a normal / portable package or macOS bundle,"
|
|
|
|
echo " depending on how the build was configured. (Default.)"
|
2023-11-10 02:44:58 +01:00
|
|
|
echo "-D --dmg Create a DMG disk image with dmgbuild (macOS only)."
|
2023-04-11 17:33:34 +02:00
|
|
|
echo "-I --innosetup Create a InnoSetup package (Windows only)."
|
|
|
|
echo "-r --release Strip debugging symbols."
|
|
|
|
echo "-S --source Create a source code package,"
|
|
|
|
echo " including subprojects dependencies."
|
|
|
|
echo " --cross-platform PLATFORM The platform to package for."
|
|
|
|
echo " --cross-arch ARCH The architecture to package for."
|
2021-08-29 10:15:55 +02:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
source_package() {
|
|
|
|
local build_dir=build-src
|
|
|
|
local package_name=$1
|
|
|
|
|
|
|
|
rm -rf ${build_dir}
|
|
|
|
rm -rf ${package_name}
|
|
|
|
rm -f ${package_name}.tar.gz
|
|
|
|
|
|
|
|
meson subprojects download
|
|
|
|
meson setup ${build_dir} -Dsource-only=true
|
|
|
|
|
|
|
|
# Note: not using git-archive(-all) because it can't include subprojects ignored by git
|
|
|
|
rsync -arv \
|
|
|
|
--exclude /*build*/ \
|
|
|
|
--exclude *.git* \
|
|
|
|
--exclude lhelper \
|
|
|
|
--exclude lite-xl* \
|
|
|
|
--exclude submodules \
|
|
|
|
. ${package_name}
|
|
|
|
|
|
|
|
cp "${build_dir}/start.lua" "${package_name}/data/core"
|
|
|
|
|
|
|
|
tar rf ${package_name}.tar ${package_name}
|
|
|
|
gzip -9 ${package_name}.tar
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
2022-09-25 22:59:01 +02:00
|
|
|
local arch="$(get_platform_arch)"
|
2021-08-29 10:15:55 +02:00
|
|
|
local platform="$(get_platform_name)"
|
|
|
|
local build_dir="$(get_default_build_dir)"
|
|
|
|
local dest_dir=lite-xl
|
|
|
|
local prefix=/
|
|
|
|
local version
|
|
|
|
local addons=false
|
|
|
|
local appimage=false
|
|
|
|
local binary=false
|
|
|
|
local dmg=false
|
|
|
|
local innosetup=false
|
2022-09-25 22:59:01 +02:00
|
|
|
local release=false
|
2021-08-29 10:15:55 +02:00
|
|
|
local source=false
|
2023-04-11 17:33:34 +02:00
|
|
|
local cross
|
|
|
|
local cross_arch
|
|
|
|
local cross_platform
|
2021-08-29 10:15:55 +02:00
|
|
|
|
2022-09-25 22:59:01 +02:00
|
|
|
# store the current flags to easily pass them to appimage script
|
|
|
|
local flags="$@"
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
for i in "$@"; do
|
|
|
|
case $i in
|
|
|
|
-b|--builddir)
|
|
|
|
build_dir="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-d|--destdir)
|
|
|
|
dest_dir="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-h|--help)
|
|
|
|
show_help
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
-p|--prefix)
|
|
|
|
prefix="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-v|--version)
|
|
|
|
if [[ -n $2 ]]; then version="-$2"; fi
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-A|--appimage)
|
|
|
|
if [[ "$platform" != "linux" ]]; then
|
|
|
|
echo "Warning: ignoring --appimage option, works only under Linux."
|
|
|
|
else
|
|
|
|
appimage=true
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-B|--binary)
|
|
|
|
binary=true
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-D|--dmg)
|
|
|
|
if [[ "$platform" != "macos" ]]; then
|
|
|
|
echo "Warning: ignoring --dmg option, works only under macOS."
|
|
|
|
else
|
|
|
|
dmg=true
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-I|--innosetup)
|
|
|
|
if [[ "$platform" != "windows" ]]; then
|
|
|
|
echo "Warning: ignoring --innosetup option, works only under Windows."
|
|
|
|
else
|
|
|
|
innosetup=true
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
;;
|
2022-09-25 22:59:01 +02:00
|
|
|
-r|--release)
|
|
|
|
release=true
|
|
|
|
shift
|
|
|
|
;;
|
2021-08-29 10:15:55 +02:00
|
|
|
-S|--source)
|
|
|
|
source=true
|
|
|
|
shift
|
|
|
|
;;
|
2022-09-25 22:59:01 +02:00
|
|
|
-a|--addons)
|
2021-08-29 10:15:55 +02:00
|
|
|
addons=true
|
|
|
|
shift
|
|
|
|
;;
|
2023-04-11 17:33:34 +02:00
|
|
|
--cross-platform)
|
|
|
|
cross=true
|
|
|
|
cross_platform="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--cross-arch)
|
|
|
|
cross=true
|
|
|
|
cross_arch="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
2021-08-29 10:15:55 +02:00
|
|
|
--debug)
|
|
|
|
set -x
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# unknown option
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2022-09-25 22:59:01 +02:00
|
|
|
if [[ $addons == true ]]; then
|
|
|
|
version="$version-addons"
|
|
|
|
fi
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
if [[ -n $1 ]]; then show_help; exit 1; fi
|
|
|
|
|
2023-04-11 17:33:34 +02:00
|
|
|
if [[ -n "$cross" ]]; then
|
|
|
|
platform="${cross_platform:-$platform}"
|
|
|
|
arch="${cross_arch:-$arch}"
|
|
|
|
build_dir="$(get_default_build_dir "$platform" "$arch")"
|
|
|
|
fi
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
# The source package doesn't require a previous build,
|
|
|
|
# nor the following install step, so run it now.
|
|
|
|
if [[ $source == true ]]; then source_package "lite-xl$version-src"; fi
|
|
|
|
|
|
|
|
# No packages request
|
|
|
|
if [[ $appimage == false && $binary == false && $dmg == false && $innosetup == false ]]; then
|
|
|
|
# Source only, return.
|
|
|
|
if [[ $source == true ]]; then return 0; fi
|
|
|
|
# Build the binary package as default instead doing nothing.
|
|
|
|
binary=true
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf "${dest_dir}"
|
|
|
|
|
2021-10-23 17:07:14 +02:00
|
|
|
DESTDIR="$(pwd)/${dest_dir}" meson install --skip-subprojects -C "${build_dir}"
|
2021-08-29 10:15:55 +02:00
|
|
|
|
|
|
|
local data_dir="$(pwd)/${dest_dir}/data"
|
|
|
|
local exe_file="$(pwd)/${dest_dir}/lite-xl"
|
2022-09-25 22:59:01 +02:00
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
local package_name=lite-xl$version-$platform-$arch
|
|
|
|
local bundle=false
|
2021-09-05 19:29:17 +02:00
|
|
|
local portable=false
|
2021-08-29 10:15:55 +02:00
|
|
|
local stripcmd="strip"
|
|
|
|
|
|
|
|
if [[ -d "${data_dir}" ]]; then
|
2021-09-05 19:29:17 +02:00
|
|
|
echo "Creating a portable, compressed archive..."
|
|
|
|
portable=true
|
2021-08-29 10:15:55 +02:00
|
|
|
exe_file="$(pwd)/${dest_dir}/lite-xl"
|
|
|
|
if [[ $platform == "windows" ]]; then
|
|
|
|
exe_file="${exe_file}.exe"
|
|
|
|
stripcmd="strip --strip-all"
|
2024-03-07 01:21:46 +01:00
|
|
|
if command -v ntldd >/dev/null 2>&1; then
|
|
|
|
# Copy MinGW libraries dependencies.
|
|
|
|
# MSYS2 ldd command seems to be only 64bit, so use ntldd
|
|
|
|
# see https://github.com/msys2/MINGW-packages/issues/4164
|
|
|
|
ntldd -R "${exe_file}" \
|
|
|
|
| grep mingw \
|
|
|
|
| awk '{print $3}' \
|
|
|
|
| sed 's#\\#/#g' \
|
|
|
|
| xargs -I '{}' cp -v '{}' "$(pwd)/${dest_dir}/"
|
|
|
|
else
|
|
|
|
echo "WARNING: ntldd not found; assuming program is static"
|
|
|
|
fi
|
2021-08-29 10:15:55 +02:00
|
|
|
else
|
|
|
|
# Windows archive is always portable
|
|
|
|
package_name+="-portable"
|
|
|
|
fi
|
|
|
|
elif [[ $platform == "macos" && ! -d "${data_dir}" ]]; then
|
|
|
|
data_dir="$(pwd)/${dest_dir}/Contents/Resources"
|
2021-09-05 19:29:17 +02:00
|
|
|
if [[ -d "${data_dir}" ]]; then
|
|
|
|
echo "Creating a macOS bundle application..."
|
|
|
|
bundle=true
|
|
|
|
# Specify "bundle" on compressed archive only, implicit on images
|
|
|
|
if [[ $dmg == false ]]; then package_name+="-bundle"; fi
|
|
|
|
rm -rf "Lite XL.app"; mv "${dest_dir}" "Lite XL.app"
|
|
|
|
dest_dir="Lite XL.app"
|
|
|
|
exe_file="$(pwd)/${dest_dir}/Contents/MacOS/lite-xl"
|
2022-01-29 14:16:51 +01:00
|
|
|
data_dir="$(pwd)/${dest_dir}/Contents/Resources"
|
2021-09-05 19:29:17 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $bundle == false && $portable == false ]]; then
|
2021-08-29 10:15:55 +02:00
|
|
|
data_dir="$(pwd)/${dest_dir}/$prefix/share/lite-xl"
|
|
|
|
exe_file="$(pwd)/${dest_dir}/$prefix/bin/lite-xl"
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "${data_dir}"
|
|
|
|
|
2022-09-25 22:59:01 +02:00
|
|
|
if [[ $addons == true ]]; then
|
|
|
|
addons_download "${build_dir}"
|
|
|
|
addons_install "${build_dir}" "${data_dir}"
|
|
|
|
fi
|
2021-08-29 10:15:55 +02:00
|
|
|
|
|
|
|
# TODO: use --skip-subprojects when 0.58.0 will be available on supported
|
|
|
|
# distributions to avoid subprojects' include and lib directories to be copied.
|
|
|
|
# Install Meson with PIP to get the latest version is not always possible.
|
|
|
|
pushd "${dest_dir}"
|
|
|
|
find . -type d -name 'include' -prune -exec rm -rf {} \;
|
|
|
|
find . -type d -name 'lib' -prune -exec rm -rf {} \;
|
|
|
|
find . -type d -empty -delete
|
|
|
|
popd
|
|
|
|
|
2022-09-25 22:59:01 +02:00
|
|
|
if [[ $release == true ]]; then
|
|
|
|
$stripcmd "${exe_file}"
|
|
|
|
fi
|
2021-08-29 10:15:55 +02:00
|
|
|
|
2023-11-10 02:36:44 +01:00
|
|
|
if [[ $bundle == true ]]; then
|
|
|
|
# https://eclecticlight.co/2019/01/17/code-signing-for-the-concerned-3-signing-an-app/
|
2024-06-18 05:38:41 +02:00
|
|
|
# https://wiki.lazarus.freepascal.org/Code_Signing_for_macOS#Big_Sur_and_later_on_Apple_M1_ARM64_processors
|
|
|
|
codesign --force --deep --digest-algorithm=sha1,sha256 -s - "${dest_dir}"
|
2023-11-10 02:36:44 +01:00
|
|
|
fi
|
|
|
|
|
2022-01-29 14:16:51 +01:00
|
|
|
echo "Creating a compressed archive ${package_name}"
|
2021-08-29 10:15:55 +02:00
|
|
|
if [[ $binary == true ]]; then
|
|
|
|
rm -f "${package_name}".tar.gz
|
|
|
|
rm -f "${package_name}".zip
|
|
|
|
|
|
|
|
if [[ $platform == "windows" ]]; then
|
|
|
|
zip -9rv ${package_name}.zip ${dest_dir}/*
|
|
|
|
else
|
|
|
|
tar czvf "${package_name}".tar.gz "${dest_dir}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-09-25 22:59:01 +02:00
|
|
|
if [[ $appimage == true ]]; then
|
|
|
|
source scripts/appimage.sh $flags --static
|
|
|
|
fi
|
|
|
|
if [[ $bundle == true && $dmg == true ]]; then
|
|
|
|
source scripts/appdmg.sh "${package_name}"
|
|
|
|
fi
|
|
|
|
if [[ $innosetup == true ]]; then
|
|
|
|
source scripts/innosetup/innosetup.sh $flags
|
|
|
|
fi
|
2021-08-29 10:15:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|