description='Various extensions for Nemo'
url='https:/github.com/linuxmint/nemo-extensions'

makedepends=(intltool gobject-introspection meson samurai
             clutter-gtk clutter-gst libmusicbrainz5 gtksourceview4
             xreader cjs)
run=(nemo file-roller imagemagick samba vte python python-gobject)

set=(cinnamon)

packager="Tnut <tnut@nutyx.org>"
contributors="Fanch,Spiky"

name=nemo-extensions
version=5.6.0
release=3

LIST=(nemo-preview nemo-terminal nemo-audio-tab nemo-python
      nemo-emblems nemo-fileroller nemo-image-converter nemo-share)

PKGMK_KEEP_SOURCES="no"
source=(https://download.tuxfamily.org/nutyx/files/cinnamon-translations-5.2.2.tar.gz
        https://github.com/linuxmint/$name/archive/$version.tar.gz)


build() {

cd $name-${version}

for i in "${LIST[@]}"; do
 if [[ -f "$i/meson.build" ]]; then
   mkdir $i/build
   cd $i/build
   meson --prefix=/usr \
   --libexecdir=lib/$i \
   --buildtype=plain \
   ..

   samu
   
   DESTDIR=$PKG samu install
   cd -
 fi
 case $i in 
    nemo-emblems|nemo-audio-tab|nemo-pastebin)
      cd $i
      python setup.py build
      python setup.py install --prefix=/usr --root=$PKG --skip-build --optimize=1
      cd -;;
    nemo-terminal)
      cd $i
      install -Dm644 src/nemo_terminal.py -t $PKG/usr/share/nemo-python/extensions/
      install -Dm755 src/nemo-terminal-prefs.py $PKG/usr/bin/nemo-terminal-prefs
      install -Dm644 src/org.nemo.extensions.nemo-terminal.gschema.xml -t \
      $PKG/usr/share/glib-2.0/schemas/
      install -Dm644 pixmap/logo_120x120.png -t \
      $PKG/usr/share/nemo-terminal/
      cd -;;
 esac
done

}
package() {
wget https://download.tuxfamily.org/nutyx/files/cinnamon-translations-5.2.2.tar.gz
bsdtar xf cinnamon-translations-5.2.2.tar.gz
cd cinnamon-translations-5.2.2
for file in po-export/$name/*.po
do
    LANG=${file/*-/}
    install -d $PKG/usr/share/locale/${LANG%.*}/LC_MESSAGES
    msgfmt -o $PKG/usr/share/locale/${LANG%.*}/LC_MESSAGES/$name.mo \
    $file
done
}
