#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=tzdata
pkgver=2023d
_tzcode=2023d
_tzdata=2023d
pkgrel=01
pkgdesc="Sources for time zone and daylight saving time data"
url="https://www.iana.org/time-zones"
options=('!emptydirs')
optdepends=('bash: for tzselect'
            'glibc: for zdump, zic')
source=(https://www.iana.org/time-zones/repository/releases/tzcode${_tzcode}.tar.gz{,.asc}
        https://www.iana.org/time-zones/repository/releases/${pkgname}${_tzdata}.tar.gz{,.asc})

_timezones=('africa' 'antarctica' 'asia' 'australasia'
           'europe' 'northamerica' 'southamerica'
           'etcetera' 'backward' 'factory')

prepare() {
  sed -i "s:sbin:bin:g" Makefile
}

build() {
  make LFLAGS="${LDFLAGS} ${LTOFLAGS}"
}

package() {
  cd "${srcdir}"
  # install tzcode stuff
  make DESTDIR="${pkgdir}" install

  # install tzdata stuff
  ./zic -b fat -d "${pkgdir}"/usr/share/zoneinfo ${_timezones[@]}
  ./zic -b fat -d "${pkgdir}"/usr/share/zoneinfo/posix ${_timezones[@]}
  ./zic -b fat -d "${pkgdir}"/usr/share/zoneinfo/right -L leapseconds ${_timezones[@]}
  # This creates the posixrules file. We use New York because POSIX requires the daylight savings time rules to be in accordance with US rules.   
  ./zic -b fat -d "${pkgdir}"/usr/share/zoneinfo -p America/New_York
  install -m644 -t "${pkgdir}"/usr/share/zoneinfo iso3166.tab leap-seconds.list zone1970.tab zone.tab SECURITY # zone.tab is depricated and will go soon
  
  # cleanup
  rm "${pkgdir}/etc/localtime"

  # install license
  install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=('custom: public domain')

validpgpkeys=('7E3792A9D8ACF7D633BC1588ED97E90E62AA7E34') # Paul Eggert <eggert@cs.ucla.edu>

sha256sums=(e9a5f9e118886d2de92b62bb05510a28cc6c058d791c93bd6b84d3292c3c161e  # tzcode2023d.tar.gz
	11763502f98c72239b24b1d3f12430f8238fbe135f7ad9422c2da8ff3469f362  # tzcode2023d.tar.gz.asc
	dbca21970b0a8b8c0ceceec1d7b91fa903be0f6eca5ae732b5329672232a08f3  # tzdata2023d.tar.gz
	c9e755e34bed5c686e53cd93255195a37a25d86f6e863844eb12f91aab8f85fc) # tzdata2023d.tar.gz.asc

##  deae3cd4a2ec2f36deaa54a6c124d89c593f63a54e55402127f1ad165f70df48  tzdata-2023d-01-x86_64.pkg.tar.lz

