mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-11 00:15:37 +03:00
build: 📦 package as an archive with install script
This commit is contained in:
parent
47463ae380
commit
58d8e21bf5
@ -14,7 +14,6 @@ To make sure you can develop the script install all the tools you need:
|
||||
|
||||
- [REUSE tool](https://git.fsfe.org/reuse/tool#install)
|
||||
- [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
|
||||
- p7zip
|
||||
|
||||
## 👷 Prepare environment
|
||||
|
||||
|
14
bin/build.sh
14
bin/build.sh
@ -7,9 +7,7 @@
|
||||
set -e
|
||||
|
||||
# Make necessary directories
|
||||
mkdir -p "${npm_package_config_build_dir:=build}/contents/code"
|
||||
mkdir -p "$npm_package_config_build_dir/contents/config"
|
||||
mkdir -p "$npm_package_config_build_dir/contents/ui"
|
||||
mkdir -p "${npm_package_config_build_dir:=build}/script/contents/code"
|
||||
|
||||
echo "Checking using TS Compiler..."
|
||||
npx tsc --noEmit
|
||||
@ -17,18 +15,16 @@ npx tsc --noEmit
|
||||
echo "Bundling using esbuild..."
|
||||
npx esbuild \
|
||||
--bundle src/index.ts \
|
||||
--outfile="$npm_package_config_build_dir/contents/code/index.mjs" \
|
||||
--outfile="$npm_package_config_build_dir/script/contents/code/index.mjs" \
|
||||
--format=esm \
|
||||
--platform=neutral
|
||||
|
||||
# Copy resources to the build directory with correct paths
|
||||
cp -v res/config.ui "$npm_package_config_build_dir/contents/ui/config.ui"
|
||||
cp -v res/popup.qml "$npm_package_config_build_dir/contents/ui/popup.qml"
|
||||
cp -v res/main.qml "$npm_package_config_build_dir/contents/ui/main.qml"
|
||||
cp -v res/config.xml "$npm_package_config_build_dir/contents/config/main.xml"
|
||||
cp -rv res/ui "$npm_package_config_build_dir/script/contents"
|
||||
cp -rv res/config "$npm_package_config_build_dir/script/contents"
|
||||
|
||||
# Copy and update metadata
|
||||
METADATA_FILE="$npm_package_config_build_dir/metadata.desktop"
|
||||
METADATA_FILE="$npm_package_config_build_dir/script/metadata.desktop"
|
||||
|
||||
cp -v res/metadata.desktop "$METADATA_FILE"
|
||||
sed -i "s/\$VER/${npm_package_version:-1.0}/" "$METADATA_FILE"
|
||||
|
@ -6,17 +6,16 @@
|
||||
|
||||
set -e
|
||||
|
||||
# Install icons
|
||||
APP_ICONS_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/icons/hicolor/scalable/apps"
|
||||
mkdir -p "$APP_ICONS_DIR"
|
||||
cp -v res/icons/bismuth.svg "$APP_ICONS_DIR/bismuth.svg"
|
||||
EXTRACT_DIR="${npm_package_config_build_dir:-build}/extracted-package"
|
||||
|
||||
# Display info and upgrade/install script
|
||||
KWINPKG_FILE="${npm_package_config_build_dir:-build}/${npm_package_name:=Bismuth}-${npm_package_version:-1.0}.kwinscript"
|
||||
plasmapkg2 -u "$KWINPKG_FILE" || plasmapkg2 -i "$KWINPKG_FILE"
|
||||
plasmapkg2 -t kwinscript -s "$npm_package_name"
|
||||
# Make directory for extraction
|
||||
mkdir -p "$EXTRACT_DIR"
|
||||
|
||||
# Enable user configuration dialog
|
||||
mkdir -p ~/.local/share/kservices5/
|
||||
ln -sf ~/.local/share/kwin/scripts/bismuth/metadata.desktop ~/.local/share/kservices5/bismuth.desktop
|
||||
# Extract built package
|
||||
tar xf "${npm_package_config_build_dir:-build}/package/bismuth.tar.gz" --directory="$EXTRACT_DIR"
|
||||
|
||||
# Run installation script
|
||||
cd "$EXTRACT_DIR"
|
||||
./install.sh
|
||||
cd - > /dev/null
|
||||
|
||||
|
@ -6,10 +6,35 @@
|
||||
|
||||
set -e
|
||||
|
||||
KWINPKG_FILE="${npm_package_config_build_dir:=build}/${npm_package_name:-Bismuth}-${npm_package_version:-1.0}.kwinscript"
|
||||
KWINPKG_NAME="bismuth.kwinscript"
|
||||
FINAL_ARCHIVE_NAME="bismuth.tar.gz"
|
||||
|
||||
# Remove old archive
|
||||
rm -f "$KWINPKG_FILE"
|
||||
# Temporary change directory for archive tools
|
||||
cd "./${npm_package_config_build_dir:-build}/script"
|
||||
|
||||
# Create new installable package
|
||||
7z a -tzip "$KWINPKG_FILE" ./${npm_package_config_build_dir}/contents/ ./${npm_package_config_build_dir}/metadata.desktop
|
||||
# Remove old packages
|
||||
rm -f "$KWINPKG_NAME"
|
||||
|
||||
# Create new .kwinscript package
|
||||
zip -qr "$KWINPKG_NAME" ./contents/ ./metadata.desktop
|
||||
|
||||
# Get back to the original directory
|
||||
cd - > /dev/null
|
||||
|
||||
# Create subdir for final package
|
||||
mkdir -p "./${npm_package_config_build_dir:-build}/package"
|
||||
cd "./${npm_package_config_build_dir:-build}/package"
|
||||
|
||||
# Copy necessary files for package
|
||||
cp -v "../script/$KWINPKG_NAME" "$KWINPKG_NAME"
|
||||
cp -v "../../res/install.sh" install.sh
|
||||
mkdir -p icons/ && cp -v "../../res/icons/bismuth.svg" icons/bismuth.svg
|
||||
|
||||
# Create installation archive for the end user
|
||||
tar -czf "$FINAL_ARCHIVE_NAME" \
|
||||
"$KWINPKG_NAME" \
|
||||
install.sh \
|
||||
icons/bismuth.svg
|
||||
|
||||
# Get back to the original directory
|
||||
cd - > /dev/null
|
||||
|
26
res/install.sh
Normal file
26
res/install.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# Installation script, that comes inside of the tar.gz package
|
||||
|
||||
set -e
|
||||
|
||||
# Install icons
|
||||
echo "🖼️ Installing icons..."
|
||||
APP_ICONS_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/icons/hicolor/scalable/apps"
|
||||
mkdir -p "$APP_ICONS_DIR"
|
||||
cp icons/bismuth.svg "$APP_ICONS_DIR/bismuth.svg"
|
||||
|
||||
# Upgrade/install script
|
||||
echo "📦 Installing the script..."
|
||||
KWINPKG_FILE="bismuth.kwinscript"
|
||||
plasmapkg2 -u "$KWINPKG_FILE" > /dev/null || plasmapkg2 -i "$KWINPKG_FILE" > /dev/null
|
||||
|
||||
# Enable user configuration dialog
|
||||
echo "🔧 Enabling user configuration..."
|
||||
mkdir -p ~/.local/share/kservices5/
|
||||
ln -sf ~/.local/share/kwin/scripts/bismuth/metadata.desktop ~/.local/share/kservices5/bismuth.desktop
|
||||
|
Loading…
Reference in New Issue
Block a user