🔧 build: add post installation script for the assistant

This commit is contained in:
eshanized
2024-12-31 04:48:53 +05:30
parent 506192f2f4
commit 0effc8d7ce
2 changed files with 45 additions and 8 deletions

View File

@@ -3,35 +3,39 @@
pkgname=snigdhaos-assistant pkgname=snigdhaos-assistant
pkgver=r251.f2df36f4 pkgver=r251.f2df36f4
_pkgver=$(curl -s https://api.github.com/repos/Snigdha-OS/snigdhaos-assistant/releases/latest | jq -r .tag_name) _pkgver=$(curl -fsSL https://api.github.com/repos/Snigdha-OS/snigdhaos-assistant/releases/latest | jq -r .tag_name)
pkgrel=1 pkgrel=1
pkgdesc="A setup utility for Snigdha OS which helps setting up & installing applications" pkgdesc="A setup utility for Snigdha OS which helps setting up & installing applications"
arch=('any') arch=('any')
url="https://gitlab.com/snigdhaos/snigdhaos-assistant/" url="https://gitlab.com/snigdhaos/snigdhaos-assistant/"
license=('MIT') license=('MIT')
depends=('yad' 'wget' 'qt5-base' 'curl' 'jq') depends=('yad' 'wget' 'qt5-base' 'curl' 'jq')
optdepends=('pamac') optdepends=('pamac: For managing packages')
makedepends=('git' 'cmake') makedepends=('git' 'cmake')
groups=() groups=()
source=("https://github.com/Snigdha-OS/${pkgname}/archive/refs/tags/${_pkgver}.tar.gz") source=("https://github.com/Snigdha-OS/${pkgname}/archive/refs/tags/${_pkgver}.tar.gz")
sha256sums=('SKIP') sha256sums=('SKIP')
install=${pkgname}.install
pkgver() { pkgver() {
# Print package version as 'rX.XXXX' # Extract the version from the tag name, removing the 'v' prefix if present.
printf "%s" "${_pkgver#v}" printf "%s" "${_pkgver#v}"
} }
build() { build() {
# Ensure the build directory exists
cmake -B build -S "$pkgname-$_pkgver" \ cmake -B build -S "$pkgname-$_pkgver" \
-DCMAKE_BUILD_TYPE='Release' \ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX='/usr' \ -DCMAKE_INSTALL_PREFIX=/usr \
-Wno-dev -Wno-dev
make -C build make -C build
} }
package() { package() {
# Install built files to the package directory
make -C build DESTDIR="$pkgdir" install make -C build DESTDIR="$pkgdir" install
install -d "$pkgdir"/usr # Ensure proper directory structure
cp -rf "$srcdir"/$pkgname-$_pkgver/usr "$pkgdir" install -d "$pkgdir/usr"
cp -rf "$srcdir/$pkgname-$_pkgver/usr" "$pkgdir"
} }

View File

@@ -0,0 +1,33 @@
post_install() {
echo "\n[INFO] Snigdha OS Assistant successfully installed!\n"
echo "\n[INFO] Post-installation steps are being executed...\n"
# Ensure necessary directories are created
echo "[INFO] Verifying required directories..."
mkdir -p "$HOME/.snigdhaos" && echo "[OK] Directory $HOME/.snigdhaos created." || echo "[WARNING] Could not create $HOME/.snigdhaos."
# Generate a default configuration file if it does not exist
CONFIG_FILE="$HOME/.snigdhaos/assistant-config.json"
if [[ ! -f "$CONFIG_FILE" ]]; then
echo "[INFO] Creating a default configuration file at $CONFIG_FILE..."
cat <<EOL > "$CONFIG_FILE"
{
"default_applications": [
"firefox",
"code",
"vlc"
],
"auto_update": true
}
EOL
echo "[OK] Default configuration file created."
else
echo "[INFO] Configuration file already exists at $CONFIG_FILE. Skipping creation."
fi
# Inform the user of the next steps
echo "\n[INFO] Post-installation completed. You can now launch Snigdha OS Assistant using the command 'snigdhaos-assistant'."
echo "\n[INFO] For configuration, edit the file at $CONFIG_FILE."
}
post_install