Last active
October 6, 2025 08:54
-
-
Save felipealfonsog/3004de70fdbd4b3985a66789f03d421b to your computer and use it in GitHub Desktop.
Arch Linux Bin repo generator script - for a personal server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| PACMAN_CONF="/etc/pacman.conf" | |
| REPO_NAME="gnlz" | |
| REPO_URL="https://gnlz.cl/repo/\$arch" | |
| if grep -q "^\[$REPO_NAME\]" "$PACMAN_CONF"; then | |
| echo ">> Repository [$REPO_NAME] already exists in $PACMAN_CONF" | |
| else | |
| echo ">> Adding repository [$REPO_NAME] to $PACMAN_CONF" | |
| sudo bash -c "cat >> $PACMAN_CONF" <<EOF | |
| [$REPO_NAME] | |
| SigLevel = Optional TrustAll | |
| Server = $REPO_URL | |
| EOF | |
| fi | |
| echo ">> Synchronizing pacman..." | |
| sudo pacman -Sy | |
| echo "✅ Repository [$REPO_NAME] added and pacman synchronized." | |
| echo ">> You can now install packages from the [$REPO_NAME] repository." | |
| echo ">> Example: sudo pacman -S package_name" | |
| echo ">> For more information, visit: https://gnlz.cl/repo/" | |
| echo ">> To remove the repository, edit $PACMAN_CONF and delete the [$REPO_NAME] section." | |
| echo ">> To refresh the package list, run: sudo pacman -Sy" | |
| echo ">> To uninstall packages from this repository, use: sudo pacman -R package_name" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| PKGVER="0.0.4.5" | |
| PKGNAME="term-pdf" | |
| SRC_DIR="$PWD/src" | |
| SRC_TARBALL="$PWD/term-pdf-${PKGVER}.tar.gz" | |
| BUILD_DIR="$PWD/srcbuild" | |
| PKGBUILD_FILE="$PWD/PKGBUILD" | |
| REPO_DIR="$PWD/repo/x86_64" | |
| REPO_NAME="gnlz" | |
| mkdir -p "$REPO_DIR" | |
| # --- Crear tarball válido desde src sin tocar proyecto original --- | |
| if [[ -f "$SRC_TARBALL" ]]; then | |
| FILE_TYPE=$(file -b "$SRC_TARBALL") | |
| if [[ "$FILE_TYPE" != *"gzip compressed data"* ]] && [[ "$FILE_TYPE" != *"POSIX tar archive"* ]]; then | |
| echo "Existing $SRC_TARBALL is invalid (detected type: $FILE_TYPE). Regenerating..." | |
| rm -f "$SRC_TARBALL" | |
| else | |
| echo "Using valid existing tarball: $SRC_TARBALL" | |
| fi | |
| fi | |
| if [[ ! -f "$SRC_TARBALL" ]]; then | |
| echo "Creating valid tarball $SRC_TARBALL from src folder..." | |
| tar czf "$SRC_TARBALL" -C "$SRC_DIR" . | |
| fi | |
| # --- Calcular SHA256 --- | |
| SHA256=$(sha256sum "$SRC_TARBALL" | awk '{print $1}') | |
| echo "SHA256: $SHA256" | |
| # --- Crear PKGBUILD dinámico --- | |
| cat > "$PKGBUILD_FILE" <<EOF | |
| pkgname=$PKGNAME | |
| pkgver=$PKGVER | |
| pkgrel=1 | |
| pkgdesc="TermPDF Viewer terminal PDF viewer" | |
| arch=('x86_64') | |
| url="https://gnlz.cl/repo/" | |
| license=('MIT') | |
| depends=('gcc' 'python-pip' 'python-pymupdf' 'python-termcolor') | |
| source=("$SRC_TARBALL") | |
| sha256sums=('$SHA256') | |
| prepare() { | |
| mkdir -p srcbuild | |
| tar xf "$SRC_TARBALL" -C srcbuild | |
| } | |
| build() { | |
| gcc -o srcbuild/term-pdf-wrp srcbuild/term-pdf-wrp.c | |
| } | |
| package() { | |
| install -Dm755 srcbuild/term-pdf-wrp "\$pkgdir/usr/local/bin/term-pdf" | |
| install -Dm755 srcbuild/termpdf.py "\$pkgdir/usr/local/bin/termpdf.py" | |
| } | |
| EOF | |
| # --- Limpiar build anterior --- | |
| rm -rf "$BUILD_DIR" | |
| # --- Construir paquete --- | |
| echo "Building package..." | |
| makepkg -f | |
| PKG_FILE="${PKGNAME}-${PKGVER}-1-x86_64.pkg.tar.zst" | |
| # --- Mover tarball y paquete al repo --- | |
| mv -f "$PKG_FILE" "$REPO_DIR/" | |
| mv -f "$SRC_TARBALL" "$REPO_DIR/" | |
| echo "Package and tarball moved to $REPO_DIR" | |
| # --- Generar o actualizar repo --- | |
| cd "$REPO_DIR" | |
| # Crear o actualizar la base de datos principal y la de archivos | |
| repo-add "${REPO_NAME}.db.tar.gz" *.pkg.tar.zst | |
| # Crear symlinks para compatibilidad con pacman | |
| ln -sf "${REPO_NAME}.db.tar.gz" "${REPO_NAME}.db" | |
| ln -sf "${REPO_NAME}.files.tar.gz" "${REPO_NAME}.files" | |
| echo "Repository updated at: $REPO_DIR" | |
| ls -l | |
| echo "Repo folder is ready to upload via FTP. Original project untouched." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| chmod +x buildpkg.sh addrepo.sh | |
| ./buildpkg.sh | |
| -- | |
| repo/x86_64/term-pdf-0.0.4.4-1-x86_64.pkg.tar.zst | |
| repo/x86_64/gnlz.db | |
| repo/x86_64/gnlz.files | |
| -- | |
| ./addrepo.sh | |
| sudo pacman -Sy mypack |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment