# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Renato Silva <br.renatosilva@gmail.com>
# Contributor: Karlson2k (Evgeny Grin) <k2k@narod.ru>
# Contributor: Alethea Rose <alethea@alethearose.com>

pkgname=filesystem
pkgver=2025.05.08
pkgrel=2
pkgdesc='Base filesystem'
arch=('i686' 'x86_64')
license=('spdx:BSD-3-Clause')
url='https://github.com/msys2/MSYS2-packages/tree/master/filesystem'
provides=('msys2-base')
replaces=('msys2-base')
msys2_references=(
  'internal'
)
backup=('etc/fstab' 'etc/shells' 'etc/profile'
        etc/bash.bashrc etc/skel/.bash{rc,_profile}
        etc/nsswitch.conf)
source=('bash.bashrc'
        'cmd'
        'dot.bash_profile'
        'dot.bashrc'
        'dot.profile'
        'fstab'
        'mingw32.ico'
        'mingw64.ico'
        'msys2.ico'
        'ucrt64.ico'
        'clang64.ico'
        'clangarm64.ico'
        'msys2_shell.cmd'
        'msystem'
        'msystem.d.CLANG64'
        'msystem.d.CLANGARM64'
        'msystem.d.MINGW32'
        'msystem.d.MINGW64'
        'msystem.d.MSYS'
        'msystem.d.UCRT64'
        'nsswitch.conf'
        'profile'
        'profile.lang.sh'
        'profile.tzset.sh'
        'profile.000-msys2.sh'
        'shell'
        'shells'
        'start'
        '01-devices.post'
        '03-mtab.post'
        '05-home-dir.post'
        '06-windows-files.post'
        '07-pacman-key.post'
        'cygwin.ldif'
        'main-config.site'
        'redirect-config.site'
        'os-release')
sha256sums=('36d4affa25606c87e70c42a5fe2294aa7898fb54f93a27910fb55224f4d6588a'
            '99eae6e37081edd73b399009c85f4a67a0c14481241ee4937ab45c4178b540fb'
            '00501046c301c5cb627b147e461217cda015aa109f673a9c1a67602891a26e88'
            '57037a01df6306fa093b93911d149bfcb0cba8f6a6b3cea551f2852113e95929'
            '0e3f00cb2cc7778a1fb5440fc979cfeeafeca72c3059dd474f38ed6b99b46070'
            '387ca1e86c1a18a143eb077ca194ad44c0a2faf98795a0d437f2d210d5a6df18'
            'f8f1b5943d385e8a7e3b5a4a2c7d64004108c94c17b2f936016e2ae50bdb65af'
            '91b4a790aad38a102565f0cfcba6c0e6d274f6cda0b37b128d9cc43c5ad6b24d'
            '793b9450a1a59a6c294e51fd0c2a47090d68c68ff2f33a25a11b45f6408c3917'
            '733e97cbb823773e1a08a91a41035a7692bc0ff270d3c894224911b4b091db44'
            '56d4080c15dff89a6263f3d5f9aa68849b2062179cabd6d78edfe0e3af6bf64a'
            '3b7af99516768485383b34d606749e6f98a250372a8191bc8d3a962d66bdfe35'
            'eab4c7fae0702821951223a3333cb5ce2547553dc1287058324a39cc374d48a7'
            '74bd56de00e49c3917deca2ede723eecd1312a86357b100ae8aabd219f6e7d5e'
            'f2b01902f08feb07fed47f5ffea3462764034abc19e9ddf3aa6f20f93afeaab6'
            '82859ae69d40de560d03c0a59e38e8b3405293003c1d24237f6bbd5efe3c87ef'
            '809ff47346e21e0e1d285e64f3e0975e7345e311e98bb4e100c8da15e1426d9b'
            '879495ad6b15f59ec2057551e06fb2917715c66de80f5bf915d6176d78e50eee'
            'b166ab9772874471695f5beb16f5c39b6207c937353d0aa9079cbe756432df1d'
            '240fa8efb6fe4b7dae826f5f6d481e41a09913462fe61b5a4ff036d6daa7a835'
            '91f1f918cf13deab0124082086e990786113b0e710dbda4678d8fc14905ad94d'
            'b8abe6231cd2b089d708d3e3097ef8c279af1e1594aa15c6eaab4150ed9dffdc'
            '6c0ca979c7b146b3750103b1296a399764f4e1b222ee091d3aa072b6da16c1a5'
            'cbec90c9403826bf6d8dd1fed16240b9d8695ec15df5dcdab7e485bb46c016ab'
            'a2ec65de2adb0277f51001463c1a0759f8a5bc35cf2f213fa26ee73df52c5280'
            '70d8b1351768765976d71ee2b7b66eb65cc23a263698cfcecf65cef3bf57177c'
            'f63241cc56aa7b7ec6962d19991d211b4e1641b78ba5226835118ab493830a8b'
            'e96c1f54ffff792e738aa032815c82c30821b0683806e5ed0ba2a759db2fd494'
            '3a4d629d72ab8ac58427097c3a8915c4e8186f819cd369c2da5eca955d08fceb'
            'd7b7eb4cd9e1f9bc227b009cdcacf700f5523ccc109fbd3c1c0331726d314c9e'
            '9c126262051a047450ed97397ee89a7148098c03ae00a1cd67c3f3425d8e4b12'
            '549859e17dc0b8d5c0374103c8a1afc6995bc61ce8f1423eeed51dc9e6cc74e0'
            '19badd8d5d7e0052028c466fc1eb7fcf8f7e1fb50cb832be389922047897ef3e'
            'caf25e3390331c6a22cc91f1c1bc551a9f87c59171dd3ef7b3b6016859a10fb5'
            '28c42ec8a6888e63b2156a802d93e74b544eff211ec688fb6ce8e67e12b81156'
            '26bf8d1acade9431d60c035a7ddfa9cb0775d5b9a457c5aca56f51c5f2f93f98'
            '1fef172ac99eef561100da9eecb7712786dff8dd73f4a97eb39462bde0275af8')

