2020-12-16 11:33:42 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# strip-components is normally set to 1 to strip the initial "data" from the
|
|
|
|
# directory path.
|
|
|
|
copy_directory_from_repo () {
|
|
|
|
local tar_options=()
|
|
|
|
if [[ $1 == --strip-components=* ]]; then
|
2020-12-16 12:21:39 +01:00
|
|
|
tar_options+=($1)
|
|
|
|
shift
|
2020-12-16 11:33:42 +01:00
|
|
|
fi
|
|
|
|
local dirname="$1"
|
|
|
|
local destdir="$2"
|
2021-09-10 15:47:33 +02:00
|
|
|
git archive "$lite_branch" "$dirname" --format=tar | tar xf - -C "$destdir" "${tar_options[@]}"
|
2020-12-16 11:33:42 +01:00
|
|
|
}
|
|
|
|
|
2020-12-16 12:21:39 +01:00
|
|
|
lite_copy_third_party_modules () {
|
|
|
|
local build="$1"
|
2021-12-19 18:12:34 +01:00
|
|
|
curl --retry 5 --retry-delay 3 --insecure -L "https://github.com/lite-xl/lite-xl-colors/archive/master.zip" -o "$build/lite-xl-colors.zip" || exit 1
|
2020-12-16 12:21:39 +01:00
|
|
|
mkdir -p "$build/third/data/colors" "$build/third/data/plugins"
|
2021-12-19 18:12:34 +01:00
|
|
|
unzip -qq "$build/lite-xl-colors.zip" -d "$build"
|
|
|
|
mv "$build/lite-xl-colors-master/colors" "$build/third/data"
|
|
|
|
rm -fr "$build/lite-xl-colors-master"
|
|
|
|
rm "$build/lite-xl-colors.zip"
|
2020-12-16 12:21:39 +01:00
|
|
|
}
|
|
|
|
|
2021-09-10 15:47:33 +02:00
|
|
|
lite_branch=master
|
2021-01-02 09:46:15 +01:00
|
|
|
while [ ! -z ${1+x} ]; do
|
|
|
|
case "$1" in
|
|
|
|
-dir)
|
2021-01-04 13:43:11 +01:00
|
|
|
use_dir="$(realpath $2)"
|
2021-01-02 09:46:15 +01:00
|
|
|
shift 2
|
|
|
|
;;
|
2021-09-10 15:47:33 +02:00
|
|
|
-branch)
|
|
|
|
lite_branch="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2021-01-02 09:46:15 +01:00
|
|
|
*)
|
|
|
|
echo "unknown option: $1"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2020-12-16 11:33:42 +01:00
|
|
|
|
2021-01-20 15:41:12 +01:00
|
|
|
wget="wget --retry-connrefused --waitretry=1 --read-timeout=20 --no-check-certificate"
|
|
|
|
|
2020-12-16 11:33:42 +01:00
|
|
|
workdir=".repackage"
|
|
|
|
rm -fr "$workdir" && mkdir "$workdir" && pushd "$workdir"
|
|
|
|
|
2021-01-02 09:46:15 +01:00
|
|
|
fetch_packages_from_github () {
|
2021-01-20 15:41:12 +01:00
|
|
|
assets=($($wget -q -nv -O- https://api.github.com/repos/franko/lite-xl/releases/latest | grep "browser_download_url" | cut -d '"' -f 4))
|
2021-01-02 09:46:15 +01:00
|
|
|
|
|
|
|
for url in "${assets[@]}"; do
|
2020-12-16 12:21:39 +01:00
|
|
|
echo "getting: $url"
|
2021-01-20 15:41:12 +01:00
|
|
|
$wget -q "$url" || exit 1
|
2021-01-02 09:46:15 +01:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
fetch_packages_from_dir () {
|
|
|
|
for file in "$1"/*.zip "$1"/*.tar.* ; do
|
|
|
|
echo "copying file $file"
|
|
|
|
cp "$file" .
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -z ${use_dir+x} ]; then
|
|
|
|
fetch_packages_from_github
|
|
|
|
else
|
|
|
|
fetch_packages_from_dir "$use_dir"
|
|
|
|
fi
|
2020-12-16 11:33:42 +01:00
|
|
|
|
2020-12-16 12:21:39 +01:00
|
|
|
lite_copy_third_party_modules "."
|
|
|
|
|
|
|
|
for filename in $(ls -1 *.zip *.tar.*); do
|
2020-12-16 11:33:42 +01:00
|
|
|
if [[ $filename == *".zip" ]]; then
|
2020-12-16 12:21:39 +01:00
|
|
|
unzip -qq "$filename"
|
2020-12-16 11:33:42 +01:00
|
|
|
elif [[ $filename == *".tar."* ]]; then
|
|
|
|
tar xf "$filename"
|
|
|
|
fi
|
|
|
|
rm "$filename"
|
2021-01-02 09:46:15 +01:00
|
|
|
find lite-xl -name lite -exec chmod a+x '{}' \;
|
2021-09-10 15:48:43 +02:00
|
|
|
start_file=$(find lite-xl -name start.lua)
|
|
|
|
lite_version=$(cat "$start_file" | awk 'match($0, /^\s*VERSION\s*=\s*"(.+)"/, a) { print(a[1]) }')
|
2020-12-16 11:33:42 +01:00
|
|
|
xcoredir="$(find lite-xl -type d -name 'core')"
|
|
|
|
coredir="$(dirname $xcoredir)"
|
|
|
|
echo "coredir: $coredir"
|
2020-12-16 12:21:39 +01:00
|
|
|
cp -r "lite-xl" "lite-xl.original"
|
|
|
|
for module_name in core plugins colors; do
|
|
|
|
rm -fr "$coredir/$module_name"
|
|
|
|
(cd .. && copy_directory_from_repo --strip-components=1 "data/$module_name" "$workdir/$coredir")
|
|
|
|
done
|
2021-09-10 15:48:43 +02:00
|
|
|
sed -i "s/@PROJECT_VERSION@/$lite_version/g" "$start_file"
|
2020-12-16 12:21:39 +01:00
|
|
|
for module_name in plugins colors; do
|
|
|
|
cp -r "third/data/$module_name" "$coredir"
|
2020-12-16 11:33:42 +01:00
|
|
|
done
|
|
|
|
if [[ $filename == *".zip" ]]; then
|
2020-12-16 12:21:39 +01:00
|
|
|
zip -qq -r -9 "$filename" lite-xl
|
|
|
|
diff -U 4 -r lite-xl.original lite-xl > "${filename/%.zip/.diff}"
|
2020-12-16 11:33:42 +01:00
|
|
|
elif [[ $filename == *".tar."* ]]; then
|
|
|
|
tar czf "${filename/%.tar.*/.tar.gz}" lite-xl
|
2020-12-16 12:21:39 +01:00
|
|
|
diff -U 4 -r lite-xl.original lite-xl > "${filename/%.tar.*/.diff}"
|
2020-12-16 11:33:42 +01:00
|
|
|
fi
|
2020-12-16 12:21:39 +01:00
|
|
|
rm -fr lite-xl lite-xl.original
|
2020-12-16 11:33:42 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
popd
|
|
|
|
|