summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV.Krishn <vkrishn@insteps.net>2024-02-02 15:56:09 +0530
committerV.Krishn <vkrishn@insteps.net>2024-02-02 15:56:09 +0530
commitb060061105b32ae1601d91a60438648d6fba1b9d (patch)
tree113bb69bf1b4ae11d822c2eb2b1956a18ba4e5df
parent5ab292a85021e1bc81789bcb216a738d3707dbe9 (diff)
downloadapklist-b060061105b32ae1601d91a60438648d6fba1b9d.tar.bz2
add fetch-apk script
-rw-r--r--fetch-apk.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/fetch-apk.sh b/fetch-apk.sh
new file mode 100644
index 0000000..2f88411
--- /dev/null
+++ b/fetch-apk.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+VER=v3.18
+ARCH=x86_64
+
+# -------------------------------------------------------------------
+# main/community/testing
+# -------------------------------------------------------------------
+set_apks_url() {
+ local branch=$1
+ echo '>>> set branch: '$branch
+ url=https://dl-cdn.alpinelinux.org/alpine/${VER}/${branch}/${ARCH}
+ dest=/media/usb/apks2/alpine/${VER}/${branch}/${ARCH}/
+}
+
+# -------------------------------------------------------------------
+make_fetch_apks_list() {
+ # altenative methods:
+ # 1. apk add ffmpeg > a.lst 2>&1
+ # 2. 'apk add --simulate' and process the output
+ # 3. 'apk fetch --recursive <pkg name>',
+ # useful if pkgs downloaded can be sorted
+ apk fix > a.lst 2>&1
+
+ grep '^(' a.lst | awk -F' ' '{print $3 " " $4}' > b.lst
+ local branch=$1; local F="${branch}.lst"; rm -f ${F}
+ echo ">>> creating ${F}"
+ cat 'b.lst' | while read f; do \
+ local name=$(echo $f | awk '{print $1}')
+ local file=$(echo $f | sed 's/ //g' | sed 's/(/-/' | sed 's/)//')
+ local b=$(apk policy ${name} | grep -c ${branch})
+ # local b=$(grep -c "^P:${name}$" 'APKINDEX') # alt method
+ if [ $b -gt 0 ]; then
+ echo "adding + $b $file"; echo ${file} >> ${F}
+ fi
+ done
+ echo "... list created, run fetch cmd"
+ rm -f a.lst b.lst
+}
+
+fetch_apks() {
+ local branch=$1
+ cat ${branch}.lst | while read f; do \
+ echo ">>> fetching: $url/$f.apk"
+ wget -c --no-check-certificate $url/$f.apk
+ done
+}
+
+if [ x"$1" = 'xmain' -o x"$1" = 'xcommunity' -o x"$1" = 'xtesting' ]; then
+ set_apks_url $1
+ # cd /tmp
+ if [ x"$2" = 'xmklist' ]; then make_fetch_apks_list "$1"; fi
+ if [ x"$2" = 'xfetch' ]; then fetch_apks "$1"; fi
+fi
+
+# -------------------------------------------------------------------
+# -------------------------------------------------------------------
+
+