3
# Copyright (C) 2016-2018 Etersoft
4
# Copyright (C) 2016-2018 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/>.
20
alt_base_dist_url="http://ftp.basealt.ru/pub/distributions"
24
# force download if wildcard is used
25
echo "$pkg_urls" | grep -q "[?*]" && return 1
27
# force download if repack is asked
28
[ -n "$repack" ] && return 1
30
# install of remote files has a side affect
31
# (more fresh package from a repo can be installed instead of the file)
34
# # do not support https yet
35
# echo "$pkg_urls" | grep -q "https://" && return 1
36
# pkg_names="$pkg_names $pkg_urls"
43
# pkg_names="$pkg_names $pkg_urls"
46
# pkg_names="$pkg_names $pkg_urls"
49
# pkg_names="$pkg_names $pkg_urls"
58
# pkg_names="$pkg_names $pkg_urls"
64
[ -n "$pkg_names" ] && pkg_names="$pkg_names $pkg_urls" || pkg_names="$pkg_urls"
68
# for download before install / checking
72
[ -z "$pkg_urls" ] && return
73
for url in $pkg_urls ; do
75
tmppkg="$(mktemp -d --tmpdir=$BIGTMPDIR)" || fatal
76
remove_on_exit $tmppkg
77
chmod $verbose a+rX $tmppkg
79
local latest='--latest'
80
# hack: download all if mask is *.something
81
basename "$url" | grep -q "^\*\." && latest=''
83
if docmd eget $latest "$url" ; then
86
[ "$i" = "*" ] && warning "Incorrect true status from eget. No saved files from download $url, ignoring" && continue
87
[ -s "$tmppkg/$i" ] || continue
88
chmod $verbose a+r "$tmppkg/$i"
89
[ -n "$pkg_files" ] && pkg_files="$pkg_files $tmppkg/$i" || pkg_files="$tmppkg/$i"
92
warning "Failed to download $url, ignoring"
97
pkg_filenames=$(strip_spaces "$pkg_files $pkg_names")
100
# NOTE: call __clean_downloaded_pkg_files after
101
__handle_pkg_urls_to_install()
103
#[ -n "$pkg_urls" ] || return
105
# FIXME: check type of pkg_urls separately?
106
if [ "$(get_package_type "$pkg_urls")" != $PKGFORMAT ] || ! __use_url_install ; then
107
# use workaround with eget: download and put in pkg_files
114
__handle_pkg_urls_to_checking()
116
#[ -n "$pkg_urls" ] || return
118
# use workaround with eget: download and put in pkg_files
126
__epm_get_altpkg_url()
128
info "TODO: https://packages.altlinux.org/api/branches"
130
local arch=$(paoapi packages/$1 | get_pao_var arch)
131
# FIXME: arch can be list
132
[ "$arch" = "noarch" ] || arch=$(arch)
133
# HACK: filename can be list
134
local filename=$(paoapi packages/$1 | get_pao_var filename | grep $arch)
135
[ -n "$filename" ] || fatal "Can't get filename"
136
# fixme: get from /branches
137
local dv=$DISTRNAME/$DISTRVERSION/branch
138
[ "$DISTRVERSION" = "Sisyphus" ] && dv=$DISTRNAME/$DISTRVERSION
139
echo "$alt_base_dist_url/$dv/$arch/RPMS.classic/$filename"
147
echo "$url" | sed -e "s|$alt_base_dist_url/$DISTRNAME|http://mirror.yandex.ru/altlinux|g"
148
echo "$url" | sed -e "s|$alt_base_dist_url/$DISTRNAME|http://download.etersoft.ru/pub/ALTLinux|g"
151
__epm_print_url_alt_check()
156
tm="$(mktemp)" || fatal
161
local buildtime=$(paoapi packages/$pkg | get_pao_var buildtime)
163
echo "Latest release: $(paoapi packages/$pkg | get_pao_var sourcepackage) $buildtime"
164
__epm_print_url_alt "$1" | while read url ; do
165
eget --get-response $url >$tm || { echo "$url: missed" ; continue ; }
166
local http=$(cat $tm | grep "^HTTP" | sed -e "s|\r||g")
167
local lastdate=$(cat $tm | grep "^Last-Modified:" | sed -e "s|\r||g")
168
local size=$(cat $tm | grep "^Content-Length:" | sed -e "s|^Content-Length: ||g" | sed -e "s|\r||g")
169
echo "$url ($http $lastdate) Size: $size"
177
if [ "$1" = "--check" ] ; then
182
load_helper epm-sh-altlinux
184
# TODO: enable if install --download-only will works
185
if tasknumber "$@" >/dev/null ; then
186
load_helper epm-addrepo
187
load_helper epm-reposave
188
load_helper epm-removerepo
189
load_helper epm-Install
191
local installlist="$(get_task_packages $*)"
192
# hack: drop -devel packages to avoid package provided by multiple packages
193
installlist="$(estrlist reg_exclude ".*-devel .*-devel-static .*-checkinstall .*-debuginfo" "$installlist")"
194
[ -n "$verbose" ] && info "Packages from task(s): $installlist"
199
[ -n "$verbose" ] && epm repo list
200
docmd epm download $print_url $installlist
207
# old systems ignore reinstall ?
209
for i in $(sudocmd apt-get install -y --print-uris --reinstall "$pkg" | cut -f1 -d " " | grep ".rpm'$" | sed -e "s|^'||" -e "s|'$||") ; do
210
echo "$(basename "$i")" | grep -q "^$pkg" || continue
211
[ -n "$print_url" ] && echo "$i" && continue
219
local url=$(__epm_get_altpkg_url $pkg)
220
[ -n "$url" ] || warning "Can't get URL for $pkg"
221
if [ -n "$checkflag" ] ; then
222
__epm_print_url_alt_check "$pkg" "$url"
224
docmd eget $url || return
233
case "$BASEDISTRNAME" in
235
__epm_download_alt $*
242
if [ -n "$print_url" ] ; then
243
docmd apt-get download --print-uris $* | cut -f1 -d " " | grep ".deb'$" | sed -e "s|^'||" -e "s|'$||"
246
docmd apt-get download $*
249
sudocmd dnf download $print_url $*
252
sudocmd apt-cyg download $*
255
docmd pkcon download $*
258
# TODO: check yum install --downloadonly --downloaddir=/tmp <package-name>
259
assure_exists yumdownloader yum-utils
260
sudocmd yumdownloader $*
263
sudocmd dnf download $*
266
sudocmd urpmi --no-install $URPMOPTIONS $@
269
sudocmd tce-load -w $*
281
fatal "Have no suitable command for $PMTYPE"