Commit d6ea3fd0 authored by Vitaly Lipatov's avatar Vitaly Lipatov

introduce get_local_alt_contents_index and use repolist for get local repo path

parent 311b45ed
......@@ -22,24 +22,20 @@ load_helper epm-query
# TODO: port or rewrite apt-file
# https://bugzilla.altlinux.org/show_bug.cgi?id=14449
# see also epm-search-file
local_content_filelist()
__alt_local_content_filelist()
{
local SYSARCH
SYSARCH=$(uname -m)
[ "$SYSARCH" = "x86_64" ] || SYSARCH=i586
load_helper epm-sh-altlinux
local REPODIR=/var/ftp/pub/ALTLinux/Sisyphus
local CI=$REPODIR/$SYSARCH/base/contents_index
local CINOA=$REPODIR/noarch/base/contents_index
local CI="$(get_local_alt_contents_index)"
# TODO: safe way to use less
#local OUTCMD="less"
#[ -n "$USETTY" ] || OUTCMD="cat"
OUTCMD="cat"
test -r $CI && test -r $CINOA || fatal "Can't locate $CI or $CINOA"
{
[ -n "$USETTY" ] && echo "Search in $CI and $CINOA for $1..."
grep -h -- ".*$1$" $CI $CINOA | sed -e "s|\(.*\)\t\(.*\)|\1|g"
[ -n "$USETTY" ] && echo "Search in $CI for $1..."
grep -h -- ".*$1$" $CI | sed -e "s|\(.*\)\t\(.*\)|\1|g"
} | $OUTCMD
}
......@@ -51,7 +47,7 @@ __epm_filelist_remote()
case $PMTYPE in
apt-rpm)
# TODO: use RESTful interface to prometeus? See ALT bug #29496
docmd_foreach local_content_filelist $@
docmd_foreach __alt_local_content_filelist $@
;;
*)
fatal "Query filelist for non installed packages does not realized"
......
......@@ -17,28 +17,19 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# TODO: port or rewrite apt-file
# https://bugzilla.altlinux.org/show_bug.cgi?id=14449
local_content_search()
__alt_local_content_search()
{
# TODO: use global get_sysarch function
local SYSARCH
SYSARCH=$(uname -m)
[ "$SYSARCH" = "x86_64" ] || SYSARCH=i586
load_helper epm-sh-altlinux
local CI="$(get_local_alt_contents_index)"
# FIXME: use config or/and web url
local REPODIR=/var/ftp/pub/ALTLinux/Sisyphus
local CI=$REPODIR/$SYSARCH/base/contents_index
local CINOA=$REPODIR/noarch/base/contents_index
#local OUTCMD="less"
#[ -n "$USETTY" ] || OUTCMD="cat"
OUTCMD="cat"
test -r $CI && test -r $CINOA || fatal "Can't locate $CI or $CINOA"
{
[ -n "$USETTY" ] && echo "Search in $CI and $CINOA for $1..."
grep -h -- ".*$1.*\t" $CI $CINOA | sed -e "s|\(.*\)\t\(.*\)|\2: \1|g"
[ -n "$USETTY" ] && echo "Search in $CI for $1..."
grep -h -- ".*$1.*\t" $CI | sed -e "s|\(.*\)\t\(.*\)|\2: \1|g"
} | $OUTCMD
}
......@@ -49,7 +40,7 @@ epm_search_file()
case $PMTYPE in
apt-rpm)
local_content_search $pkg_filenames
__alt_local_content_search $pkg_filenames
return ;;
apt-dpkg|aptitude-dpkg)
assure_exists apt-file
......
#!/bin/sh
#
# Copyright (C) 2014 Etersoft
# Copyright (C) 2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# TODO: port or rewrite apt-file
# https://bugzilla.altlinux.org/show_bug.cgi?id=14449
get_local_alt_contents_index()
{
load_helper epm-repolist
epm_repolist | grep "rpm file:/" | sed -e "s|^rpm file:||g" | while read URL ARCH other ; do
test -d "$URL/$ARCH" || continue # fatal "Local mirror is not accessible via $URL/$ARCH"
FILE="$URL/$ARCH/base/contents_index"
if [ -r "$FILE" ] ; then
echo "$FILE"
else
info "TODO for girar server: There is no $(basename $FILE) file in $(dirname $FILE)"
fi
done
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment