recipes: compressors/xz: Upgraded to version 5.6.2
[dragora.git] / archive / dragora-installer / parts / InstallPackages
blob5073e3fa7c3ea849c1691e4733de9b16969c986e
1 # This file is part of the 'dragora-installer'.
3 # Purpose: Installation of .tlz packages from series.
5 # Show menu
7 dialog --colors \
8  --backtitle "\ZbPackage installation" \
9  --title "SELECT THE INSTALLATION MODE" \
10  --no-cancel --menu "" 6 58 0 \
11 "All"     "Install all packages from chosen series" \
12 "Expert"  "Select packages individually" \
13  2> ${SUBTMPDIR}/return-InstallPackages
15 # Check menu options
17 case "$(cat -- ${SUBTMPDIR}/return-InstallPackages)" in
18 All )
19     # Clean for subsequent filling
20     : > ${SUBTMPDIR}/return-InstallPackages_All
22     # Read (selected) series
23     IFS= read -r REPLY < ${SUBTMPDIR}/return-ShowSeries
25     for serie in $REPLY
26     do
27         find -- "${MEDIUM_SOURCE}"/@ARCH@ "${MEDIUM_SOURCE}"/noarch \
28          -type f \( -name "*@${serie}.tlz" -a ! -name "*-pass*" \) \
29           -printf '%p\n' >> ${SUBTMPDIR}/return-InstallPackages_All \
30            2> /dev/null || true
31     done
32     unset -v REPLY serie
34     # Proceed to install the packages from selected series
36     if test -s ${SUBTMPDIR}/return-InstallPackages_All
37     then
38        sort ${SUBTMPDIR}/return-InstallPackages_All \
39         > ${SUBTMPDIR}/return-InstallPackages_All.sorted
41         # Set some packages at the top of the list to give priority
43         count=0
44         total=4
45         while test $count -lt $total
46         do
47             for string in hierarchyfs etc 'musl@libs' barelibs
48             do
49                 ed -l -s ${SUBTMPDIR}/return-InstallPackages_All.sorted << EOF
50 /${string}/m${count}
52 EOF
53             count=$((count+1))
54             done
55         done
56         unset -v count total string
58         echo ""
60         # Calculate total number of packages installed to reflect
61         # the progress during package installation
63         x=1
64         total="$(awk 'END{ print NR }' ${SUBTMPDIR}/return-InstallPackages_All.sorted)"
66         while read -r package
67         do
68             qi install --no-rc \
69              --rootdir=/media/dragora-root \
70              --packagedir=/usr/pkg \
71              --targetdir=/ \
72              --prune "$package"
74             printf "%${COLUMNS}s %s\n" \
75              "$(tput bold)$(tput setaf 3)^ ${x} / ${total}$(tput sgr0)"
77             x=$((x+1));         # Increment counter.
78         done < ${SUBTMPDIR}/return-InstallPackages_All.sorted
80         unset -v x total
81     else
82         echo "${PROGRAM}: All: Error the package list is empty." 1>&2
83         exit 99;
84     fi
85     ;;
86 Expert )
87     # Clean for subsequent filling
88     : > ${SUBTMPDIR}/search-InstallPackages_Expert
90     # Read (selected) series
91     IFS= read -r REPLY < ${SUBTMPDIR}/return-ShowSeries
93     for serie in $REPLY
94     do
95         find -- "${MEDIUM_SOURCE}"/@ARCH@ "${MEDIUM_SOURCE}"/noarch \
96          -type f \( -name "*@${serie}.tlz" -a ! -name "*-pass*" \) \
97           -printf '%p\n' >> ${SUBTMPDIR}/search-InstallPackages_Expert \
98            2> /dev/null || true
99     done
100     unset -v REPLY serie
102     if test -s ${SUBTMPDIR}/search-InstallPackages_Expert
103     then
104        sort ${SUBTMPDIR}/search-InstallPackages_Expert \
105         > ${SUBTMPDIR}/search-InstallPackages_Expert.sorted
106     else
107         echo "${PROGRAM}: Expert: The package list is empty." 1>&2
108         exit 99;
109     fi
111     # Dialog, package checklist composition
113     cat << EOF > ${SUBTMPDIR}/InstallPackages_Expert
114 dialog --colors --no-shadow \\
115  --backtitle "\ZbPackage selection from chosen series" \\
116  --title "SOFTWARE PACKAGES" \\
117  --no-cancel --item-help --checklist \\
118 "The following packages have been found according to the series.\n\n\\
119 Please use the cursor keys and \\Z3[Space]\\Zn to deselect the packages\n\\
120 you do not want to install.  By default, all packages are selected." \\
121 $(( LINES - 6 )) $COLUMNS 16 \\
124     # Populate checklist item using information from meta files
125     while read -r meta
126     do
127         if ! . "${meta}.txt"
128         then
129             echo "${PROGRAM}: Error no meta file(s) available." 1>&2
130             exit 99;
131         fi
133         echo "\"${full_pkgname%@*}\" \"@${pkgcategory}\" ON \"${blurb}\" \\" \
134          >> ${SUBTMPDIR}/InstallPackages_Expert
135     done < ${SUBTMPDIR}/search-InstallPackages_Expert.sorted
137     # Add tail to get the answers
138     echo ' 2> ${SUBTMPDIR}/return-InstallPackages_Expert' \
139      >> ${SUBTMPDIR}/InstallPackages_Expert
141     touch ${SUBTMPDIR}/return-InstallPackages_Expert
143     # Show the menu
144     . ${SUBTMPDIR}/InstallPackages_Expert
146     # Proceed to install the chosen packages
148     if test -s ${SUBTMPDIR}/return-InstallPackages_Expert
149     then
150        tr ' ' '\n' < ${SUBTMPDIR}/return-InstallPackages_Expert | \
151         sort > ${SUBTMPDIR}/return-InstallPackages_Expert.sorted
153         # Set some packages at the top of the list to give priority
155         count=0
156         total=4
157         while test $count -lt $total
158         do
159             for string in hierarchyfs etc 'musl$' barelibs
160             do
161                 ed -l -s ${SUBTMPDIR}/return-InstallPackages_Expert.sorted << EOF
162 /${string}/m${count}
165             count=$((count+1))
166             done
167         done
168         unset -v count total string
169     else
170         echo "${PROGRAM}: Expert: Error the package list is empty." 1>&2
171         exit 99;
172     fi
174     echo ""
176     # Calculate total number of packages installed to reflect
177     # the progress during package installation
179     x=1
180     total="$(awk 'END{ print NR }' ${SUBTMPDIR}/return-InstallPackages_Expert.sorted)"
182     # Proceed to install if there is a match in the search list
183     while read -r line
184     do
185         grep -s "${line}[@]" \
186          ${SUBTMPDIR}/search-InstallPackages_Expert.sorted | \
187           qi install --no-rc \
188            --rootdir=/media/dragora-root \
189            --packagedir=/usr/pkg \
190            --targetdir=/ \
191            --prune -
193         printf "%${COLUMNS}s %s\n" \
194          "$(tput bold)$(tput setaf 3)^ ${x} / ${total}$(tput sgr0)"
196         x=$((x+1));             # Increment counter.
197     done < ${SUBTMPDIR}/return-InstallPackages_Expert.sorted
199     unset -v x total
200     ;;
201 esac