#!/bin/bash

# GUI to build Privatix Live-System cd-iso
# Version 10.02.07 by Markus Mandalka


if [ ! -f /usr/bin/lh_build ]; then

  Xdialog --title "Missing package Live-Helper!" --msgbox "Package live-helper is not available!
  
  Please install live-helper first (apt-get install live-helper) !" 0 0;
  exit 1;

fi;



TEMPFILE=/tmp/selection.$$

if ! Xdialog --title "Build Privatix" --menu "Select graphical user interface" 0 0 8 "gnome" "Gnome (standard)" "xfce" "Xfce (light)" "kde" "KDE (privatiks) - alpha! no privacy setup! no security-update-manager!" 2>$TEMPFILE
then
  exit
fi;
build_wm=$(cat $TEMPFILE)

if ! Xdialog --title "Build Privatix" --menu "Select language" 0 0 8 "en" "English" "de" "Deutsch" 2>$TEMPFILE
then
  exit
fi;
build_locales=$(cat $TEMPFILE)


# Update iso with changes of home (all new files and settings), too?
if ! Xdialog --title "Build Privatix" --menu "Update the new iso with changes and settings made in home?

If you want to include new settings or data, be carefull:

This will include all temporary files like browser caches,
your last visited sites, your last opened files and so on.
So everybody who gets the new iso / live-cd
would be able to see all you did sice the start!

If you did private things, first reboot the live-cd,
do only settings and include only data that can be published
and start this script again or select the standard <no> !

Add more to the new iso than security-fixes?
" 0 0 15 "no" "No, add security-updates only, no additional settings and data!" "yes" "Yes, include all changes, settings and temporary caches i changed in home, too."  2>$TEMPFILE
then
  exit
fi;
build_home=$(cat $TEMPFILE)

# Version of the privatix scripts
version="10.02.07"
# Version of the security-patches from security.debian.org (=today)
version_patches=$(date +"%Y%m%d")
build_source=$(dirname $0)

title_saveas="Filename for the iso"

if ! Xdialog --title "$title_saveas" --fselect "/mnt/privatix_${version}_${build_wm}_${build_locales}-${version_patches}.iso" 0 0 2>$TEMPFILE
then
  exit;
fi;
build_filename=$(cat $TEMPFILE)


if [ $build_home == "yes" ]
then
  $build_source/build --update-home --base $build_wm --locales $build_locales --filename $build_filename
else
  $build_source/build --base $build_wm --locales $build_locales --filename $build_filename
fi;
