# Maintainer: PktSurf <smlinux@pktsurf.in>
app=smstools
version=3.1.21
build=1sml
homepage="https://smstools3.kekekasvi.com"
download="https://smstools3.kekekasvi.com/packages/smstools3-$version.tar.gz"
desc="SMS gateway software for sending and receiving SMSs from GSM modems and mobile phones"
requires="musl"

prepbuilddir() {
  mkandenterbuilddir
  rm -rf "smstools3"

  tar xf $srcdir/smstools3-$version.tar.?z
  cd "smstools3"
  fixbuilddirpermissions

  applypatch $srcdir/fixups2.diff
}

build() {
  cd src 
  make CC="$CC -static" 

  cp ../LICENSE $pkgdocs

  # Add sample config files
  mkdir -p $pkg/etc/smsd
  cat ../examples/smsd.conf.easy > $pkg/etc/smsd/smsd.conf.easy
  cat ../examples/smsd.conf.full > $pkg/etc/smsd/smsd.conf.full
  cat ../examples/smsd.conf.net > $pkg/etc/smsd/smsd.conf.net
  cat ../examples/smsd.conf.non-root > $pkg/etc/smsd/smsd.conf.non-root

  install -Dm 755 smsd $pkg/bin/smsd

  # Fix some ownership/permissions
  mkdir -p $pkg/var/spool/sms
  chown -R root:dialout $pkg/var/spool/sms
  chmod -R g+rw $pkg/var/spool/sms

  mkfinalpkg
}

sha512sums="
ef6f328203228d63a14abf4ae2e67a4bf3e2d14ae19a2dc538f866b27a84d96cedeb9ce9d39ab45b577d2242230e073a5dc26853253e65c97ba861cc3cbd712d  smstools3-3.1.21.tar.lz
12235c9d716e3875b9a1b953dcfc0aa6a41dfa05ed5aa7556fd2dbb6cceffd464792fa6385ecf11f094e46e05b7162e5a6a63320fbfe7ff9e734673098589607  fixups2.diff
"
