generated from tumble1999/ppa-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-packages.sh
executable file
·40 lines (39 loc) · 1.14 KB
/
get-packages.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
CONFIG=`cat ppa-config.json`
repos=`echo "${CONFIG}" | jq -r ".repos[]"`
distros=`echo "${CONFIG}" | jq -c ".distros[]"`
if [[ -n "${repos}" ]]; then
for repo in $repos; do
echo "https://api.github.com/repos/${repo}/releases/latest"
release=`curl -sL https://api.github.com/repos/${repo}/releases/latest`
assets=`echo "${release}" | jq -c ".assets[]"`
if [[ -n "${assets}" ]]; then
for asset in $assets; do
name=`echo "${asset}"| jq -r ".name"`
url=`echo "${asset}"| jq -r ".browser_download_url"`
echo "name: ${name}"
echo "url: ${url}"
if [[ -n "${distros}" ]]; then
for distro in $distros; do
echo "distro ${distro}"
folder=`echo "${distro}" | jq -r ".[0]"`
exts=(`echo "${distro}" | jq -r ".[1:][]"`)
echo "folder: ${folder}"
echo "extentions: ${exts[@]}"
if [[ -n "${exts}" ]]; then
for extention in $exts; do
if [[ $name == $extention ]]; then
if [ ! -d $folder ]; then mkdir $folder; fi
cd $folder
if [ -f $name ]; then rm $name; fi
wget $url
cd ..
fi
done
fi
done
fi
done
fi
done
fi