# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=filesystem
pkgver=2015.04
pkgrel=3
pkgdesc='Base filesystem'
arch=('i686' 'x86_64')
license=('BSD')
url='http://sourceforge.net/projects/msys2/'
groups=('base')
provides=('msys2-base')
replaces=('msys2-base')
backup=('etc/fstab' 'etc/shells' 'etc/profile'
        etc/bash.bash{rc,_logout} etc/skel/.bash{rc,_profile,_logout}
        etc/nsswitch.conf)
source=('bash.bash_logout'
        'bash.bashrc'
        'cmd'
        'dep-search'
        'dot.bash_logout'
        'dot.bash_profile'
        'dot.bashrc'
        'dot.inputrc'
        'dot.profile'
        'fstab'
        'mingw32_shell.bat'
        'mingw64_shell.bat'
        'msys2_shell.bat'
        'msys2.ico'
        'nsswitch.conf'
        'profile'
        'profile.lang.sh'
        'profile.tzset.sh'
        'regen-info.sh'
        'shells'
        'start'
        '01-devices.post'
        '03-mtab.post'
        '05-home-dir.post'
        '06-windows-files.post'
        '07-pacman-key.post'
        '08-xml-catalog.post'
        'cygwin.ldif')
md5sums=('3b95f37af49beb642c8fe174dd1f63fc'
         'fa8c4d2dee439851cb280f904dde766e'
         '9ffd57721725e961ffd5e311d6c2f374'
         'e6a830e08fce049c78272d275f57d57f'
         '42f4400ed2314bd7519c020d0187edc5'
         'e32cd0cf441ce0e8c57f550b0d28b182'
         '7a8cf2e199bc046bcfed1fc75275b15c'
         'ff5b9ce40fb39b9c745f188bde6dabea'
         '061895b3b304f5b7552689df408e3086'
         'b0eb2ba1c1bc95e678309fd36dac27db'
         '60b98a16b10ca531034bb82ab56018b0'
         '62c83d220f0d5e0afe6532d7f0f55a66'
         'ba944a5704589a598920d2564853b009'
         '292ad5cdd78abac9d694cc06819a96fc'
         'b29485d6e832dce9b27a2c025b53bdd8'
         '69032f71e69a70676444c21e358b6fa4'
         '118fa00617d4d0b2eb337dd565d44494'
         '39c1d2412eb62864c8c07cb2557c7da3'
         '3b6753667b61800db1a30c614efd1ee1'
         'bb51026508581e55bbefe36e2b799108'
         '900c95162b9c3f7a29912408e0579852'
         '7df6a2d0c05e49bf9224fdfbc240a730'
         'c3c57aa78cdb6cd5dea1e51b12cdbc1d'
         '632ea6c9928b682d1c95806483902332'
         'fef301aa9d3357ca034fbb3adf77f0f0'
         '8ab86771cc1180fc52adca9629858243'
         '751ef1e25f070cd8085f9598c783c018'
         'f1db1f7f275738092a38012c89a19d63')

build() {
  cd ${srcdir}
}

package() {
  cd ${pkgdir}

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

  mkdir -p tmp

  # setup /etc
  #
  install -d etc/{fstab.d,skel,profile.d,post-install}
  for f in bash.bashrc bash.bash_logout fstab shells profile nsswitch.conf; do
    install -m644 ${srcdir}/${f} etc/
  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.inputrc etc/skel/.inputrc
  install -m644 ${srcdir}/dot.bash_profile etc/skel/.bash_profile
  install -m644 ${srcdir}/dot.bash_logout etc/skel/.bash_logout
  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}/msys2.ico msys2.ico
  install -m755 ${srcdir}/msys2_shell.bat msys2_shell.bat
  install -m755 ${srcdir}/mingw32_shell.bat mingw32_shell.bat
  install -m755 ${srcdir}/mingw64_shell.bat mingw64_shell.bat

  # 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 dep-search regen-info.sh; do
    install -m755 ${srcdir}/${f} usr/bin
  done

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

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