mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-17 11:37:10 +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)
|
- [REUSE tool](https://git.fsfe.org/reuse/tool#install)
|
||||||
- [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
|
- [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
|
||||||
- p7zip
|
|
||||||
|
|
||||||
## 👷 Prepare environment
|
## 👷 Prepare environment
|
||||||
|
|
||||||
|
14
bin/build.sh
14
bin/build.sh
@ -7,9 +7,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Make necessary directories
|
# Make necessary directories
|
||||||
mkdir -p "${npm_package_config_build_dir:=build}/contents/code"
|
mkdir -p "${npm_package_config_build_dir:=build}/script/contents/code"
|
||||||
mkdir -p "$npm_package_config_build_dir/contents/config"
|
|
||||||
mkdir -p "$npm_package_config_build_dir/contents/ui"
|
|
||||||
|
|
||||||
echo "Checking using TS Compiler..."
|
echo "Checking using TS Compiler..."
|
||||||
npx tsc --noEmit
|
npx tsc --noEmit
|
||||||
@ -17,18 +15,16 @@ npx tsc --noEmit
|
|||||||
echo "Bundling using esbuild..."
|
echo "Bundling using esbuild..."
|
||||||
npx esbuild \
|
npx esbuild \
|
||||||
--bundle src/index.ts \
|
--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 \
|
--format=esm \
|
||||||
--platform=neutral
|
--platform=neutral
|
||||||
|
|
||||||
# Copy resources to the build directory with correct paths
|
# Copy resources to the build directory with correct paths
|
||||||
cp -v res/config.ui "$npm_package_config_build_dir/contents/ui/config.ui"
|
cp -rv res/ui "$npm_package_config_build_dir/script/contents"
|
||||||
cp -v res/popup.qml "$npm_package_config_build_dir/contents/ui/popup.qml"
|
cp -rv res/config "$npm_package_config_build_dir/script/contents"
|
||||||
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"
|
|
||||||
|
|
||||||
# Copy and update metadata
|
# 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"
|
cp -v res/metadata.desktop "$METADATA_FILE"
|
||||||
sed -i "s/\$VER/${npm_package_version:-1.0}/" "$METADATA_FILE"
|
sed -i "s/\$VER/${npm_package_version:-1.0}/" "$METADATA_FILE"
|
||||||
|
@ -6,17 +6,16 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Install icons
|
EXTRACT_DIR="${npm_package_config_build_dir:-build}/extracted-package"
|
||||||
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"
|
|
||||||
|
|
||||||
# Display info and upgrade/install script
|
# Make directory for extraction
|
||||||
KWINPKG_FILE="${npm_package_config_build_dir:-build}/${npm_package_name:=Bismuth}-${npm_package_version:-1.0}.kwinscript"
|
mkdir -p "$EXTRACT_DIR"
|
||||||
plasmapkg2 -u "$KWINPKG_FILE" || plasmapkg2 -i "$KWINPKG_FILE"
|
|
||||||
plasmapkg2 -t kwinscript -s "$npm_package_name"
|
|
||||||
|
|
||||||
# Enable user configuration dialog
|
# Extract built package
|
||||||
mkdir -p ~/.local/share/kservices5/
|
tar xf "${npm_package_config_build_dir:-build}/package/bismuth.tar.gz" --directory="$EXTRACT_DIR"
|
||||||
ln -sf ~/.local/share/kwin/scripts/bismuth/metadata.desktop ~/.local/share/kservices5/bismuth.desktop
|
|
||||||
|
# Run installation script
|
||||||
|
cd "$EXTRACT_DIR"
|
||||||
|
./install.sh
|
||||||
|
cd - > /dev/null
|
||||||
|
|
||||||
|
@ -6,10 +6,35 @@
|
|||||||
|
|
||||||
set -e
|
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
|
# Temporary change directory for archive tools
|
||||||
rm -f "$KWINPKG_FILE"
|
cd "./${npm_package_config_build_dir:-build}/script"
|
||||||
|
|
||||||
# Create new installable package
|
# Remove old packages
|
||||||
7z a -tzip "$KWINPKG_FILE" ./${npm_package_config_build_dir}/contents/ ./${npm_package_config_build_dir}/metadata.desktop
|
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