git » kicad-library.git » main » tree

[main] / PKGBUILD

# Maintainer: Filipe LaĆ­ns <lains@archlinux.org>
# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Kyle Keen <keenerd@gmail.com>
# Contributor: Rachel Mant <aur@dragonmux.network>

pkgbase=kicad-library
pkgname=($pkgbase{,-3d})
pkgver=8.0.8
pkgrel=1
pkgdesc='Assorted libraries for KiCad'
arch=('any')
url='http://kicad.org/'
license=('GPL')
makedepends=('git' 'cmake' 'squashfs-tools')
options=('!strip')
source=(
  "git+https://gitlab.com/kicad/libraries/kicad-packages3D.git#tag=$pkgver"
  "git+https://gitlab.com/kicad/libraries/kicad-symbols.git#tag=$pkgver"
  "git+https://gitlab.com/kicad/libraries/kicad-templates.git#tag=$pkgver"
  "git+https://gitlab.com/kicad/libraries/kicad-footprints.git#tag=$pkgver"
)
# This is split to allow easier patching to newer kicad-library PKGBUILDs from upstream
source+=(
  "10-kicad-library.preset"
  "10-kicad-library-3d.preset"
)

build() {
  for package in symbols footprints packages3D templates; do
     cmake \
       -B "build-$package" \
       -S "kicad-$package" \
       -DCMAKE_INSTALL_PREFIX=/usr

     cmake --build "build-$package"
   done
}

_squash_dir_systemd() {
  for package in $@; do
    mksquashfs "$pkgdir"/usr/share/kicad/$package "$pkgdir"/usr/share/kicad/$package.sqfs -b 1m -comp zstd -Xcompression-level 19
    rm -r "$pkgdir"/usr/share/kicad/$package
    mkdir -p "$pkgdir"/usr/share/kicad/$package
    mkdir -p "$pkgdir"/usr/lib/systemd/system
    cat > "$pkgdir"/usr/lib/systemd/system/usr-share-kicad-$package.mount << EOF
[Unit]
Description=Kicad $package

[Mount]
What=/usr/share/kicad/$package.sqfs
Where=/usr/share/kicad/$package
Type=squashfs
Options=loop,ro

[Install]
WantedBy=multi-user.target
EOF
  done
}

package_kicad-library() {
  pkgdesc="KiCad symbol, footprint and template libraries"
  install=kicad-library.install

  for package in symbols footprints templates; do
    DESTDIR="$pkgdir" cmake --install "build-$package"
  done

  _squash_dir_systemd symbols footprints
  mkdir -p "$pkgdir"/usr/lib/systemd/system-preset
  cp 10-kicad-library.preset "$pkgdir"/usr/lib/systemd/system-preset/
}

package_kicad-library-3d() {
  pkgdesc="KiCad 3D model libraries"
  install=kicad-library-3d.install

  DESTDIR="$pkgdir" cmake --install build-packages3D

  _squash_dir_systemd 3dmodels
  mkdir -p "$pkgdir"/usr/lib/systemd/system-preset
  cp 10-kicad-library-3d.preset "$pkgdir"/usr/lib/systemd/system-preset/
}

# vim:set ts=2 sw=2 et:
sha256sums=('d10c2cf350820295d728bb7aa254f08c66e37d1e9640bce07988817a09a8cb82'
            '299a6deb23782809aeb79cc263f1454b2e04adb6c3fc0f2a8ab7892e8670131d'
            '083617a1071ea3dc539e2e76cde0002d337eb6f474f169b3b20a5ef136001731'
            '72f2c6590a551edd416489b84c68adba05b464c980ea28cb0508389bca05594b'
            '22502d199590f0fee0d17b309a374ff1d085b312393b318f43cea88ca245c2db'
            'f45bab86a2baeb6798df19c0c3a7821562d5c9120d3c0582caf39f0a87912815')