3
# Copyright (C) 2015,2016 Etersoft
4
# Copyright (C) 2015,2016 Vitaly Lipatov <lav@etersoft.ru>
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Affero General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Affero General Public License for more details.
16
# You should have received a copy of the GNU Affero General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
23
PAOURL="https://packages.altlinux.org"
27
# http://petstore.swagger.io/?url=http://packages.altlinux.org/api/docs
28
assure_exists curl || return 1
29
showcmd curl "$PAOURL/api/$1"
30
a='' curl -s --header "Accept: application/json" "$PAOURL/api/$1"
33
# TODO: use /home/lav/Projects/git/JSON.sh
37
#grep '"$FIELD"' | sed -e 's|.*"$FIELD":"||g' | sed -e 's|".*||g'
38
$SHAREDIR/tools_json -b | grep -E "\[.*\"$FIELD\"\]" | sed -e 's|.*[[:space:]]"\(.*\)"|\1|g'
43
run_command_if_exists()
47
if is_command "$CMD" ; then
54
# TODO: use something like xdg-browser
58
for i in xdg-open firefox chromium links ; do
59
run_command_if_exists $i "$@" && return
63
__query_package_hl_url()
67
paoapi srpms/$1 | get_pao_var url
79
# TODO: for binary packages?
80
query_package_field URL "$1" || __query_package_hl_url "$1"
85
docmd brew "$1" | grep "^From: " | sed -e "s|^From: ||"
89
fatal "rpm based distro supported only. TODO: Realize via web service?"
95
loc=$(a='' natspec --locale 2>/dev/null)
96
[ -n "$loc" ] || loc=$LANG
103
loc=$(get_locale | cut -c1-2)
111
echo "$PAOURL/$loc/Sisyphus/srpms"
119
local srpm=$(print_srcname "$1")
120
[ -n "$srpm" ] || fatal "Can't get source name for $1"
121
echo "$(get_pao_url)/$srpm"
125
fatal "rpm based distro supported only. TODO: Realize via web service?"
131
[ -n "$pkg_filenames" ] || fatal "Info: package name is missed"
134
for f in $pkg_names $pkg_files ; do
135
[ "$f" = "-p" ] && PAO="$f" && continue
136
if [ -n "$PAO" ] ; then
137
pkg_url=$(query_altlinux_url $f)
139
pkg_url=$(query_package_url $f)
141
[ -n "$pkg_url" ] && open_browser "$pkg_url" && continue
142
warning "Can't get URL for $f package"
145
#for f in $pkg_names ; do
149
# TODO: -p for p.a.o (see rpmurl)