diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 0845774fb..4939877d2 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -82,12 +82,88 @@ jobs: export DEBIAN_FRONTEND=noninteractive ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime apt-get update - apt-get install -y curl wget git dpkg-dev fakeroot tzdata zip unzip desktop-file-utils rpm libfuse2 file build-essential binutils + apt-get install -y curl wget git dpkg-dev fakeroot tzdata \ + zip unzip desktop-file-utils rpm libfuse2 \ + file build-essential binutils zstd + + # Detect Ubuntu Codename + UBUNTU_CODENAME=$(. /etc/os-release && echo "$VERSION_CODENAME") + + if [ "$UBUNTU_CODENAME" = "noble" ]; then + echo "Detected Ubuntu 24.04 (Noble). Installing official package..." + apt-get install -y pacman-package-manager + elif [ "$UBUNTU_CODENAME" = "focal" ]; then + echo "Detected Ubuntu 20.04 (Focal). Building Arch Linux packaging tools..." + # + # Install pacman, makepkg, and Arch packaging utilities on Ubuntu Linux + # + # Written 2024-06-27 by Ronald Joe Record + + apt-get install -y pkg-config meson gcc libtool libgpgme-dev \ + libarchive-dev ninja-build libcurl4-openssl-dev \ + libssl-dev curl gettext python3 python3-setuptools \ + dash gawk ca-certificates fakechroot \ + libarchive-tools + + # Need a more recent version of Meson + mkdir -p /usr/local/meson + git clone https://github.com/mesonbuild/meson.git /usr/local/meson + CWD=$(pwd) + cd /usr/local/meson + git fetch --tags + git checkout 1.4.2 + cd $CWD + + [ -f /usr/bin/meson ] && { + mver=$(/usr/bin/meson --version) + mv /usr/bin/meson /usr/bin/meson-${mver} + } + + if [ -f /usr/local/meson/meson.py ]; then + ln -s /usr/local/meson/meson.py /usr/bin/meson + else + echo "ERROR: cannot locate /usr/local/meson/meson.py" + exit 1 + fi + + rm -rf pacman + git clone https://gitlab.archlinux.org/pacman/pacman.git + CWD=$(pwd) + cd pacman + meson setup -Ddoc=disabled build + ninja -C build + + [ -d build ] || { + echo "Directory pacman/build does not exist. Exiting." + exit 1 + } + cd build + + grep mirror scripts/libmakepkg/source/git.sh > /dev/null && { + cat scripts/libmakepkg/source/git.sh | sed -e "s/---mirror//" > /tmp/git$$ + cp /tmp/git$$ scripts/libmakepkg/source/git.sh + rm -f /tmp/git$$ + } + + meson install --no-rebuild --quiet + + cd $CWD + fi + + # Swap Arch package file extension + sed -i "s/^PKGEXT='.pkg.tar.gz'$/PKGEXT='.pkg.tar.zst'/" /etc/makepkg.conf + - name: Download build uses: actions/download-artifact@v8 with: name: sourcegit.${{ matrix.runtime }} path: build + - name: Create package user + run: | + apt-get install -y sudo + useradd -m pkguser + echo "pkguser ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers + chown -R pkguser:pkguser build - name: Package env: VERSION: ${{ inputs.version }} @@ -105,6 +181,8 @@ jobs: build/sourcegit-*.AppImage build/sourcegit_*.deb build/sourcegit-*.rpm + build/sourcegit-*.pkg.tar.zst + build/sourcegit-*.pkg.tar.xz - name: Delete temp artifacts uses: geekyeggo/delete-artifact@v6 with: diff --git a/build/resources/aur/PKGBUILD b/build/resources/aur/PKGBUILD new file mode 100644 index 000000000..a5e690860 --- /dev/null +++ b/build/resources/aur/PKGBUILD @@ -0,0 +1,47 @@ +# Modified for for sourcegit repo relase builds. +# Special thanks to the AUR package maintainer: Aikawa Yataro + +pkgname=sourcegit-bin +_name="${pkgname%-bin}" +pkgver=$VERSION +pkgrel=1 +pkgdesc="GUI client for GIT users" +arch=('x86_64') +url='https://github.com/sourcegit-scm/sourcegit' +license=('MIT') +provides=('sourcegit') +conflicts=('sourcegit') +depends=('git' 'xdg-utils') +optdepends=('git-credential-manager: third-party authentication support') +makedepends=('desktop-file-utils') +options=('!debug') + +prepare() { + local _desktop_file="${startdir}/usr/share/applications/${_name}.desktop" + +# desktop-file-install + + if [[ -f "$_desktop_file" ]]; then + desktop-file-edit "$_desktop_file" \ + --set-icon="${_name}" \ + --set-key=Exec \ + --set-value="${_name}" + fi +} + +package() { + install -d "$pkgdir/opt/$_name/" + install -d "$pkgdir/usr/bin/" + + cp -ra "${startdir}/opt/"* "${pkgdir}/opt/" + cp -ra "${startdir}/usr/"* "${pkgdir}/usr/" + + install -Dm644 "${startdir}/usr/share/applications/${_name}.desktop" \ + "${pkgdir}/usr/share/applications/${_name}.desktop" + + install -Dm644 "${startdir}/usr/share/icons/${_name}.png" \ + "${pkgdir}/usr/share/icons/hicolor/256x256/apps/${_name}.png" + + install -Dm644 "${startdir}/LICENSE" \ + "${pkgdir}/usr/share/licenses/${_realname}/LICENSE" +} diff --git a/build/scripts/package.linux.sh b/build/scripts/package.linux.sh index 262f141ae..aad6fe05c 100755 --- a/build/scripts/package.linux.sh +++ b/build/scripts/package.linux.sh @@ -1,86 +1,144 @@ #!/usr/bin/env bash -set -e -set -o -set -u -set pipefail - -# ICU versions to support (Debian has no virtual package, must list all) -# Format: space-separated version numbers -ICU_VERSIONS="78 77 76 74 72 71 70 69 68 67 66 65 63" +set -euo pipefail arch= appimage_arch= target= -case "$RUNTIME" in - linux-x64) - arch=amd64 - appimage_arch=x86_64 - target=x86_64;; - linux-arm64) - arch=arm64 - appimage_arch=arm_aarch64 - target=aarch64;; - *) - echo "Unknown runtime $RUNTIME" - exit 1;; -esac - -APPIMAGETOOL_URL=https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage - -cd build - -if [[ ! -f "appimagetool" ]]; then - curl -o appimagetool -L "$APPIMAGETOOL_URL" - chmod +x appimagetool -fi - -rm -f SourceGit/*.dbg -rm -f SourceGit/*.pdb - -mkdir -p SourceGit.AppDir/opt -mkdir -p SourceGit.AppDir/usr/share/metainfo -mkdir -p SourceGit.AppDir/usr/share/applications - -cp -r SourceGit SourceGit.AppDir/opt/sourcegit -desktop-file-install resources/_common/applications/sourcegit.desktop --dir SourceGit.AppDir/usr/share/applications \ - --set-icon com.sourcegit_scm.SourceGit --set-key=Exec --set-value=AppRun -mv SourceGit.AppDir/usr/share/applications/{sourcegit,com.sourcegit_scm.SourceGit}.desktop -cp resources/_common/icons/sourcegit.png SourceGit.AppDir/com.sourcegit_scm.SourceGit.png -ln -rsf SourceGit.AppDir/opt/sourcegit/sourcegit SourceGit.AppDir/AppRun -ln -rsf SourceGit.AppDir/usr/share/applications/com.sourcegit_scm.SourceGit.desktop SourceGit.AppDir -cp resources/appimage/sourcegit.appdata.xml SourceGit.AppDir/usr/share/metainfo/com.sourcegit_scm.SourceGit.appdata.xml - -ARCH="$appimage_arch" ./appimagetool -v SourceGit.AppDir "sourcegit-$VERSION.linux.$arch.AppImage" - -mkdir -p resources/deb/opt/sourcegit/ -mkdir -p resources/deb/usr/bin -mkdir -p resources/deb/usr/share/applications -mkdir -p resources/deb/usr/share/icons -cp -f SourceGit/* resources/deb/opt/sourcegit -ln -rsf resources/deb/opt/sourcegit/sourcegit resources/deb/usr/bin -cp -r resources/_common/applications resources/deb/usr/share -cp -r resources/_common/icons resources/deb/usr/share - -# Calculate installed size in KB -installed_size=$(du -sk resources/deb | cut -f1) - -# Generate ICU dependencies string for Debian -# Debian lacks libicu virtual package, must list all versions with OR operator -icu_deps="libicu" -for v in $ICU_VERSIONS; do - icu_deps="$icu_deps | libicu$v" -done - -# Update the control file (replace placeholder, not whole Depends line) -sed -i -e "s/^Version:.*/Version: $VERSION/" \ - -e "s/^Architecture:.*/Architecture: $arch/" \ - -e "s/^Installed-Size:.*/Installed-Size: $installed_size/" \ - -e "s/@ICU_DEPS@/$icu_deps/" \ - resources/deb/DEBIAN/control - -# Build deb package with gzip compression -dpkg-deb -Zgzip --root-owner-group --build resources/deb "sourcegit_$VERSION-1_$arch.deb" - -rpmbuild -bb --target="$target" resources/rpm/SPECS/build.spec --define "_topdir $(pwd)/resources/rpm" --define "_version $VERSION" -mv "resources/rpm/RPMS/$target/sourcegit-$VERSION-1.$target.rpm" ./ + +main() { + case "$RUNTIME" in + linux-x64) + arch=amd64 + appimage_arch=x86_64 + target=x86_64;; + linux-arm64) + arch=arm64 + appimage_arch=arm_aarch64 + target=aarch64;; + *) + echo "Unknown runtime $RUNTIME" + exit 1;; + esac + + cd build + echo "======== Creating Linux Packaging For Version: $VERSION ========" + + build_appimage + build_debian_package + build_rpm_package + build_arch_package + + echo "======== Package Creation Complete For Version: $VERSION ========" +} + +build_appimage() { + echo "-------- Creating AppImage Package --------" + APPIMAGETOOL_URL=https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage + + + if [[ ! -f "appimagetool" ]]; then + curl -o appimagetool -L "$APPIMAGETOOL_URL" + chmod +x appimagetool + fi + + rm -f SourceGit/*.dbg + rm -f SourceGit/*.pdb + + mkdir -p SourceGit.AppDir/opt + mkdir -p SourceGit.AppDir/usr/share/metainfo + mkdir -p SourceGit.AppDir/usr/share/applications + + cp -r SourceGit SourceGit.AppDir/opt/sourcegit + desktop-file-install resources/_common/applications/sourcegit.desktop --dir SourceGit.AppDir/usr/share/applications \ + --set-icon com.sourcegit_scm.SourceGit --set-key=Exec --set-value=AppRun + mv SourceGit.AppDir/usr/share/applications/{sourcegit,com.sourcegit_scm.SourceGit}.desktop + cp resources/_common/icons/sourcegit.png SourceGit.AppDir/com.sourcegit_scm.SourceGit.png + ln -rsf SourceGit.AppDir/opt/sourcegit/sourcegit SourceGit.AppDir/AppRun + ln -rsf SourceGit.AppDir/usr/share/applications/com.sourcegit_scm.SourceGit.desktop SourceGit.AppDir + cp resources/appimage/sourcegit.appdata.xml SourceGit.AppDir/usr/share/metainfo/com.sourcegit_scm.SourceGit.appdata.xml + + ARCH="$appimage_arch" ./appimagetool -v SourceGit.AppDir "sourcegit-$VERSION.linux.$arch.AppImage" +} + +build_debian_package() { + echo "-------- Creating Debian/Ubuntu Package --------" + # ICU versions to support (Debian has no virtual package, must list all) + # Format: space-separated version numbers + ICU_VERSIONS="78 77 76 74 72 71 70 69 68 67 66 65 63" + + mkdir -p resources/deb/opt/sourcegit/ + mkdir -p resources/deb/usr/bin + mkdir -p resources/deb/usr/share/applications + mkdir -p resources/deb/usr/share/icons + cp -f SourceGit/* resources/deb/opt/sourcegit + ln -rsf resources/deb/opt/sourcegit/sourcegit resources/deb/usr/bin + cp -r resources/_common/applications resources/deb/usr/share + cp -r resources/_common/icons resources/deb/usr/share + + # Calculate installed size in KB + installed_size=$(du -sk resources/deb | cut -f1) + + # Generate ICU dependencies string for Debian + # Debian lacks libicu virtual package, must list all versions with OR operator + icu_deps="libicu" + for v in $ICU_VERSIONS; do + icu_deps="$icu_deps | libicu$v" + done + + # Update the control file (replace placeholder, not whole Depends line) + sed -i -e "s/^Version:.*/Version: $VERSION/" \ + -e "s/^Architecture:.*/Architecture: $arch/" \ + -e "s/^Installed-Size:.*/Installed-Size: $installed_size/" \ + -e "s/@ICU_DEPS@/$icu_deps/" \ + resources/deb/DEBIAN/control + + # Build deb package with gzip compression + dpkg-deb -Zgzip --root-owner-group --build resources/deb "sourcegit_$VERSION-1_$arch.deb" +} + +build_rpm_package() { + echo "-------- Creating RPM Package --------" + rpmbuild -bb --target="$target" resources/rpm/SPECS/build.spec --define "_topdir $(pwd)/resources/rpm" --define "_version $VERSION" + + mv "resources/rpm/RPMS/$target/sourcegit-$VERSION-1.$target.rpm" ./ +} + +build_arch_package() { + echo "-------- Creating ARCH Package --------" + if command -v makepkg &> /dev/null; then + mkdir -p resources/aur/opt/sourcegit/ + mkdir -p resources/aur/usr/bin + mkdir -p resources/aur/usr/share/applications + mkdir -p resources/aur/usr/share/icons + cp ../LICENSE resources/aur/ + cp -f SourceGit/* resources/aur/opt/sourcegit + ln -rsf resources/aur/opt/sourcegit/sourcegit resources/aur/usr/bin + cp -r resources/_common/applications resources/aur/usr/share + cp -r resources/_common/icons resources/aur/usr/share + + chown -R pkguser:pkguser ./ + + cd "resources/aur/" || exit 1 + + if [ "$(id -u)" -eq 0 ]; then + sudo -E -u pkguser makepkg --nodeps + else + makepkg --nodeps + fi + + if find . -maxdepth 1 -type f -name "sourcegit*.pkg.tar.zst" -o -name "sourcegit*.pkg.tar.xz" -quit | grep -q .; then + echo "Copying Arch package for artifact upload" + cp sourcegit*.pkg.tar.zst ../../ + else + echo "Arch package file not found." + echo "$(ls -alh .)" + fi + + cd ../../ # return to previous path + else + echo -e "\033[0;31 ⚠ makepkg not found!\033\[0m" + fi +} + +main "$@"