Skip to content
Snippets Groups Projects
Commit 2571b48d authored by Bensong Liu's avatar Bensong Liu
Browse files

Bug fix

parent 26dda297
No related branches found
No related tags found
No related merge requests found
TODO: filter not done # Upgrade your AUR packages in parallel
Building is slow, downloading is also slow. Why not build everything in parallel to overlap CPU-heavy tasks, Network-heavy tasks, and IO-heavy tasks?
## Configure
Modify config.sh, and set `aurpar_config_threads`, `aurpar_config_aur_manager` and `aurpar_aur_user`.
You may have a look at other options below, but I don't think you're interested in them.
## Usage
```bash
sudo ./aur-parallel-upgrade.sh
```
## FAQ
- Multiple tasks printing texts at the same time and my terminal messed up!
If you want to avoid the cross-talking, please remove `--line-buffer` from `aur-parallel-upgrade.sh`.
...@@ -25,8 +25,12 @@ source "$my_path/config.sh" ...@@ -25,8 +25,12 @@ source "$my_path/config.sh"
function _aurpar_do_install () { function _aurpar_do_install () {
# do_install $package_name # do_install $package_name
# NO input, outputs to stderr. # NO input, outputs to stderr.
echo "AURPAR> Issue new job: $1" 1>&2
sudo -u "$aurpar_aur_user" yaourt -S --noconfirm "$1" 1>&2 sudo -u "$aurpar_aur_user" yaourt -S --noconfirm "$1" 1>&2
return $?
ret=$?
echo "AURPAR> Job exited: $1, status=$ret" 1>&2
return $ret
} }
function get_package_list () { function get_package_list () {
...@@ -44,17 +48,52 @@ function get_package_list () { ...@@ -44,17 +48,52 @@ function get_package_list () {
fi fi
} }
function get_package_list_with_filter () {
# NO input, NO arg. Result outputs to stdout, seprated by '\n'
list=`get_package_list` || return $?
while read -r blacklist; do
list=`echo "$list" | grep -vE "^(aur/)?$blacklist$"`
done <<< "$aurpar_config_package_blacklist"
echo $list
return $?
}
pkgs=`get_package_list` || { echo "Failed to get package list. Exiting..." 1>&2; exit $?; } pkgs=`get_package_list` || { echo "Failed to get package list. Exiting..." 1>&2; exit $?; }
echo "============ Packages to UPGRADE: " echo "============ Packages to UPGRADE: "
echo "$pkgs" echo "$pkgs"
pkgs=`get_package_list_with_filter` || { echo "Failed to get package list. Exiting..." 1>&2; exit $?; }
echo "============ Jobs to issue: "
echo "$pkgs"
read -p "Start the upgrade? [y/N] " -n 1 -r
[[ $REPLY =~ ^[Yy]$ ]] || { echo "User give up the upgrade. " 1>&2; exit 0; }
export -f _aurpar_do_install export -f _aurpar_do_install
export aurpar_aur_user export aurpar_aur_user
echo "$pkgs" | SHELL=$(type -p bash) PATH="$my_path:$PATH" parallel --max-procs "$aurpar_config_threads" _aurpar_do_install '{}' || echo "Done. But some package failed to upgrade. " 1>&2 echo "$pkgs" | SHELL=$(type -p bash) PATH="$my_path:$PATH" parallel --line-buffer --max-procs "$aurpar_config_threads" _aurpar_do_install '{}' || echo "Done. But some package failed to upgrade. " 1>&2
exit 0 exit 0
############ notes ############ notes ############################
# list packages: # list packages:
echo n | yaourt -Su --aur 2>/dev/null | sed 's/\r/\n/g' | grep '^aur/' echo n | yaourt -Su --aur 2>/dev/null | sed 's/\r/\n/g' | grep '^aur/'
pakku -Syup | grep aur.archlinux.org | sed 's/^.*aur.archlinux.org.//g' | sed 's/.git$//g' pakku -Syup | grep aur.archlinux.org | sed 's/^.*aur.archlinux.org.//g' | sed 's/.git$//g'
# old code
+function get_tasks_list_impl () {
+ if [[ "$aurpar_config_aur_manager" = "yaourt" ]]; then
+ echo n | yaourt -Su --aur 2>/dev/null | sed 's/\r/\n/g' | grep '^aur/'
+ elif [[ "$aurpar_config_aur_manager" = "pakku" ]]; then
+ pakku -Syup | grep aur.archlinux.org | sed 's/^.*aur.archlinux.org.//g' | sed 's/.git$//g'
+ else
+ echo "Unsupported AUR helper: $aurpar_config_aur_manager . Don't know how to retrive package list. exiting..."
+ exit 2
+ fi
+}
+function get_tasks_list () {
+}
...@@ -54,5 +54,8 @@ aurpar_config_package_blacklist=( ...@@ -54,5 +54,8 @@ aurpar_config_package_blacklist=(
# wps-office # wps-office
wps-office-mime wps-office-mime
# frpc
frps
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment