Add repackage script in dev-utils folder

This commit is contained in:
Francesco Abbate
2020-12-16 11:33:42 +01:00
parent c3dd506bd7
commit 2ad9bbf0a6
2 changed files with 48 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
#!/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
tar_options+=($1)
shift
fi
local dirname="$1"
local destdir="$2"
git archive master "$dirname" --format=tar | tar xf - -C "$destdir" "${tar_options[@]}"
}
assets=($(wget --no-check-certificate -q -nv -O- https://api.github.com/repos/franko/lite-xl/releases/latest | grep "browser_download_url" | cut -d '"' -f 4))
workdir=".repackage"
rm -fr "$workdir" && mkdir "$workdir" && pushd "$workdir"
for url in "${assets[@]}"; do
wget --no-check-certificate "$url"
done
for filename in $(ls -1); do
if [[ $filename == *".zip" ]]; then
unzip "$filename"
elif [[ $filename == *".tar."* ]]; then
tar xf "$filename"
fi
rm "$filename"
xcoredir="$(find lite-xl -type d -name 'core')"
coredir="$(dirname $xcoredir)"
echo "coredir: $coredir"
for module_name in core plugins; do
rm -fr "$coredir/$module_name"
(cd .. && copy_directory_from_repo --strip-components=1 "data/$module_name" "$workdir/$coredir")
done
if [[ $filename == *".zip" ]]; then
zip -r -9 "$filename" lite-xl
elif [[ $filename == *".tar."* ]]; then
tar czf "${filename/%.tar.*/.tar.gz}" lite-xl
fi
rm -fr lite-xl
done
popd
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
rundir=".run"
if [ ${1:-x} == "-portable" ]; then
bindir="$rundir"
datadir="$rundir/data"
shift
else
bindir="$rundir/bin"
datadir="$rundir/share/lite-xl"
fi
userdir="$(realpath "$rundir")"
if [ "$#" -lt 1 ]; then
echo "usage: $0 <build-dir>"
exit 1
fi
builddir="$1"
rm -fr "$rundir"
mkdir -p "$bindir" "$datadir" "$userdir"
if [ -f "$builddir/src/lite" ]; then
cp "$builddir/src/lite" "$bindir"
elif [ -f "$builddir/src/lite.exe" ]; then
cp "$builddir/src/lite.exe" "$bindir"
else
echo "error: no lite executable found in $builddir/src"
exit 1
fi
for module_name in core plugins colors fonts; do
cp -r "data/$module_name" "$datadir"
done
HOME="$userdir" USERPROFILE="$userdir" exec "$bindir/lite" "${@:2}"