diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 0845774fb..133302a2e 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -83,6 +83,25 @@ jobs: 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 + + # Detect Ubuntu Codename + UBUNTU_CODENAME=$(lsb_release -cs) + + # If it's not a supported Ubuntu release, the build script + # should report failure to create Arch package while not + # affecting other packages. + + if [ "$UBUNTU_CODENAME" = "noble" ]; then + echo "Detected Ubuntu 24.04 (Noble). Installing official package..." + sudo apt-get install -y pacman-package-manager + elif [ "$UBUNTU_CODENAME" = "focal" ]; then + echo "Detected Ubuntu 20.04 (Focal). Installing community port..." + # Use the version compiled for glibc 2.31 (Ubuntu 20.04 standard) + wget https://github.com/ThePoorPilot/pacman-utils/releases/download/6.0.1-2_2.31-0/pacman-utils_6.0.1-2_amd64.deb + sudo dpkg -i pacman-utils_6.0.1-2_amd64.deb + sudo apt-get install -f -y + fi + - name: Download build uses: actions/download-artifact@v8 with: @@ -105,6 +124,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..37f0c1811 100755 --- a/build/scripts/package.linux.sh +++ b/build/scripts/package.linux.sh @@ -1,86 +1,124 @@ #!/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 + build_appimage + build_debian_package + build_rpm_package + build_arch_package +} + +build_appimage() { + 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() { + # 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() { + 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() { + 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 + + cd "resources/aur/" && makepkg + + cd ../../ # return to previous path + + if [[ -f "resources/aur/sourcegit-bin-${VERSION}-1-$(uname -m).pkg.tar.zst" ]]; then + mv resources/aur/sourcegit-bin*.pkg.tar.zst . + fi + else + echo -e "\033[0;31 ⚠ makepkg not found!\033\[0m" + fi +} + +main "$@"