manjaro-migration.sh 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. #!/usr/bin/env bash
  2. set -o errexit #>Exit when a command fails (returns non-zero)
  3. set -o pipefail #>Exit when a command within a pipeline fail (returns non-zero)
  4. #set -o nounset #>Forbid to use unset
  5. # Reset language to default
  6. #export LANG=C
  7. # Get Distro Infos
  8. [[ -f /etc/lsb-release ]] && source /etc/lsb-release
  9. # Set Root
  10. ROOT=$(dirname $0)
  11. # Set Binary Paths
  12. ZENITY='/usr/bin/zenity'
  13. SUDO='/usr/bin/pkexec'
  14. [[ ! -x "${ZENITY}" ]] && pamac install --no-confirm "$(pamac search --files "${ZENITY}" --quiet)"
  15. TMPDIR="/tmp/ma-mi/"
  16. mkdir -p $TMPDIR
  17. echo 'iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAABmJLR0QA/wD/AP+gvaeTAAAFD0lEQVR4nO2dT2hcRRzHv7+3m2TJ28TaW7Glmrq0tHhpShoxKUJy0UuylODZq6CCVtOmVHowxDRpQQSJFyFehFprIoKXxEP1YuIqHhSlWqGU3kzF7obsbvaNh/QtqaTZN/P+zMzu73Pe38zs95N5f2bevgAMwzAMwzAMwzAMwzBMq0BRNCLGjrUX1zrzRDQCgeMA9gNwo2jbIEoA7oDwo4BYyD6+vkCf/VIJ22hoAfeHT56GEJcI6Anblk0Q8KdH4u2updXrIdtRQ4yNpUprt6cB8WaYAVgPiVl3YHWcLsJTKXdU++XwHyDoTOnbvinVcqUZcH/45GkS4ppqp80IAXl3eWVBoU4OMXasfX3N/VUAh2Rrm5y/3L2lI7InZulDUHGtM8/h78hTxb/dEdkiaQEEjMrWtApEiF8AQL3yNS3DCdkClRmwT7amV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of1hK/nudo4BXwI/ibsv9RM8PsV9JtxvvBhGNqdDN9wggf8EF9MvCnvLnRk4Ad4YMJN+XYe+AG/U+GLyErhw2Sb8u08/WRd4TfpFcGHSTbl23n1iUiCP6QV/E35JfzyuMbwHfOAcRoJH6I25e3E8kRsY48M/PEeCdyUd9V398EXkVHw7bb7KHwZ6gG/zFtf+GI1aGr4MMmmfDd8/ctYgu9W5Kb83Q2/ObbavWxkDHyI/SfLGIDPiFjbc+1uhQ8x/2QZw/CbrHWFLzIOfoBDgv+a6lGAb88Ddeumgg+hy1BP+Bwx+CE+GL8MPULwTSdMDx8m25R3wy+TCX6fojfl/37pHVRxiCoWKDnk/me+1i62pvDLown/5tu/Mtq7/eSTBo+xin4drRuTFYtWkXWGX37MZne2VzQoIxT1TVjAMEYVh3aRMr2m8F1ytjcQPkR8E66r041RVY8Qrew6w285QRztjYAPYXPArsB2fWLHfLESe4ewla0n/NuF9ruhVXvaMV/001suYH0KWYb+Uj8xrrUS8N7NYi3hA/xhd2a0x2htGz7AO4xUQAhSF4AbPvABXv5bwa0DWTv4uwt4beekP3zhZoFccDLrUdB/Y/XQL64/kC8WPxHUV4HtLvhQDpLPb8L3vgCPfQ628jsb/idFxu93c17bOcnV/bzdrBZ82QX1doFcuPKNM3/1ApiUlJSUlJSUlJSUlJSUlJSUdCT1P6sYb4s+EzwrAAAAAElFTkSuQmCC' | base64 --decode > $TMPDIR/save.png
  20. # Icons
  21. declare -A Icons
  22. Icons[close]="$TMPDIR/close.png"
  23. Icons[import]="$TMPDIR/import.png"
  24. Icons[save]="$TMPDIR/save.png"
  25. # Translation
  26. # > Main Menu
  27. declare -A GuiMainMenu
  28. GuiMainMenu[title]='Hauptmenü'
  29. GuiMainMenu[text]='<big>Manjaro Migration</big>\n<sup>Es sichert alle Paketename in eine Text-Datei</sup>\n<sup>und importiert diese dann von dieser Liste.</sup>'
  30. GuiMainMenu[save]='Speichern'
  31. GuiMainMenu[import]='Importieren'
  32. GuiMainMenu[close]='Schließen'
  33. GuiMainMenu[ok]='Auswählen'
  34. GuiMainMenu[cancel]='Schließen'
  35. # > Save Package List
  36. declare -A GuiSavePackageList
  37. GuiSavePackageList[title]='Paketliste'
  38. GuiSavePackageList[ok]='Sichern'
  39. GuiSavePackageList[cancel]='Abbrechen'
  40. GuiSavePackageList[text]='Wähle Pakete aus, die in die Liste soll.'
  41. # > Save File Selection
  42. declare -A GuiSaveFileSelection
  43. GuiSaveFileSelection[date]=$(date +%Y-%m-%d)
  44. GuiSaveFileSelection[version]=${DISTRIB_RELEASE}
  45. GuiSaveFileSelection[codename]=${DISTRIB_CODENAME}
  46. GuiSaveFileSelection[distro]=${DISTRIB_ID}
  47. GuiSaveFileSelection[filename]="Paketliste.txt"
  48. GuiSaveFileSelection[title]="Wo willst du deine Paketliste speichern?"
  49. GuiSaveFileSelection[ok]="Speichern"
  50. GuiSaveFileSelection[cancel]="Abbrechen"
  51. # > Read Package List
  52. declare -A GuiReadPackageList
  53. GuiReadPackageList[title]='Paketliste'
  54. GuiReadPackageList[ok]='Importieren'
  55. GuiReadPackageList[cancel]='Abbrechen'
  56. GuiReadPackageList[text]='Wähle Pakete aus, die du importieren willst.'
  57. # > Read File Selection
  58. declare -A GuiReadFileSelection
  59. GuiReadFileSelection[title]="Wähle eine Paketliste."
  60. GuiReadFileSelection[ok]="Lesen"
  61. GuiReadFileSelection[cancel]="Abbrechen"
  62. # > Import Progress
  63. declare -A GuiImportProgress
  64. GuiImportProgress[title]="Bitte warten..."
  65. GuiImportProgress[text]="Pakete werden installiert."
  66. # > Update Mirror Progress
  67. declare -A GuiUpdateMirrorProgress
  68. GuiUpdateMirrorProgress[title]="Bitte warten..."
  69. GuiUpdateMirrorProgress[text]="Spiegel-Server werden aktualisert."
  70. function GetAllPackages ()
  71. {
  72. local packages=( $(pacman -Qq | sed -r "s/^(.+)/TRUE \\1/g") )
  73. local PackageList=$($ZENITY --list --checklist --height="420" --hide-header \
  74. --print-column=2 --window-icon=${Icons['import']} \
  75. --title="${GuiSavePackageList[title]}" \
  76. --text="${GuiSavePackageList[text]}" \
  77. --ok-label="${GuiSavePackageList[ok]}" \
  78. --cancel-label="${GuiSavePackageList[cancel]}" \
  79. --column="" --column="" \
  80. ${packages[@]})
  81. echo "${PackageList}" | tr "|" "\n"
  82. }
  83. function GetPackagesFromList ()
  84. {
  85. local FilePath=$($ZENITY --file-selection)
  86. local SavedPackages=( $(cat $FilePath) )
  87. local LocalPackages=( $(pacman -Qq) )
  88. # Sort existing packages out
  89. for index in $(seq 0 ${#LocalPackages[@]}); do
  90. pkg=${LocalPackages[$index]}
  91. unset LocalPackages[$index]
  92. for index2 in ${!SavedPackages[@]}; do
  93. if [[ ${pkg} == ${SavedPackages[$index2]} ]]; then
  94. unset SavedPackages[$index2]
  95. break
  96. fi
  97. done
  98. done
  99. local packages=( $( echo ${SavedPackages[@]} | tr " " "\n" | sed -r "s/^(.+)/TRUE \\1/g" ) )
  100. local PackageList=$($ZENITY --list --checklist --height="420" --hide-header \
  101. --window-icon=${Icons['import']} \
  102. --title="${GuiReadPackageList[title]}" \
  103. --text="${GuiReadPackageList[text]}" \
  104. --ok-label="${GuiReadPackageList[ok]}" \
  105. --cancel-label="${GuiReadPackageList[cancel]}" \
  106. --column="1" --column="2" \
  107. "${packages[@]}")
  108. echo "${PackageList}" | tr "|" "\n"
  109. }
  110. function SavePackageList()
  111. {
  112. local PackageList=( $(GetAllPackages) )
  113. local FileName=""
  114. local FileName+="${GuiSaveFileSelection[date]}"
  115. local FileName+="_"
  116. local FileName+="${GuiSaveFileSelection[distro]}"
  117. local FileName+="-"
  118. local FileName+="${GuiSaveFileSelection[codename]}"
  119. local FileName+="-"
  120. local FileName+="${GuiSaveFileSelection[version]}"
  121. local FileName+="_"
  122. local FileName+="${GuiSaveFileSelection[filename]}"
  123. local FilePath=$( $ZENITY --file-selection --save --confirm-overwrite \
  124. --window-icon=${Icons['save']} --filename=${FileName})
  125. echo ${PackageList[@]} | tr " " "\n" | tee $FilePath
  126. }
  127. function InstallPackageList ()
  128. {
  129. local PackageList=( $(GetPackagesFromList) )
  130. (
  131. for pkg in ${PackageList[@]}; do
  132. echo "# Installiere $pkg";
  133. pamac install --no-confirm $pkg;
  134. done
  135. ) | $ZENITY --progress --height="100" --width="400" --auto-close --auto-kill --no-cancel --pulsate --time-remaining \
  136. --title="${GuiImportProgress[title]}" --text="${GuiImportProgress[text]}"
  137. }
  138. function main ()
  139. {
  140. while true
  141. do
  142. menu=$( $ZENITY --list --imagelist --height="420" --hide-header\
  143. --print-column=2 --window-icon=${Icons['import']} \
  144. --title="${GuiMainMenu[title]}" \
  145. --column="" --column="" \
  146. --text="${GuiMainMenu[text]}" \
  147. --ok-label="${GuiMainMenu[ok]}" \
  148. --cancel-label="${GuiMainMenu[cancel]}" \
  149. ${Icons[save]} ${GuiMainMenu[save]} \
  150. ${Icons[import]} ${GuiMainMenu[import]} \
  151. ${Icons[close]} ${GuiMainMenu[close]})
  152. case $menu in
  153. "${GuiMainMenu[save]}") SavePackageList ;;
  154. "${GuiMainMenu[import]}") InstallPackageList ;;
  155. "${GuiMainMenu[close]}") break ;;
  156. *) break ;;
  157. esac
  158. done
  159. }
  160. main "$@"