123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- #!/usr/bin/env bash
- set -o errexit #>Exit when a command fails (returns non-zero)
- set -o pipefail #>Exit when a command within a pipeline fail (returns non-zero)
- #set -o nounset #>Forbid to use unset
- # Reset language to default
- #export LANG=C
- # Get Distro Infos
- [[ -f /etc/lsb-release ]] && source /etc/lsb-release
- # Set Root
- ROOT=$(dirname $0)
- # Set Binary Paths
- ZENITY='/usr/bin/zenity'
- SUDO='/usr/bin/pkexec'
- [[ ! -x "${ZENITY}" ]] && pamac install --no-confirm "$(pamac search --files "${ZENITY}" --quiet)"
- TMPDIR="/tmp/ma-mi/"
- mkdir -p $TMPDIR
- echo 'iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAABmJLR0QA/wD/AP+gvaeTAAAFD0lEQVR4nO2dT2hcRRzHv7+3m2TJ28TaW7Glmrq0tHhpShoxKUJy0UuylODZq6CCVtOmVHowxDRpQQSJFyFehFprIoKXxEP1YuIqHhSlWqGU3kzF7obsbvaNh/QtqaTZN/P+zMzu73Pe38zs95N5f2bevgAMwzAMwzAMwzAMwzBMq0BRNCLGjrUX1zrzRDQCgeMA9gNwo2jbIEoA7oDwo4BYyD6+vkCf/VIJ22hoAfeHT56GEJcI6Anblk0Q8KdH4u2updXrIdtRQ4yNpUprt6cB8WaYAVgPiVl3YHWcLsJTKXdU++XwHyDoTOnbvinVcqUZcH/45GkS4ppqp80IAXl3eWVBoU4OMXasfX3N/VUAh2Rrm5y/3L2lI7InZulDUHGtM8/h78hTxb/dEdkiaQEEjMrWtApEiF8AQL3yNS3DCdkClRmwT7amVSDgCdkaaQECyMrWtAoq2SjfBzDRwAI0wwI0wwI0Y4QA6uoGH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LnRk4Ad4YMJN+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
- # Icons
- declare -A Icons
- Icons[close]="$TMPDIR/close.png"
- Icons[import]="$TMPDIR/import.png"
- Icons[save]="$TMPDIR/save.png"
- # Translation
- # > Main Menu
- declare -A GuiMainMenu
- GuiMainMenu[title]='Hauptmenü'
- 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>'
- GuiMainMenu[save]='Speichern'
- GuiMainMenu[import]='Importieren'
- GuiMainMenu[close]='Schließen'
- GuiMainMenu[ok]='Auswählen'
- GuiMainMenu[cancel]='Schließen'
- # > Save Package List
- declare -A GuiSavePackageList
- GuiSavePackageList[title]='Paketliste'
- GuiSavePackageList[ok]='Sichern'
- GuiSavePackageList[cancel]='Abbrechen'
- GuiSavePackageList[text]='Wähle Pakete aus, die in die Liste soll.'
- # > Save File Selection
- declare -A GuiSaveFileSelection
- GuiSaveFileSelection[date]=$(date +%Y-%m-%d)
- GuiSaveFileSelection[version]=${DISTRIB_RELEASE}
- GuiSaveFileSelection[codename]=${DISTRIB_CODENAME}
- GuiSaveFileSelection[distro]=${DISTRIB_ID}
- GuiSaveFileSelection[filename]="Paketliste.txt"
- GuiSaveFileSelection[title]="Wo willst du deine Paketliste speichern?"
- GuiSaveFileSelection[ok]="Speichern"
- GuiSaveFileSelection[cancel]="Abbrechen"
- # > Read Package List
- declare -A GuiReadPackageList
- GuiReadPackageList[title]='Paketliste'
- GuiReadPackageList[ok]='Importieren'
- GuiReadPackageList[cancel]='Abbrechen'
- GuiReadPackageList[text]='Wähle Pakete aus, die du importieren willst.'
- # > Read File Selection
- declare -A GuiReadFileSelection
- GuiReadFileSelection[title]="Wähle eine Paketliste."
- GuiReadFileSelection[ok]="Lesen"
- GuiReadFileSelection[cancel]="Abbrechen"
- # > Import Progress
- declare -A GuiImportProgress
- GuiImportProgress[title]="Bitte warten..."
- GuiImportProgress[text]="Pakete werden installiert."
- # > Update Mirror Progress
- declare -A GuiUpdateMirrorProgress
- GuiUpdateMirrorProgress[title]="Bitte warten..."
- GuiUpdateMirrorProgress[text]="Spiegel-Server werden aktualisert."
- function GetAllPackages ()
- {
- local packages=( $(pacman -Qq | sed -r "s/^(.+)/TRUE \\1/g") )
- local PackageList=$($ZENITY --list --checklist --height="420" --hide-header \
- --print-column=2 --window-icon=${Icons['import']} \
- --title="${GuiSavePackageList[title]}" \
- --text="${GuiSavePackageList[text]}" \
- --ok-label="${GuiSavePackageList[ok]}" \
- --cancel-label="${GuiSavePackageList[cancel]}" \
- --column="" --column="" \
- ${packages[@]})
- echo "${PackageList}" | tr "|" "\n"
- }
- function GetPackagesFromList ()
- {
- local FilePath=$($ZENITY --file-selection)
- local SavedPackages=( $(cat $FilePath) )
- local LocalPackages=( $(pacman -Qq) )
- # Sort existing packages out
- for index in $(seq 0 ${#LocalPackages[@]}); do
- pkg=${LocalPackages[$index]}
- unset LocalPackages[$index]
- for index2 in ${!SavedPackages[@]}; do
- if [[ ${pkg} == ${SavedPackages[$index2]} ]]; then
- unset SavedPackages[$index2]
- break
- fi
- done
- done
- local packages=( $( echo ${SavedPackages[@]} | tr " " "\n" | sed -r "s/^(.+)/TRUE \\1/g" ) )
- local PackageList=$($ZENITY --list --checklist --height="420" --hide-header \
- --window-icon=${Icons['import']} \
- --title="${GuiReadPackageList[title]}" \
- --text="${GuiReadPackageList[text]}" \
- --ok-label="${GuiReadPackageList[ok]}" \
- --cancel-label="${GuiReadPackageList[cancel]}" \
- --column="1" --column="2" \
- "${packages[@]}")
-
- echo "${PackageList}" | tr "|" "\n"
- }
- function SavePackageList()
- {
- local PackageList=( $(GetAllPackages) )
- local FileName=""
- local FileName+="${GuiSaveFileSelection[date]}"
- local FileName+="_"
- local FileName+="${GuiSaveFileSelection[distro]}"
- local FileName+="-"
- local FileName+="${GuiSaveFileSelection[codename]}"
- local FileName+="-"
- local FileName+="${GuiSaveFileSelection[version]}"
- local FileName+="_"
- local FileName+="${GuiSaveFileSelection[filename]}"
- local FilePath=$( $ZENITY --file-selection --save --confirm-overwrite \
- --window-icon=${Icons['save']} --filename=${FileName})
- echo ${PackageList[@]} | tr " " "\n" | tee $FilePath
- }
- function InstallPackageList ()
- {
- local PackageList=( $(GetPackagesFromList) )
- (
- for pkg in ${PackageList[@]}; do
- echo "# Installiere $pkg";
- pamac install --no-confirm $pkg;
- done
- ) | $ZENITY --progress --height="100" --width="400" --auto-close --auto-kill --no-cancel --pulsate --time-remaining \
- --title="${GuiImportProgress[title]}" --text="${GuiImportProgress[text]}"
- }
- function main ()
- {
- while true
- do
- menu=$( $ZENITY --list --imagelist --height="420" --hide-header\
- --print-column=2 --window-icon=${Icons['import']} \
- --title="${GuiMainMenu[title]}" \
- --column="" --column="" \
- --text="${GuiMainMenu[text]}" \
- --ok-label="${GuiMainMenu[ok]}" \
- --cancel-label="${GuiMainMenu[cancel]}" \
- ${Icons[save]} ${GuiMainMenu[save]} \
- ${Icons[import]} ${GuiMainMenu[import]} \
- ${Icons[close]} ${GuiMainMenu[close]})
-
- case $menu in
- "${GuiMainMenu[save]}") SavePackageList ;;
- "${GuiMainMenu[import]}") InstallPackageList ;;
- "${GuiMainMenu[close]}") break ;;
- *) break ;;
- esac
-
- done
- }
- main "$@"
|