# Maintainer (Artegos): Alex Filgueira <alexfilgueira@antergos.com>
# Maintainer: André Silva <emulatorman@hyperbola.info>

_pkgname=Cnchi
pkgname=cnchi
pkgver=0.12.0
pkgrel=1.parabola1
pkgdesc='Graphical Installer for Parabola GNU/Linux-libre, without nonfree software installation support (Parabola rebranded)'
arch=(any)
license=(GPL)
url="https://github.com/Antergos/Cnchi"
conflicts=(cnchi-dev)
depends=(python pyalpm python-gobject python-dbus python-cairo python-requests
         python-parted webkitgtk upower python-mako iso-codes gptfdisk python-bugsnag)
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/Antergos/Cnchi/archive/v${pkgver}.tar.gz"
         libre+rebranding.patch)
sha256sums=('ada2fecd5710307570feb6a8e01ebafb57ef55d2f1fe1d01d1929608a89af17b')

prepare() {
	cd "${srcdir}/${pkgname}-${pkgver}"

	patch -Np1 -i ${srcdir}/libre+rebranding.patch
}

package() {
	cd "${srcdir}/${pkgname}-${pkgver}"

	install -d ${pkgdir}/usr/share/locale/
	install -d ${pkgdir}/usr/share/cnchi
	install -Dm755 "bin/${pkgname}" "${pkgdir}/usr/bin/cnchi"
	install -Dm755 "${pkgname}.desktop" "${pkgdir}/usr/share/applications/cnchi.desktop"
	for i in cnchi bin data scripts ui; do
		cp -R ${i} "${pkgdir}/usr/share/cnchi/"
	done

  	for files in po/*; do
    	if [ -f "$files" ] && [ "$files" != 'po/cnchi.pot' ]; then
        	STRING_PO=`echo ${files#*/}`
        	STRING=`echo ${STRING_PO%.po}`
        	mkdir -p ${pkgdir}/usr/share/locale/${STRING}/LC_MESSAGES
        	msgfmt $files -o ${pkgdir}/usr/share/locale/${STRING}/LC_MESSAGES/cnchi.mo
        	echo "${STRING} installed..."
    	fi
	done
}
# -*- mode: bash;-*-
