dragora-installer: More enhancements
[dragora.git] / archive / dragora-installer / parts / InstallPackages
blob4273ed22845ce6ab4bf38c8d30695e9c35d55aa2
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}"/noarch "${MEDIUM_SOURCE}"/@ARCH@ \
28          -type f \( -name "*@${serie}.tlz" -a ! -name "*-pass*" \) -print | \
29           sort >> ${SUBTMPDIR}/return-InstallPackages_All 2> /dev/null || true
30     done
31     unset -v REPLY serie
33     # Proceed to install the packages from selected series
35     if test -s ${SUBTMPDIR}/return-InstallPackages_All
36     then
37         # Set some packages at the top of the list to give priority
38         ed -l -s ${SUBTMPDIR}/return-InstallPackages_All << EOF
39 /etc_/m0
40 /hierarchyfs_/m1
42 EOF
43         qi install \
44          --rootdir=/media/dragora-root \
45          --packagedir=/usr/pkg \
46          --targetdir=/ \
47          --prune - < ${SUBTMPDIR}/return-InstallPackages_All
48     else
49         echo "${PROGRAM}: All: Error the package list is empty." 1>&2
50         exit 99;
51     fi
52     ;;
53 Expert )
54     # Clean for subsequent filling
55     : > ${SUBTMPDIR}/search-InstallPackages_Expert
57     # Read (selected) series
58     IFS= read -r REPLY < ${SUBTMPDIR}/return-ShowSeries
60     for serie in $REPLY
61     do
62         find -- "${MEDIUM_SOURCE}"/noarch "${MEDIUM_SOURCE}"/@ARCH@ \
63          -type f \( -name "*@${serie}.tlz" -a ! -name "*-pass*" \) -print | \
64           sort >> ${SUBTMPDIR}/search-InstallPackages_Expert 2> /dev/null || true
65     done
66     unset -v REPLY serie
68     if test -s ${SUBTMPDIR}/search-InstallPackages_Expert
69     then
70         true
71     else
72         echo "${PROGRAM}: Expert: The package list is empty." 1>&2
73         exit 99;
74     fi
76     # Dialog, package checklist composition
78     cat << EOF > ${SUBTMPDIR}/InstallPackages_Expert
79 dialog --colors --no-shadow \\
80  --backtitle "\ZbPackage selection from chosen series" \\
81  --title "SOFTWARE PACKAGES" \\
82  --no-cancel --item-help --checklist \\
83 "The following packages have been found according to the series.\n\n\\
84 Please use the cursor keys and \\Z3[Space]\\Zn to deselect the packages\n\\
85 you do not want to install.  By default, all packages are selected." \\
86 $(( LINES - 6 )) $COLUMNS 16 \\
87 EOF
89     # Populate checklist item using information from meta files
90     while read -r meta
91     do
92         . "${meta}.txt" || {
93             echo "${PROGRAM}: Error no meta file(s) available." 1>&2
94             exit 99;
95         }
97         echo "\"${full_pkgname%%@*}\" \"@${pkgcategory}\" ON \"${blurb}\" \\" \
98          >> ${SUBTMPDIR}/InstallPackages_Expert
99     done < ${SUBTMPDIR}/search-InstallPackages_Expert
101     # Add tail to get the answers
102     echo ' 2> ${SUBTMPDIR}/return-InstallPackages_Expert' \
103      >> ${SUBTMPDIR}/InstallPackages_Expert
105     touch ${SUBTMPDIR}/return-InstallPackages_Expert
106     . ${SUBTMPDIR}/InstallPackages_Expert;      # Show menu.
108     # Proceed to install the chosen packages
110     if test -s ${SUBTMPDIR}/return-InstallPackages_Expert
111     then
112         # Join the answers by turning blank spaces into a new line
113         sed -e 's/[[:blank:]]/\n/g' \
114             -i ${SUBTMPDIR}/return-InstallPackages_Expert
116         # Set some packages at the top of the list to give priority
117         ed -l -s ${SUBTMPDIR}/return-InstallPackages_Expert << EOF
118 /etc_/m0
119 /hierarchyfs_/m1
122         # Proceed to install if there is a match in the search list
123         while read -r line
124         do
125             grep -F -s -w -m 1 "$line" \
126              ${SUBTMPDIR}/search-InstallPackages_Expert | qi install \
127                --rootdir=/media/dragora-root \
128                --packagedir=/usr/pkg \
129                --targetdir=/ \
130                --prune -
131         done < ${SUBTMPDIR}/return-InstallPackages_Expert
132     else
133         echo "${PROGRAM}: Expert: Error the package list is empty." 1>&2
134         exit 99;
135     fi
136     ;;
137 esac