Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
8e2ed7b9f9 | |||
e7252333b0 | |||
0496e2c887 |
@@ -9,8 +9,9 @@ A very simple AUR/ABS helper. Doesn't build packages, only gets the sources.
|
|||||||
-S Search only in the sync db. Implies -s.
|
-S Search only in the sync db. Implies -s.
|
||||||
-A Search only in AUR. Implies -s.
|
-A Search only in AUR. Implies -s.
|
||||||
-d Get the package sources (default). Set twice to also get the dependencies.
|
-d Get the package sources (default). Set twice to also get the dependencies.
|
||||||
-f Force downloading package sources even if they are already present in the working directory.
|
-n Don't update existing git repos.
|
||||||
-w <dir> Set the working directory.
|
-w <dir> Set the working directory.
|
||||||
|
--nossl Set curl's --insecure flag.
|
||||||
|
|
||||||
You can override any value in the script in \$HOME/.config/prm.rc.sh
|
You can override any value in the script in \$HOME/.config/prm.rc.sh
|
||||||
By default prm downloads the sources into the current directory. Controlled by `$cfg_workdir`.
|
By default prm downloads the sources into the current directory. Controlled by `$cfg_workdir`.
|
||||||
|
85
prm
85
prm
@@ -6,9 +6,9 @@
|
|||||||
_self="${0##*/}"
|
_self="${0##*/}"
|
||||||
|
|
||||||
cfg_workdir="$PWD"
|
cfg_workdir="$PWD"
|
||||||
|
cfg_aur_url="https://aur.archlinux.org"
|
||||||
|
|
||||||
# Version 4 by default.
|
cfg_curl_opts=( '--silent' '--location' )
|
||||||
cfg_aur_version='4'
|
|
||||||
|
|
||||||
err() { printf "$@" >&2; }
|
err() { printf "$@" >&2; }
|
||||||
|
|
||||||
@@ -23,15 +23,16 @@ usage() {
|
|||||||
-S Search only in the sync db. Implies -s.
|
-S Search only in the sync db. Implies -s.
|
||||||
-A Search only in AUR. Implies -s.
|
-A Search only in AUR. Implies -s.
|
||||||
-d Get the package sources (default). Set twice to also get the dependencies.
|
-d Get the package sources (default). Set twice to also get the dependencies.
|
||||||
-f Force downloading package sources even if they are already present in the working directory.
|
-n Don't update existing git repos.
|
||||||
-w <dir> Set the working directory.
|
-w <dir> Set the working directory.
|
||||||
|
--nossl Set curl's --insecure flag.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
aur.search() {
|
aur.search() {
|
||||||
declare i aur_api_search_data aur_search_result_num aur_search_results version description
|
declare i aur_api_search_data aur_search_result_num aur_search_results version description
|
||||||
|
|
||||||
aur_api_search_data=$( curl -skL "${cfg_aur_api}?type=search&arg=${1}" )
|
aur_api_search_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}?type=search&arg=${1}" )
|
||||||
aur_search_result_num=$( jshon -e resultcount -u <<< "$aur_api_search_data" )
|
aur_search_result_num=$( jshon -e resultcount -u <<< "$aur_api_search_data" )
|
||||||
|
|
||||||
# Exit if nothing was found
|
# Exit if nothing was found
|
||||||
@@ -54,7 +55,7 @@ aur.search() {
|
|||||||
aur.info() {
|
aur.info() {
|
||||||
declare pkg_aur_info aur_query_result
|
declare pkg_aur_info aur_query_result
|
||||||
|
|
||||||
pkg_aur_info=$( curl -skL "${cfg_aur_api}?type=info&arg=${1}" 2>/dev/null )
|
pkg_aur_info=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}?type=info&v=2&arg=${1}" 2>/dev/null )
|
||||||
aur_query_result=$( jshon -e resultcount -u <<< "$pkg_aur_info" )
|
aur_query_result=$( jshon -e resultcount -u <<< "$pkg_aur_info" )
|
||||||
|
|
||||||
(( aur_query_result )) || { return 1; }
|
(( aur_query_result )) || { return 1; }
|
||||||
@@ -68,45 +69,43 @@ aur.get() {
|
|||||||
read -r pkg_aur_info
|
read -r pkg_aur_info
|
||||||
|
|
||||||
# A temporary hack till AUR4 becomes the main version
|
# A temporary hack till AUR4 becomes the main version
|
||||||
if (( cfg_aur_version == 4 )); then
|
read -r pkg_base < <( jshon -e results -e PackageBase -u <<< "$pkg_aur_info" )
|
||||||
read -r pkg_base < <( jshon -e results -e PackageBase -u <<< "$pkg_aur_info" )
|
tarball_path="/cgit/aur.git/snapshot/${pkg_base}.tar.gz"
|
||||||
tarball_path="/cgit/aur.git/snapshot/${pkg_base}.tar.gz"
|
|
||||||
else
|
|
||||||
{
|
|
||||||
read -r pkg_base
|
|
||||||
read -r tarball_path
|
|
||||||
} < <(
|
|
||||||
jshon -e results -e PackageBase -u -p -e URLPath -u <<< "$pkg_aur_info"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
|
|
||||||
(( flag_force )) || {
|
|
||||||
[[ -d "${cfg_workdir}/${pkg_base}" ]] && {
|
|
||||||
printf "Found %s in %s, skipping. Use -f to override\n" "${pkg_base}" "${cfg_workdir}"
|
|
||||||
return 17
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cd "$cfg_workdir"
|
cd "$cfg_workdir"
|
||||||
|
|
||||||
|
printf 'Working in %s\n' "${cfg_workdir}"
|
||||||
|
|
||||||
printf "Working in %s\n" "${cfg_workdir}"
|
if [[ -d "$pkg_base" ]]; then
|
||||||
|
if ! (( flag_nopull )); then
|
||||||
printf "Downloading %s\n" "${pkg_base}"
|
printf 'Updating %s\n' "$pkg_base"
|
||||||
{ curl -skL "${cfg_aur_url}${tarball_path}" | gzip -d | tar x; } || {
|
cd "$pkg_base"
|
||||||
err "Fail!\n"
|
git pull || {
|
||||||
return 1
|
err 'Fail!'
|
||||||
}
|
return 21
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf 'Cloning %s\n' "$pkg_base"
|
||||||
|
git clone "https://aur.archlinux.org/${pkg_base}.git" || {
|
||||||
|
err 'Fail!'
|
||||||
|
return 19
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
if (( flag_get_deps )); then
|
if (( flag_get_deps )); then
|
||||||
cd "${cfg_workdir}/${pkg_base}"
|
cd "${cfg_workdir}/${pkg_base}"
|
||||||
source PKGBUILD
|
|
||||||
|
|
||||||
for i in "${depends[@]}" "${makedepends[@]}"; do
|
read -d '' -r -a depends < <(
|
||||||
|
jshon -e results -e Depends -a -u -p -p -e MakeDepends -a -u <<< "$pkg_aur_info" 2>/dev/null
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in "${depends[@]}"; do
|
||||||
dep_name="${i/[<>=]*}"
|
dep_name="${i/[<>=]*}"
|
||||||
aur_api_multireq+="&arg\[\]=$dep_name"
|
aur_api_multireq+="&arg\[\]=$dep_name"
|
||||||
done
|
done
|
||||||
|
|
||||||
aur_deps_api_data=$( curl -skL "${cfg_aur_api}?type=multiinfo${aur_api_multireq}" )
|
aur_deps_api_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}?type=multiinfo${aur_api_multireq}" )
|
||||||
aur_deps_count=$( jshon -e resultcount <<< "$aur_deps_api_data" )
|
aur_deps_count=$( jshon -e resultcount <<< "$aur_deps_api_data" )
|
||||||
|
|
||||||
if (( aur_deps_count )); then
|
if (( aur_deps_count )); then
|
||||||
@@ -118,9 +117,9 @@ aur.get() {
|
|||||||
aur.get < <(aur.info "$i")
|
aur.get < <(aur.info "$i")
|
||||||
_result="$?"
|
_result="$?"
|
||||||
|
|
||||||
(( _result > 0 && result != 17 )) && {
|
if (( _result > 0 && result != 17 )); then
|
||||||
return "$_result"
|
return "$_result"
|
||||||
}
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -195,10 +194,6 @@ main() {
|
|||||||
action='search'
|
action='search'
|
||||||
flag_search_syncdb=1;;
|
flag_search_syncdb=1;;
|
||||||
|
|
||||||
(-V)
|
|
||||||
cfg_aur_version="$2"
|
|
||||||
shift;;
|
|
||||||
|
|
||||||
(-u)
|
(-u)
|
||||||
cfg_aur_url="$2"
|
cfg_aur_url="$2"
|
||||||
shift;;
|
shift;;
|
||||||
@@ -215,7 +210,9 @@ main() {
|
|||||||
cfg_workdir="$2"
|
cfg_workdir="$2"
|
||||||
shift;;
|
shift;;
|
||||||
|
|
||||||
(-f) flag_force=1;;
|
(-n) flag_nopull=1;;
|
||||||
|
|
||||||
|
(--nossl) cfg_curl_opts+=( '--insecure' );;
|
||||||
|
|
||||||
(-*)
|
(-*)
|
||||||
err "Unknown key: %s\n" "$1"
|
err "Unknown key: %s\n" "$1"
|
||||||
@@ -232,14 +229,6 @@ main() {
|
|||||||
unset flag_search_aur flag_search_syncdb
|
unset flag_search_aur flag_search_syncdb
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -z "$cfg_aur_url" ]]; then
|
|
||||||
if (( cfg_aur_version == 3 )); then
|
|
||||||
cfg_aur_url="https://aur.archlinux.org"
|
|
||||||
else
|
|
||||||
cfg_aur_url="https://aur4.archlinux.org"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
cfg_aur_api="${cfg_aur_url}/rpc.php"
|
cfg_aur_api="${cfg_aur_url}/rpc.php"
|
||||||
|
|
||||||
[[ "$action" ]] || {
|
[[ "$action" ]] || {
|
||||||
|
Reference in New Issue
Block a user