InstallPackages 5.8 KB

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