#!/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=filesystem
pkgver=2023.04.09
pkgrel=01
pkgdesc='Base Joborun Linux file system'
groups=( jobbot base )
url='https://pozol.eu'
depends=('iana-etc')
backup=('etc/crypttab' 'etc/fstab' 'etc/group' 'etc/gshadow' 'etc/host.conf'
        'etc/hosts' 'etc/issue' 'etc/ld.so.conf' 'etc/nsswitch.conf'
        'etc/passwd' 'etc/profile' 'etc/resolv.conf' 'etc/resolv.conf.pacnew' 'etc/securetty'
        'etc/shadow' 'etc/shells' 'etc/subuid' 'etc/subgid')
source=('crypttab' 'fstab' 'group' 'gshadow' 'host.conf' 'hosts'
		'issue' 'ld.so.conf' 'locale.sh' 'motd' 'nsswitch.conf' 'os-release'
		'passwd' 'profile' 'resolv.conf' 'securetty' 'shadow' 'shells'
		'subuid' 'subgid' 'sysusers' 'tmpfiles' 'modprobe.d.usb-load-ehci-first'
		'jobo-release')
#		'env-generator' 'joborun-linux-logo.svg' 'joborun-linux-logo.png'
#		'joborun-linux-logo-text.svg' 'joborun-linux-logo-text-dark.svg')

package() {
  cd "$pkgdir"

  # setup root filesystem
  for d in boot dev etc home mnt usr var opt srv/http run; do
    install -d -m755 $d
  done
  install -d -m555 proc
  install -d -m555 sys
  install -d -m0755 root
  install -d -m1777 tmp
  install -d -m777 src
  # vsftpd won't run with write perms on /srv/ftp
  # ftp (uid 14/gid 11)
  install -d -m555 -g 11 srv/ftp

  # setup /etc and /usr/share/factory/etc
  install -d etc/{ld.so.conf.d,skel,profile.d} usr/share/factory/etc
  for f in fstab group host.conf hosts issue ld.so.conf motd nsswitch.conf \
  passwd securetty shells profile subuid subgid; do
    install -m644 "$srcdir"/$f etc/
    install -m644 "$srcdir"/$f usr/share/factory/etc/
  done
  install -m644 "$srcdir"/resolv.conf etc/resolv.conf.pacnew
  ln -s ../proc/self/mounts etc/mtab
  for f in gshadow shadow crypttab; do
    install -m600 "$srcdir"/$f etc/
    install -m600 "$srcdir"/$f usr/share/factory/etc/
  done
    install -D -m644 "$srcdir"/modprobe.d.usb-load-ehci-first usr/lib/modprobe.d/usb-load-ehci-first.conf

  install -Dm644 "$srcdir"/jobo-release etc/jobo-release
  touch etc/arch-release
  install -m644 "$srcdir"/locale.sh etc/profile.d/locale.sh
  install -Dm644 "$srcdir"/os-release usr/lib/os-release
    ln --symbolic --relative "$pkgdir"/usr/lib/os-release "$pkgdir"/etc/os-release

  # setup /var
  for d in cache local opt log/old lib/misc lib/pacman empty; do
    install -d -m755 var/$d
  done
  install -d -m1777 var/{tmp,spool/mail}

  # allow setgid games (gid 50) to write scores
  install -d -m775 -g 50 var/games
  ln -s spool/mail var/mail
  ln -s ../run var/run
  ln -s ../run/lock var/lock

  # setup /usr hierarchy
  for d in bin include lib share/{misc,pixmaps} src; do
    install -d -m755 usr/$d
  done
  for d in {1..8}; do
    install -d -m755 usr/share/man/man$d
  done

  # add lib symlinks
  ln -s usr/lib lib
    ln -s usr/lib lib64
    ln -s lib usr/lib64

  # add bin symlinks
  ln -s usr/bin bin
  ln -s usr/bin sbin
  ln -s bin usr/sbin

  # setup /usr/local hierarchy
  for d in bin etc games include lib man sbin share src; do
    install -d -m755 usr/local/$d
  done
  ln -s ../man usr/local/share/man

  # setup systemd-sysusers wrapper
  install -D -m644 "$srcdir"/sysusers usr/lib/sysusers.d/joborun.conf

  # setup systemd-tmpfiles wrapper
  install -D -m644 "$srcdir"/tmpfiles usr/lib/tmpfiles.d/joborun.conf

##  # add logo
##  install -D -m644 "$srcdir"/joborun-linux-logo{.png,.svg,-text.svg,-text-dark.svg} usr/share/pixmaps
}

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

arch=(x86_64)

license=('GPL')

sha256sums=(e03bede3d258d680548696623d5979c6edf03272e801a813c81ba5a5c64f4f82  # crypttab
	115d324c8518affc7bec5559579d85f8f5491646b6110ea9567a586a26a76da9  # fstab
	b1e8c06dd1785ad89df6c3d27b8b82218885a475424e19d54a7542c66dcba253  # group
	d75a8553d13041c5f971fd8db52081ad4e46176a779c617b6218c479e79df957  # gshadow
	250cfbb9a2b5e3cc9879ab2080eb3c7875fbe66eb375ce3f96eee335654a4979  # host.conf
	8a63876eaf11641bbecdf2dea934c14e730dd4daceb32a5b172d08887a263f73  # hosts
	dd677efadad3354fa9ab28e561c28e7c03829b01a4647307ede3a9260137a745  # issue
	dad04a370e488aa85fb0a813a5c83cf6fd981ce01883fc59685447b092de84b5  # ld.so.conf
	6c17fa911c82c27a30414624cdb32b44a76e60304cb875dc794bb9ee7aac21d4  # locale.sh
	c307b0cfb3814649c2f45a149322c5ab83466517887c16af3a6504d2a7427320  # motd
	581a292aeae5e125f8527fef41a839c6c3d6f81f853c49c476b6ab25e20917ef  # nsswitch.conf
	07c6b95de509a2c33f94b97b59cbf7f86f642cf1aaec12b011732ef8d8e27429  # os-release
	eac657125eb0e80c6cc79bac04f4c9b317dcea2d2d5436c03f26d73310bca6e6  # passwd
	5e4088ad8d0853d390fa303f6be8c3f69c33834200cba9e90f7849f1993ca8d0  # profile
	de4974ab07e775a7c88ae930108afc705b3ab956e99a1e5def863bb3aa26ecbf  # resolv.conf
	d88be2b45b43605ff31dd83d6a138069b6c2e92bc8989b7b9ab9eba8da5f8c7b  # securetty
	b302b2e8b06d27d078c5ad68655d441e2a07357b925a867dcf6a33f3a5464b3a  # shadow
	362cb89caffb71c0d5fb9ef5e2b00089723849bb6a2b720fe4016d7768e2cef2  # shells
	e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  # subgid
	e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  # subuid
	ec207f224fdd6f29d2a333b2e9be211ef44f21a2bff0c0c6d7ea6d1b72b70eee  # sysusers
	618ac097441c1f2daffc9967e5c3cd18ea8866f776db62d04bf401c53907b1c9  # tmpfiles
	90fb123aa8c0176bc144322b585bb889181c437542ddbe546af43e11b95be6ab  # modprobe.d.usb-load-ehci-first
	673953e0ad7fc53247f4feadc2c2d4506396840d1f8796526f48d47333ac7652) # jobo-release

##  955d23de2599828bb90458692afc36a0b33677c85a0047a4104d1e7c52a17b7e  filesystem-2023.04.09-01-x86_64.pkg.tar.lz

