#!/bin/sh
cat /dev/null > /tmp/SeTnewtag
dialog --title "select pkgs from tex(TeX related packages)" \
  --checklist "select packages from tex series. \
You can move cursor with UP/DOWN key and push space \
key to select pkgs. After finish selecting, \
push Enter to start installation. " 24 72 15 \
"texlive" "TeX Live programs" "on" \
"texlive_texmf" "TeX Live macros and font libraries" "on" \
"texlive_texmf_doc" "TeX Live macros and font libraries (doc)" "on" \
"texlive_texmf_doc_fonts" "TeX Live macros and font libraries (doc/fonts)" "on" \
"texlive_texmf_doc_generic" "TeX Live macros and font libraries (doc/generic)" "on" \
"texlive_texmf_doc_latex0" "TeX Live macros and font libraries (doc/latex[0/6])" "on" \
"texlive_texmf_doc_latex1" "TeX Live macros and font libraries (doc/latex[1/6])" "on" \
"texlive_texmf_doc_latex2" "TeX Live macros and font libraries (doc/latex[2/6])" "on" \
"texlive_texmf_doc_latex3" "TeX Live macros and font libraries (doc/latex[3/6])" "on" \
"texlive_texmf_doc_latex4" "TeX Live macros and font libraries (doc/latex[4/6])" "on" \
"texlive_texmf_doc_latex5" "TeX Live macros and font libraries (doc/latex[5/6])" "on" \
"texlive_texmf_doc_latex6" "TeX Live macros and font libraries (doc/latex[6/6])" "on" \
"texlive_texmf_fonts" "TeX Live macros and font libraries (fonts)" "on" \
"texlive_texmf_fonts_afm" "TeX Live macros and font libraries (fonts/afm)" "on" \
"texlive_texmf_fonts_opentype" "TeX Live macros and font libraries (fonts/opentype)" "on" \
"texlive_texmf_fonts_tfm" "TeX Live macros and font libraries (fonts/tfm)" "on" \
"texlive_texmf_fonts_truetype" "TeX Live macros and font libraries (fonts/truetype)" "on" \
"texlive_texmf_fonts_type1" "TeX Live macros and font libraries (fonts/type1)" "on" \
"texlive_texmf_fonts_type1_public" "TeX Live macros and font libraries (fonts/type1/public)" "on" \
"texlive_texmf_fonts_type1_public_cbfonts" "TeX Live macros and font libraries (fonts/type1/public/cbfonts)" "on" \
"texlive_texmf_fonts_type1_public_cm_super" "TeX Live macros and font libraries (fonts/type1/public/cm-super)" "on" \
"texlive_texmf_fonts_type1_public_nanumtype1" "TeX Live macros and font libraries (fonts/type1/public/nanumtype1)" "on" \
"texlive_texmf_source" "TeX Live macros and font libraries (source)" "on" \
"texlive_texmf_tex" "TeX Live macros and font libraries (tex)" "on" \
2> /tmp/SeTpkgs
if [ $? = 1 -o $? = 255 ]; then
  rm -f /tmp/SeTpkgs
  > /tmp/SeTnewtag
  for pkg in texlive texlive_texmf texlive_texmf_doc texlive_texmf_doc_fonts texlive_texmf_doc_generic texlive_texmf_doc_latex0 texlive_texmf_doc_latex1 texlive_texmf_doc_latex2 texlive_texmf_doc_latex3 texlive_texmf_doc_latex4 texlive_texmf_doc_latex5 texlive_texmf_doc_latex6 texlive_texmf_fonts texlive_texmf_fonts_afm texlive_texmf_fonts_opentype texlive_texmf_fonts_tfm texlive_texmf_fonts_truetype texlive_texmf_fonts_type1 texlive_texmf_fonts_type1_public texlive_texmf_fonts_type1_public_cbfonts texlive_texmf_fonts_type1_public_cm_super texlive_texmf_fonts_type1_public_nanumtype1 texlive_texmf_source texlive_texmf_tex  ; do 
  echo "$pkg: SKP" >> /tmp/SeTnewtag
  done
  exit
fi
cat /dev/null > /tmp/SeTnewtag
for PACKAGE in texlive texlive_texmf texlive_texmf_doc texlive_texmf_doc_fonts texlive_texmf_doc_generic texlive_texmf_doc_latex0 texlive_texmf_doc_latex1 texlive_texmf_doc_latex2 texlive_texmf_doc_latex3 texlive_texmf_doc_latex4 texlive_texmf_doc_latex5 texlive_texmf_doc_latex6 texlive_texmf_fonts texlive_texmf_fonts_afm texlive_texmf_fonts_opentype texlive_texmf_fonts_tfm texlive_texmf_fonts_truetype texlive_texmf_fonts_type1 texlive_texmf_fonts_type1_public texlive_texmf_fonts_type1_public_cbfonts texlive_texmf_fonts_type1_public_cm_super texlive_texmf_fonts_type1_public_nanumtype1 texlive_texmf_source texlive_texmf_tex  ; do
    if grep "$PACKAGE" /tmp/SeTpkgs 1> /dev/null 2> /dev/null ; then
        echo "$PACKAGE: ADD" >> /tmp/SeTnewtag
    else echo "$PACKAGE: SKP" >> /tmp/SeTnewtag
    fi
done
rm -f /tmp/SeTpkgs
