Advertisement
Guest User

schildichat-desktop-custom-git PKGBUILD, version 1.11.81.sc.0.test.0+3.r503.20241021.a18b08f-2

a guest
Oct 21st, 2024
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.32 KB | Source Code | 0 0
  1. # Maintainer:  dreieck (https://aur.archlinux.org/account/dreieck)
  2. # Contributor: lsf (https://aur.archlinux.org/account/lsf)
  3. # Contributor: Bruno Pagani <archange@archlinux.org>
  4. # Contributor: Steef Hegeman <mail@steefhegeman.com>
  5. # Contributor: Luca Weiss <luca (at) z3ntu (dot) xyz>
  6. # Contributor: Julian Schacher <jspp@posteo.net>
  7.  
  8. _electron="electron30"  # As of 2024-10-21, latest working version is `electron30`. See https://github.com/SchildiChat/schildichat-desktop/issues/265#issuecomment-2427793936.
  9. _nodeversion=20         # As of 2024-10-20, the minimum version of `nodejs` is 20.
  10. _pkgname="schildichat-desktop"
  11. pkgname="${_pkgname}-custom-git"
  12. pkgver=1.11.81.sc.0.test.0+3.r503.20241021.a18b08f
  13. pkgrel=2
  14. pkgdesc="A Matrix client based on Element with a more traditional instant messaging experience. @dreieck's custom build of the latest git checkout."
  15. arch=(
  16.   "x86_64"
  17. )
  18. url="https://schildi.chat"
  19. license=('Apache-2.0')
  20. conflicts=(
  21.   "${_pkgname}"
  22.   "${_pkgname}-bin"
  23. )
  24. provides=(
  25.   "${_pkgname}=${pkgver}"
  26.   "${_pkgname}-custom=${pkgver}"
  27.   "${_pkgname}-git=${pkgver}"
  28. )
  29. makedepends=(
  30.   "npm"
  31.   "git"
  32.   "yarn"
  33.   "python"
  34.   "python-setuptools"
  35.   "rust"
  36.   "tcl"
  37.   "nodejs>=${_nodeversion}"
  38.   "nvm"
  39.   "libxcrypt-compat"
  40.   "asar"
  41. )
  42. depends=(
  43.   "${_electron}"
  44.   "libsecret"
  45. )
  46. source=(
  47.   "${_pkgname}::git+https://github.com/SchildiChat/schildichat-desktop.git#branch=lite"
  48.   "git+https://github.com/SchildiChat/matrix-js-sdk.git"
  49.   "git+https://github.com/SchildiChat/matrix-react-sdk.git"
  50.   "git+https://github.com/SchildiChat/element-web.git"
  51.   "git+https://github.com/SchildiChat/element-desktop.git"
  52.   "autolaunch.patch"
  53.   "schildichat-desktop.desktop"
  54.   "schildichat-desktop.sh"
  55. )
  56. sha256sums=(
  57.   'SKIP'
  58.   'SKIP'
  59.   'SKIP'
  60.   'SKIP'
  61.   'SKIP'
  62.   '20533d63ffadf03dbfd173e6d4f1f1048746a628db7b2a70f5bc02390e812302'
  63.   '6450af411fea039cb76357ff4ea7f1ef336601315de4d27b848a75d7960cef17'
  64.   '8084211fe11ba23be956ef4b8bb0fffaa6aaa721b79f9753ecc3574666ef95ce'
  65. )
  66.  
  67. prepare() {
  68.   cd ${_pkgname}
  69.   export npm_config_cache="${srcdir}/npm_cache"
  70.   _ensure_local_nvm
  71.   #nvm install "${_nodeversion}" # Not needed; `nodejs>=${_nodeversion}` from the repositories suffices.
  72.  
  73.   git submodule init
  74.   git config submodule.matrix-js-sdk.url    "${srcdir}/matrix-js-sdk"
  75.   git config submodule.matrix-react-sdk.url "${srcdir}/matrix-react-sdk"
  76.   git config submodule.element-web.url      "${srcdir}/element-web"
  77.   git config submodule.element-desktop.url  "${srcdir}/element-desktop"
  78.   git -c protocol.file.allow=always submodule update
  79.  
  80.   # Specify electron version in launcher
  81.   sed -i "s|@ELECTRON@|${_electron}|" "${srcdir}/schildichat-desktop.sh"
  82.  
  83.   _electron_dist="/usr/lib/${_electron}"
  84.   _electron_ver="$(cat "${_electron_dist}/version")"
  85.  
  86.   cd element-desktop
  87.   printf '%s\n' " --> Applying patch 'autolaunch.patch' ..."
  88.   patch -Np1 --follow-symlinks -i "${srcdir}/autolaunch.patch"
  89.  
  90.   printf '%s\n' " --> Doing some fixups with sed in .json files ..."
  91.   sed -i 's|"target": "deb"|"target": "dir"|' package.json
  92.   sed -i "s|\"electronVersion\": \".*\"|\"electronVersion\": \"${_electron_ver}\"|" package.json # removed?
  93.   sed -i "s|\"electron\": \".*\"|\"electron\": \"${_electron_ver}\"|" package.json
  94.   sed -i 's|"https://packages.element.io/desktop/update/"|null|' element.io/release/config.json
  95.  
  96.   cd ${srcdir}/${_pkgname}
  97.  
  98.   git log > git.log
  99.  
  100.   printf '%s\n' " --> Running 'make setup' ..."
  101.   make setup
  102. }
  103.  
  104. pkgver() {
  105.   cd "${_pkgname}"
  106.  
  107.   _ver="$(git describe --tags | sed -E -e 's|^[vV]||' -e 's|\-g[0-9a-f]*$||' -e 's|-(sc)|.\1|' -e 's|-([0-9]+)$|+\1|')"
  108.   _rev="$(git rev-list --count HEAD)"
  109.   _date="$(git log -1 --date=format:"%Y%m%d" --format="%ad")"
  110.   _hash="$(git rev-parse --short HEAD)"
  111.  
  112.   if [ -z "${_ver}" ]; then
  113.     error "Version could not be determined."
  114.     return 1
  115.   else
  116.     printf '%s' "${_ver}.r${_rev}.${_date}.${_hash}"
  117.   fi
  118. }
  119.  
  120. build() {
  121.   cd "${_pkgname}"
  122.   export npm_config_cache="${srcdir}/npm_cache"
  123.   _ensure_local_nvm
  124.   #nvm use ${_nodeversion} # Not needed; `nodejs>=${_nodeversion}` from the repositories suffices.
  125.   export SQLCIPHER_BUNDLED=1
  126.   export CFLAGS+=" -ffat-lto-objects"
  127.  
  128.   # printf '%s\n' " --> Running 'yarn' ..."
  129.   # yarn --cwd element-desktop run build:64 --linux -c.linux.target=dir -c.electronDist=${_electron_dist} -c.electronVersion=${_electron_ver}
  130.   # let's use the ready-made build script instead - otherwise, we'd have to do a lot more work to get the webapp build etc.
  131.  
  132.   printf '%s\n' " --> Running 'make pacman' ..."
  133.   make pacman
  134. }
  135.  
  136. package() {
  137.   cd "${_pkgname}"
  138.  
  139.   install -dvm755 "${pkgdir}/usr/lib/${_pkgname}"
  140.  
  141.   cp -rv element-desktop/dist/linux-unpacked/resources{,.pak} "${pkgdir}"/usr/lib/${_pkgname}/
  142.   cp -rv element-desktop/dist/linux-unpacked/locales "${pkgdir}"/usr/lib/${_pkgname}/
  143.  
  144.   # crashes (at least on wayland) when remaining packed. might be some issue with the webapp.asar location, but inconclusive
  145.   # workaround by extracting app.asar
  146.  
  147.   install -dvm755 "${pkgdir}"/usr/lib/${_pkgname}/resources/app
  148.   asar e "${pkgdir}"/usr/lib/${_pkgname}/resources/app.asar "${pkgdir}/usr/lib/${_pkgname}/resources/app"
  149.   rm "${pkgdir}/usr/lib/${_pkgname}/resources/app.asar"
  150.  
  151.   # Required extras
  152.   install -Dvm644 "${srcdir}/schildichat-desktop.desktop" -t "${pkgdir}"/usr/share/applications/
  153.   install -Dvm755 "${srcdir}/${_pkgname}.sh" "${pkgdir}/usr/bin/${_pkgname}"
  154.  
  155.   # Icons
  156.   install -Dvm644 element-desktop/res/img/element.png "${pkgdir}"/usr/share/icons/hicolor/scalable/apps/schildichat-desktop.png
  157.   for i in 16 24 48 64 96 128 256 512; do
  158.     install -Dvm644 "element-desktop/build/icons/${i}x${i}.png" "${pkgdir}/usr/share/icons/hicolor/${i}x${i}/apps/schildichat-desktop.png"
  159.   done
  160.  
  161.   install -Dvm644 -t "${pkgdir}/usr/share/doc/${_pkgname}" git.log RELEASE.md README.md FEATURES.md
  162.  
  163.   install -Dvm644 -t "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
  164. }
  165.  
  166. # https://wiki.archlinux.org/title/Node.js_package_guidelines#Using_nvm
  167. _ensure_local_nvm() {
  168.     # let's be sure we are starting clean
  169.     which nvm >/dev/null 2>&1 && nvm deactivate && nvm unload
  170.     export NVM_DIR="${srcdir}/.nvm"
  171.  
  172.     # The init script returns 3 if version specified
  173.     # in ./.nvrc is not (yet) installed in $NVM_DIR
  174.     # but nvm itself still gets loaded ok
  175.     source /usr/share/nvm/init-nvm.sh || [[ $? != 1 ]]
  176. }
  177.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement