#!/bin/sh
#a frontend to the package manager. run from "petget" icon on desktop, and Package Manager entry in Setup menu.
#180630 first release.

#looks like there will be three different types of package manager:
#normal native installs, run /usr/local/petget/pkg_chooser.sh
#EasyPak universal apps, run /usr/local/EasyPak/eppm in 'easypak0' container.
#containerized native apps, run /usr/local/easy_containers/eppm in 'petget0' container.

#container 'petget0' will be started at bootup, so ready to chroot into.

export TEXTDOMAIN=petget___ppm
export OUTPUT_CHARSET=UTF-8

export PPM_DLG="
<window title=\"$(gettext 'Easy Package Manager')\" icon-name=\"gtk-harddisk\">
 <vbox>
  <text><label>The Easy Package Manager is able to install apps in the traditional way, in the main filesystem, or isolated in conatiners. The latter is recommended for security reasons, especially is the app requires Internet access.</label></text>
  
  <hbox>
   <text><label>Package Manager for traditional installation:</label></text>
   <button>
    <input>/usr/local/lib/X11/pixmaps/pet48.png</input>
    <action>exit:traditional</action>
   </button>
  </hbox>
  
  <hbox>
   <text><label>Package Manager for containerized apps:</label></text>
   <button>
    <input>/usr/local/lib/X11/pixmaps/ec-pet48.png</input>
    <action>exit:containerized</action>
   </button>
  </hbox>
  
  <hbox>
   <button cancel></button>
  </hbox>
 </vbox>
</window>"

RETPARAMS="`gtkdialog --program=PPM_DLG`"

EXIT="$(echo "$RETPARAMS" | grep '^EXIT=' | cut -f 2 -d '"')"

[ "$EXIT" == "traditional" ] && exec /usr/local/petget/pkg_chooser.sh

[ "$EXIT" == "containerized" ] && exec /usr/local/easy_containers/ec-ppm

###end###
