summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0a5a3ef4830c909512c082942dbfc3bb53969e81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Maintainer: Your Name <your@email.com>
pkgname=dssat-csm-os-git
pkgver=v4.8.5.41.r1.g1b7784c0
pkgrel=2
pkgdesc="The Cropping System Model (CSM) from the Decision Support System for Agrotechnology Transfer (DSSAT)"
# To use: Download DSSAT data files from https://dssat.net/data
# Extract to a directory (e.g., ~/dssat_data) and run:
#   cd ~/dssat_data/Maize
#   dscsm048 MZCER048 A UFGA8201.MZX
# See https://github.com/DSSAT/dssat-csm-os for documentation
arch=('x86_64')
url="https://github.com/DSSAT/dssat-csm-os"
license=('LicenseRef-DSSAT')
depends=('netcdf-fortran' 'libjpeg-turbo')
makedepends=('gcc-fortran' 'cmake' 'make' 'git')
provides=('dssat-csm-os')
conflicts=('dssat-csm-os')
install=dssat-csm-os-git.install
source=("git+https://github.com/DSSAT/dssat-csm-os.git")
sha256sums=('SKIP')

pkgver() {
  cd "dssat-csm-os"
  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd "dssat-csm-os"
  mkdir -p build
}

build() {
  cd "dssat-csm-os/build"
  cmake ../ \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=RELEASE \
    -DDYNAMIC_LINK=ON \
    -DCMAKE_EXE_LINKER_FLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
  make
}

package() {
  cd "dssat-csm-os/build"
  make DESTDIR="${pkgdir}" install

  # Move the executable to the correct path
  install -d "${pkgdir}/usr/bin"
  mv "${pkgdir}/usr/dscsm048" "${pkgdir}/usr/bin/"

  # Move all data files into the correct share path
  install -d "${pkgdir}/usr/share/${pkgname}"
  find "${pkgdir}/usr/" -mindepth 1 -maxdepth 1 \
    ! -name "bin" \
    ! -name "share" \
    ! -name "lib" \
    -exec mv -t "${pkgdir}/usr/share/${pkgname}/" {} +

  # Create symlink for hardcoded /DSSAT48/ path in the binary
  # The Fortran source (Utilities/OSDefsLINUX.for) hardcodes STDPATH = '/DSSAT48/'
  install -d "${pkgdir}/"
  ln -s "/usr/share/${pkgname}" "${pkgdir}/DSSAT48"

  # Finally, install the license file using its full path and correct name
  install -Dm644 "${srcdir}/dssat-csm-os/license.txt" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}