build() {
  cd ${srcdir}
}

package() {
  cd ${pkgdir}

  # setup root filesystem
  #
  for d in dev etc home usr var opt; do
    install -d -m755 ${d}
  done

  mkdir -p tmp

  # setup /etc
  #
  install -d etc/{fstab.d,skel,profile.d,post-install,msystem.d}
  for f in bash.bashrc fstab shells profile nsswitch.conf msystem os-release; do
    install -m644 ${srcdir}/${f} etc/
  done

  for f in ${srcdir}/msystem.d.*; do
    install -m644 ${f} "etc/msystem.d/${f#${srcdir}/msystem.d.}"
  done

  for f in ${srcdir}/*.post; do
    install -m644 ${f} etc/post-install/
  done

  # user configuration file skeletons
  #
  install -m644 ${srcdir}/dot.bashrc etc/skel/.bashrc
  install -m644 ${srcdir}/dot.bash_profile etc/skel/.bash_profile
  install -m644 ${srcdir}/dot.profile etc/skel/.profile

  install -m644 ${srcdir}/profile.tzset.sh etc/profile.d/tzset.sh
  install -m644 ${srcdir}/profile.lang.sh etc/profile.d/lang.sh
  install -m644 ${srcdir}/profile.000-msys2.sh etc/profile.d/000-msys2.sh

  install -m644 ${srcdir}/mingw32.ico mingw32.ico
  install -m644 ${srcdir}/mingw64.ico mingw64.ico
  install -m644 ${srcdir}/ucrt64.ico ucrt64.ico
  install -m644 ${srcdir}/clang64.ico clang64.ico
  install -m644 ${srcdir}/clangarm64.ico clangarm64.ico
  install -m644 ${srcdir}/msys2.ico msys2.ico
  install -m755 ${srcdir}/msys2_shell.cmd msys2_shell.cmd

  # setup /var
  #
  for d in cache/man local opt log/old lib/misc empty; do
    install -d -m755 var/${d}
  done
  mkdir -p var/tmp

  # setup /usr
  #
  for d in bin include lib share/misc src; do
    install -d -m755 usr/${d}
  done
  for d in $(seq 8); do
    install -d -m755 usr/share/man/man${d}
  done
  # various shell scripts
  for f in cmd start shell; do
    install -m755 ${srcdir}/${f} usr/bin
  done

  install -Dm 644 ${srcdir}/cygwin.ldif usr/share/Msys/cygwin.ldif

  # setup 'configure' helpers
  #
  install -m644 ${srcdir}/main-config.site etc/config.site
  install -D -m644 ${srcdir}/redirect-config.site usr/local/etc/config.site

  # setup /mingw hierarchies
  for m in mingw32 mingw64 clang64 clangarm64 ucrt64; do
    install -d -m755 ${m}
    for d in bin etc include lib share; do
      install -d -m755 ${m}/${d}
    done
  done
}
