Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
8e2ed7b9f9 | |||
e7252333b0 | |||
0496e2c887 | |||
a450ff9708 | |||
dd0d7f7902 | |||
840ab9254c | |||
b2dc6c01d7 |
@@ -2,15 +2,16 @@ prm
|
|||||||
---
|
---
|
||||||
A very simple AUR/ABS helper. Doesn't build packages, only gets the sources.
|
A very simple AUR/ABS helper. Doesn't build packages, only gets the sources.
|
||||||
|
|
||||||
Usage: prm [flags] <package>
|
Usage: prm [flags] <package>
|
||||||
Flags:
|
Flags:
|
||||||
-h Show this message.
|
-h Show this message.
|
||||||
-s Search for <package>.
|
-s Search for <package>.
|
||||||
-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`.
|
||||||
|
74
prm
74
prm
@@ -6,8 +6,9 @@
|
|||||||
_self="${0##*/}"
|
_self="${0##*/}"
|
||||||
|
|
||||||
cfg_workdir="$PWD"
|
cfg_workdir="$PWD"
|
||||||
cfg_aur_url='https://aur.archlinux.org'
|
cfg_aur_url="https://aur.archlinux.org"
|
||||||
cfg_aur_api="${cfg_aur_url}/rpc.php"
|
|
||||||
|
cfg_curl_opts=( '--silent' '--location' )
|
||||||
|
|
||||||
err() { printf "$@" >&2; }
|
err() { printf "$@" >&2; }
|
||||||
|
|
||||||
@@ -22,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
|
||||||
@@ -53,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; }
|
||||||
@@ -66,40 +68,44 @@ aur.get() {
|
|||||||
|
|
||||||
read -r pkg_aur_info
|
read -r pkg_aur_info
|
||||||
|
|
||||||
{
|
# A temporary hack till AUR4 becomes the main version
|
||||||
read -r pkg_base
|
read -r pkg_base < <( jshon -e results -e PackageBase -u <<< "$pkg_aur_info" )
|
||||||
read -r tarball_path
|
tarball_path="/cgit/aur.git/snapshot/${pkg_base}.tar.gz"
|
||||||
} < <(
|
|
||||||
jshon -e results -e PackageBase -u -p -e URLPath -u <<< "$pkg_aur_info"
|
|
||||||
)
|
|
||||||
|
|
||||||
(( 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}"
|
||||||
|
|
||||||
printf "Downloading %s\n" "${pkg_base}"
|
if [[ -d "$pkg_base" ]]; then
|
||||||
{ curl -skL "${cfg_aur_url}${tarball_path}" | gzip -d | tar x; } || {
|
if ! (( flag_nopull )); then
|
||||||
err "Fail!\n"
|
printf 'Updating %s\n' "$pkg_base"
|
||||||
return 1
|
cd "$pkg_base"
|
||||||
|
git pull || {
|
||||||
|
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
|
||||||
@@ -111,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
|
||||||
@@ -131,7 +137,7 @@ abs.get() {
|
|||||||
svn_repo='packages';;
|
svn_repo='packages';;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
svn checkout "svn://svn.archlinux.org/${svn_repo}/${1}/trunk" "${cfg_workdir}/${1}"
|
svn export "svn://svn.archlinux.org/${svn_repo}/${1}/trunk" "${cfg_workdir}/${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_argv() {
|
set_argv() {
|
||||||
@@ -188,6 +194,10 @@ main() {
|
|||||||
action='search'
|
action='search'
|
||||||
flag_search_syncdb=1;;
|
flag_search_syncdb=1;;
|
||||||
|
|
||||||
|
(-u)
|
||||||
|
cfg_aur_url="$2"
|
||||||
|
shift;;
|
||||||
|
|
||||||
(-d)
|
(-d)
|
||||||
if [[ "$action" == 'get' ]]; then
|
if [[ "$action" == 'get' ]]; then
|
||||||
flag_get_deps=1
|
flag_get_deps=1
|
||||||
@@ -200,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"
|
||||||
@@ -217,6 +229,8 @@ main() {
|
|||||||
unset flag_search_aur flag_search_syncdb
|
unset flag_search_aur flag_search_syncdb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg_aur_api="${cfg_aur_url}/rpc.php"
|
||||||
|
|
||||||
[[ "$action" ]] || {
|
[[ "$action" ]] || {
|
||||||
usage
|
usage
|
||||||
return 1
|
return 1
|
||||||
|
Reference in New Issue
Block a user