Skip to content

Instantly share code, notes, and snippets.

@sukanka
Last active April 7, 2023 12:52
Show Gist options
  • Save sukanka/792fc4b100294ff7a1317e6c04c87302 to your computer and use it in GitHub Desktop.
Save sukanka/792fc4b100294ff7a1317e6c04c87302 to your computer and use it in GitHub Desktop.
PKGBUILD for balena-etcher
#!/bin/bash
if [[ $EUID -ne 0 ]] || [[ $ELECTRON_RUN_AS_NODE ]]; then
exec _ELECTRON_ /usr/lib/balena-etcher "$@"
else
exec _ELECTRON_ --no-sandbox /usr/lib/balena-etcher "$@"
fi
# Maintainer: Matthew McGinn <[email protected]>
# Contributor: Håvard Pettersson <[email protected]>
# Contributor: Andrew Stubbs <[email protected]>
pkgname=balena-etcher
_pkgname=etcher
pkgver=1.18.6
_electron=electron19
pkgrel=1
epoch=2
pkgdesc='Flash OS images to SD cards & USB drives, safely and easily'
arch=('x86_64' 'i686' 'armv7h' 'aarch64')
_github_url='https://github.com/balena-io/etcher'
url='https://balena.io/etcher'
license=(Apache)
depends=("${_electron}" "gtk3" "libxtst" "libxss" "nss" "alsa-lib" "glib2" "polkit" "libusb")
makedepends=("npm" "jq" "patch" "nodejs" 'moreutils' 'node-gyp' )
optdepends=("libnotify: for notifications")
conflicts=("${_pkgname}"
"${_pkgname}-git"
"${_pkgname}-bin"
)
options=('!strip')
source=("${_pkgname}-${pkgver}.tar.gz::https://github.com/balena-io/etcher/archive/refs/tags/v${pkgver}.tar.gz"
"${pkgname}-electron.sh"
"${pkgname}-electron.desktop"
"resin-${pkgver}.tar.gz::https://github.com/product-os/scripts/archive/refs/tags/v1.26.6.tar.gz"
)
sha256sums=('e1e87942a2c21feea00356d10a032b040e2b7bfdc386c342f669350c99571a5c'
'71d3ca348f879c585aee8724fd565ce22ca5767833829ddce15ada81a5dceaf8'
'c950d9578f9cf60998c920bb60c6617559963f06a4918e7072fdc706b0ef5754'
'a6f4472cb501456f17a72668c635d1fa9077bc32074e047ee240b1dd3d27c3cb')
prepare() {
cd "${_pkgname}-${pkgver}"
sed -i "s|_ELECTRON_|${_electron}|g" ${srcdir}/balena-etcher-electron.sh
cp -rf ${srcdir}/scripts-*/* "${srcdir}/${_pkgname}-${pkgver}/scripts/resin"
# patch electron version
local electronDist="/usr/lib/${_electron}"
local electronVersion="$(< $electronDist/version)"
jq ".devDependencies.electron = \"$electronVersion\"" package.json | sponge package.json
jq ".build.electronDist = \"$electronDist\"" package.json | sponge package.json
jq ".build.electronVersion = \"$electronVersion\"" package.json | sponge package.json
rm -rf package-lock.json
}
build() {
cd "${_pkgname}-${pkgver}"
export HOME=${srcdir}
unset MAKEFLAGS
npm install
npm run webpack
npm prune --production
}
package() {
cd "${_pkgname}-${pkgver}"
_appdir="${pkgdir}/usr/lib/${pkgname}"
install -d "${_appdir}"
install package.json "${_appdir}"
cp -a {lib,generated,node_modules} "${_appdir}"
install -D assets/icon.png "${_appdir}/assets/icon.png"
install -D lib/gui/app/index.html "${_appdir}/lib/gui/app/index.html"
install -Dm755 "${srcdir}/${pkgname}-electron.sh" "${pkgdir}/usr/bin/${pkgname}-electron"
install -Dm644 "${srcdir}/${pkgname}-electron.desktop" \
"${pkgdir}/usr/share/applications/${pkgname}-electron.desktop"
for size in 16x16 32x32 48x48 128x128 256x256 512x512; do
install -Dm644 "assets/iconset/${size}.png" \
"${pkgdir}/usr/share/icons/hicolor/${size}/apps/${pkgname}-electron.png"
done
find "${pkgdir}" -name package.json -print0 | xargs -r -0 sed -i '/_where/d'
}
# vim:set ts=2 sw=2 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment