dragora-installer: remove LC_COLLATE variable
[dragora.git] / archive / dragora-installer / parts / InstallPackages
blobf5056807f2241a99357e42d1dfdd1cfe19fe9f42
1 # This file is part of the 'dragora-installer'.
3 # Purpose: Installation of .tlz packages from chosen series.
5 _convertTag()
7     for file in "$@"
8     do
9         test -s "$file" || continue
11         # Compose checklist to be showed by the installer
13         case $file in
14         */@ARCH@/*)  arch_name=@ARCH@;;
15                  *)  arch_name=noarch;;
16         esac
18         tag_name="${file##*/}"
19         (
20             cd -- ${SUBTMPDIR}/return-InstallPackages_Expert.dir || exit $?
21             cat << EOF > ${arch_name}.${tag_name}
22 dialog --colors \\
23  --backtitle "\ZbSelect packages from chosen series" \\
24  --title "[ ${arch_name} | $(printf "%s" "${tag_name#*-}" | tr _ /) ]" \\
25  --item-help --checklist "" 20 $COLUMNS 15 \\
26 EOF
27             { # Add double quotes plus output file for items
28               sed -e 's/:/\" \"/g' $file | sed -e 's/^/\"/;s/$/\" \\/'
29               echo " 2> \${SUBTMPDIR}/return-InstallPackages_Expert.dir/return-${arch_name}-${tag_name} || return 0"
30             } >> ${arch_name}.${tag_name}
31         )
32     done
33     unset file arch_name tag_name
36 # Show menu
37 dialog --colors \
38  --backtitle "\ZbInstallation mode" \
39  --title "SELECT THE INSTALLATION MODE" \
40  --no-cancel --menu "" 7 66 0 \
41 "All"     "Install packages from selected series" \
42 "Expert"  "Select packages from chosen series" \
43  2> ${SUBTMPDIR}/return-InstallPackages
45 # Check for selected options
46 case "$(cat -- ${SUBTMPDIR}/return-InstallPackages)" in
47 All)
48     : > ${SUBTMPDIR}/return-InstallPackages_All;                # Clean up file.
49     IFS= read -r REPLY < ${SUBTMPDIR}/return-ShowSeries;        # Read selected series.
50     for serie in $REPLY
51     do
52         find "${MEDIUM_SOURCE}"/noarch/$serie "${MEDIUM_SOURCE}"/@ARCH@/$serie \
53          -type f \( -name '*.tlz' -a ! -name '*_pass*' \) \
54           >> ${SUBTMPDIR}/return-InstallPackages_All 2> /dev/null || true
55     done
56     unset REPLY serie
58     # Proceed to install the packages found
60     if test -s ${SUBTMPDIR}/return-InstallPackages_All
61     then
62         # Set some packages at the top of the list to give priority
63         ed -l -s ${SUBTMPDIR}/return-InstallPackages_All << EOF
64 /_etc/m0
65 /_hierarchyfs/m1
67 EOF
68         qi -r /media/dragora-root -P /usr/pkg -t / -i -p - \
69          < ${SUBTMPDIR}/return-InstallPackages_All
70     else
71         echo "${PROGRAM}: Error the package list is empty." 1>&2
72         exit 99;
73     fi
74     ;;
75 Expert)
76     # Re-create subdirectory for (converted) package tags
77     rm -rf -- ${SUBTMPDIR}/return-InstallPackages_Expert.dir
78     mkdir -p -- ${SUBTMPDIR}/return-InstallPackages_Expert.dir
80     IFS= read -r REPLY < ${SUBTMPDIR}/return-ShowSeries;        # Read selected series.
81     for serie in $REPLY
82     do
83         _convertTag "${MEDIUM_SOURCE}"/noarch/${serie}/tagfile* \
84                     "${MEDIUM_SOURCE}"/@ARCH@/${serie}/tagfile*
85     done
86     unset serie _convertTag
88     # Show package checklist
89     for list in ${SUBTMPDIR}/return-InstallPackages_Expert.dir/*.tagfile*
90     do
91         . $list
92     done
93     unset list
95     # Description of external file list:
96     # .taglist:  All the dialog answers.
97     # .search:   Package search (from selected series, .taglist).
99     # Join the answers by turning blank spaces into a new line
100     if ls ${SUBTMPDIR}/return-InstallPackages_Expert.dir/return-* > /dev/null 2>&1
101     then
102         sed -e 's/[[:blank:]]/\n/g' \
103          ${SUBTMPDIR}/return-InstallPackages_Expert.dir/return-* 2> /dev/null | \
104           sort > ${SUBTMPDIR}/return-InstallPackages_Expert.taglist
105     else
106         echo "${PROGRAM}: Error all series have been canceled from package selection." 1>&2
107         exit 99;
108     fi
110     for serie in $REPLY
111     do
112         while read -r name
113         do
114             find "${MEDIUM_SOURCE}"/noarch/$serie "${MEDIUM_SOURCE}"/@ARCH@/$serie \
115              -type f -name "${name}*.tlz" 2> /dev/null | fgrep -s -w -m 1 $name \
116               >> ${SUBTMPDIR}/return-InstallPackages_Expert.search || true
117         done < ${SUBTMPDIR}/return-InstallPackages_Expert.taglist
118     done
119     unset REPLY name
121     # Proceed to install the chosen packages
123     if test -s ${SUBTMPDIR}/return-InstallPackages_Expert.search
124     then
125         # Set some packages at the top of the list to give priority
126         ed -l -s ${SUBTMPDIR}//return-InstallPackages_Expert.search << EOF
127 /_etc/m0
128 /_hierarchyfs/m1
131         qi -r /media/dragora-root -P /usr/pkg -t / -i -p - \
132          < ${SUBTMPDIR}/return-InstallPackages_Expert.search
133     else
134         echo "${PROGRAM}: Error the package list is empty." 1>&2
135         exit 99;
136     fi
137     ;;
138 esac