summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorlesto2019-01-16 01:03:32 +0100
committerlesto2019-01-16 01:03:32 +0100
commit71f9729983010f6a172b2d41f3d1083b68231943 (patch)
tree6cc1203e016ae4937974c911727d24f57e1bf078
downloadaur-71f9729983010f6a172b2d41f3d1083b68231943.tar.gz
first commit
-rw-r--r--.SRCINFO14
-rw-r--r--PKGBUILD22
-rwxr-xr-xpp.sh64
3 files changed, 100 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 00000000000..94567b03fa5
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,14 @@
+pkgbase = pacman-parallelizer
+ pkgdesc = A minimal package downloader for pacman, using aria2
+ pkgver = 1
+ pkgrel = 1
+ url = https://github.com/lestofante/PacmanParallelizer
+ arch = any
+ license = GPL3
+ depends = aria2
+ depends = pacman-contrib
+ source = pp.sh
+ md5sums = 5670471a6fbddec18d3a562f11969c0c
+
+pkgname = pacman-parallelizer
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..0f05fb5f670
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,22 @@
+# Maintainer: lesto <lestofante88@gmail.com>
+pkgname=pacman-parallelizer
+pkgver=1
+pkgrel=1
+pkgdesc="A minimal package downloader for pacman, using aria2"
+arch=(any)
+url="https://github.com/lestofante/PacmanParallelizer"
+license=('GPL3')
+depends=('aria2' 'pacman-contrib')
+source=("pp.sh")
+md5sums=('5670471a6fbddec18d3a562f11969c0c')
+
+build() {
+ cd "$srcdir"
+ chmod +x ./pp.sh
+}
+
+package() {
+ cd "$srcdir"
+ mkdir -p "$pkgdir/usr/bin"
+ cp pp.sh "$pkgdir/usr/bin"
+}
diff --git a/pp.sh b/pp.sh
new file mode 100755
index 00000000000..a913fa4dce1
--- /dev/null
+++ b/pp.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+if [[ $UID -ne 0 ]]; then
+ sudo -p 'Restarting as root, password: ' bash $0 "$@"
+ exit $?
+fi
+
+#read mirrorlist, "Server =" lines, remove all before and including "= " (10 char)
+readarray -t mirrorArray < <(grep "^Server =" /etc/pacman.d/mirrorlist | cut -c 10-)
+
+#randomize the order of the mirror
+mirrorArray=( $(shuf -e "${mirrorArray[@]}") )
+
+#now get the list of stuff to update
+readarray -t packageList < <(checkupdates | cut -d ' ' -f 1,4)
+
+pidToWait=''
+
+for pkgNameAndVersion in "${packageList[@]}"; do
+ pkgName=${pkgNameAndVersion% *}
+
+ #echo "pkgName $pkgName"
+
+ repoAndArch=($(pacman -Si $pkgName | grep 'Repository :\|Architecture :' | cut -c 19-))
+
+ repo=${repoAndArch[0]}
+ archpkg=${repoAndArch[1]}
+
+ arch='x86_64'
+
+ downloadList=''
+ for mirror in "${mirrorArray[@]}"; do
+ pkgNameAndVersion=${pkgNameAndVersion/ /-}
+ val=${mirror/\$repo/$repo}
+ val=$(echo ${val/\$arch/$arch}/$pkgNameAndVersion-$archpkg.pkg.tar.xz)
+ #echo - $repo - $arch - $val - $mirror
+ downloadList="$downloadList $val"
+ done
+
+ #echo $downloadList
+ aria2c -c $downloadList -d /var/cache/pacman/pkg/ &> /dev/null &
+
+ running=$(jobs |wc -l)
+ echo ">>> $(date +%T) | Downloading $pkgName, $running/10 download"
+
+ while [ $running -gt 10 ]; do
+ sleep 0.1 #sleep 0.1 second
+ running=$(jobs |wc -l)
+ done
+
+done
+
+#now wait for all remaining jobs
+echo "all download started, waiting for completition"
+wait
+
+if [[ $# -gt 0 ]]; then
+ #DROP PRIVILEDGES
+ sudo -s -u $SUDO_USER $1 -Syu --noconfirm
+else
+ echo "downloads complete, calling pacman"
+ pacman -Syu --noconfirm
+fi
+