This repository has been archived on 2026-10-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
omarchy-pkgs/pkgbuilds/shared/github-copilot-cli/PKGBUILD
T

79 lines
2.6 KiB
Bash

# Maintainer: Rafael Dominiquini <rafaeldominiquini at gmail dot com>
# Co-maintainer: edu4rdshl <edu4rdshl at protonmail dot com>
_npmmodule=@github/copilot
pkgname=github-copilot-cli
_pkgexec=copilot
pkgver=1.0.8
pkgrel=1
pkgdesc="GitHub Copilot CLI brings the power of Copilot coding agent directly to your terminal."
url="https://github.com/github/copilot-cli"
_urlraw="https://raw.githubusercontent.com/github/copilot-cli/v${pkgver}"
arch=("x86_64")
license=("LicenseRef-GitHub-Copilot")
conflicts=("${pkgname%%-cli}" "${pkgname}-legacy")
depends=("glibc" "gcc-libs" "nodejs" "glib2" "libsecret")
replaces=("${pkgname%%-cli}")
makedepends=("npm" "jq")
provides=("${_pkgexec}")
options=(!strip emptydirs staticlibs zipman)
source=("https://registry.npmjs.org/${_npmmodule}/-/copilot-${pkgver}.tgz"
"CHANGELOG-${pkgver}.md::${_urlraw}/changelog.md")
noextract=("copilot-${pkgver}.tgz")
b2sums=('cddde05f393e0ba53a1c5df85ed8790160406d9e0db9bba23901437373d6b58be7f1fe60ce1d6b59a72a2bdaf2d0611fa9db5c3e1e4c033dd24d305db2c8e5e9'
'19b3f94e4034f266376cde3429c0a189b69a4111b4991d94039c7185389e3e56c482b67b014ab159debf5910f91a928772e04fb7ef3d386d740972986f4b5943')
# Document: https://wiki.archlinux.org/title/Node.js_package_guidelines
package() {
msg2 "Install using Using NPM"
npm install -s -g \
--cache "${srcdir}/npm-cache" \
--prefix "${pkgdir}/usr" \
"${srcdir}/copilot-${pkgver}.tgz"
msg2 "Fix ownership of ALL FILES"
find "${pkgdir}/usr" -type d -exec chmod 755 {} +
chown -R root:root "${pkgdir}"
msg2 "Remove references to PKGDIR"
find "${pkgdir}" -name package.json -print0 | xargs -r -0 sed -i '/_where/d'
msg2 "Fixing 'package.json'"
local tmppackage="$(mktemp)"
local pkgjson="${pkgdir}/usr/lib/node_modules/${_npmmodule}/package.json"
jq '.|=with_entries(select(.key|test("_.+")|not))' "${pkgjson}" > "${tmppackage}"
mv "${tmppackage}" "${pkgjson}"
chmod 644 "${pkgjson}"
msg2 "More fixes for 'package.json'"
find "${pkgdir}" -type f -name package.json | while read pkgjson; do
local tmppackage="$(mktemp)"
jq 'del(.man)' "${pkgjson}" > "${tmppackage}"
mv "${tmppackage}" "${pkgjson}"
chmod 644 "${pkgjson}"
done
msg2 "Install README file"
install -dm755 "${pkgdir}/usr/share/doc/${pkgname}/"
ln -sf "/usr/lib/node_modules/${_npmmodule}/README.md" "${pkgdir}/usr/share/doc/${pkgname}/README.md"
msg2 "Install CHANGELOG file"
install -Dm755 "${srcdir}/CHANGELOG-${pkgver}.md" "${pkgdir}/usr/share/doc/${pkgname}/CHANGELOG.md"
msg2 "Install LICENSE file"
install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}/"
ln -sf "/usr/lib/node_modules/${_npmmodule}/LICENSE.md" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}