openmamba-repository: added restore and search functions; don't rely on base arch (i586) to allow managing packages which only have alternative arch(s) builds
This commit is contained in:
parent
c9d84479d2
commit
0ee5676519
@ -1,59 +1,74 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# openmamba inter-repository import script from remote ftp to local
|
||||
# Copyright (c) 2007-2009 by Silvan Calarco
|
||||
# Copyright (c) 2007-2012 by Silvan Calarco
|
||||
#
|
||||
. /etc/sysconfig/openmamba-central
|
||||
|
||||
basearch=i586
|
||||
|
||||
me=${0##*/}
|
||||
|
||||
function usage() {
|
||||
|
||||
echo "openmamba inter-repository import script"
|
||||
echo "Copyright (c) 2007-2008 by Silvan Calarco"
|
||||
echo "Copyright (c) 2007-2012 by Silvan Calarco"
|
||||
echo
|
||||
echo "Usage:"
|
||||
echo "$me list"
|
||||
echo "$me import REPOSITORY [PKGS ...] [-d REPOSITORY] [-s] [-y]"
|
||||
echo "$me release REPOSITORY [PKGS ...] [-d REPOSITORY] [-s] [-y]"
|
||||
echo "$me archive REPOSITORY PKGS ..."
|
||||
echo "$me restore REPOSITORY PKGS ..."
|
||||
echo "$me query REPOSITORY PKGS ..."
|
||||
echo "$me search [-i] [-r regexp] STRING"
|
||||
echo "$me verify REPOSITORY [PKGS ...]"
|
||||
echo "$me inspect REPOSITORY {PKGS ...} [-d REPOSITORY]"
|
||||
echo "$me setwarning REPOSITORY {PKG ...} -t \"TEXT\""
|
||||
echo "$me diff REPOSITORY [PKGS ...] [-d REPOSITORY]"
|
||||
echo "$me import REPOSITORY [PKGS ...] [-d REPOSITORY] [-s]"
|
||||
echo "$me release REPOSITORY [PKGS ...] [-d REPOSITORY] [-s]"
|
||||
echo "$me distromatic REPOSITORY"
|
||||
echo
|
||||
echo " -d use given repository as destination (default: devel)"
|
||||
echo " -r match repositories with given regexp"
|
||||
echo " -s simulate operations to see if it would work"
|
||||
echo " -t warning text"
|
||||
echo " -y assume yes to all questions (be careful!)"
|
||||
}
|
||||
|
||||
# get_pkg_buildinfo - uses distromatic generated build file for
|
||||
# getting information on the repository
|
||||
#
|
||||
# $1: repositoy name
|
||||
# $2: pkg name
|
||||
# $3: architecture
|
||||
# $2: architecture
|
||||
# $3: pkg name
|
||||
function get_pkg_buildinfo() {
|
||||
|
||||
local pkg i
|
||||
|
||||
[ $1 ] && rep=$1 || exit 1
|
||||
[ $2 ] && pkg=$2
|
||||
[ $3 ] && buildarch="$3" || buildarch="i586"
|
||||
|
||||
DISTROMATIC_BUILD_FILE=$local_distromatic/$rep/builds-$buildarch
|
||||
local pkg i a
|
||||
|
||||
[ -e $DISTROMATIC_BUILD_FILE ] || {
|
||||
echo "Error: missing distromatic generated file $DISTROMATIC_BUILD_FILE; aborting."
|
||||
exit 1;
|
||||
}
|
||||
[ $1 ] && rep=$1 || exit 1
|
||||
[ $2 ] && buildarch=$2 || exit 1
|
||||
[ $3 ] && pkg=$3
|
||||
|
||||
pkg_archs=();
|
||||
for a in ${archs[*]}; do
|
||||
pkg_header=();
|
||||
DISTROMATIC_BUILD_FILE=$local_distromatic/$rep/builds-$a.sh
|
||||
[ -e $DISTROMATIC_BUILD_FILE ] && . $DISTROMATIC_BUILD_FILE
|
||||
[ ${pkg_header[0]} ] && pkg_archs=(${pkg_archs[*]} $a)
|
||||
done
|
||||
|
||||
pkg_header=();
|
||||
pkg_builds=();
|
||||
pkg_obsoletes=();
|
||||
|
||||
pkg_list=();
|
||||
|
||||
[ "$buildarch" = "any" ] && buildarch=${pkg_archs[0]}
|
||||
|
||||
DISTROMATIC_BUILD_FILE=$local_distromatic/$rep/builds-${buildarch}.sh
|
||||
if [ ! -e $DISTROMATIC_BUILD_FILE ]; then
|
||||
echo "Error: missing distromatic generated file $DISTROMATIC_BUILD_FILE; aborting."
|
||||
return;
|
||||
fi
|
||||
. $DISTROMATIC_BUILD_FILE
|
||||
|
||||
for i in ${pkg_list[*]}; do
|
||||
@ -62,27 +77,28 @@ function get_pkg_buildinfo() {
|
||||
# Note: pkg_arch reported in builds file is just last arch source was
|
||||
# built for, so we use repository arch instead
|
||||
pkg_arch=${pkg_header[1]};
|
||||
[ "$pkg_arch" = "noarch" ] || pkg_arch=$buildarch
|
||||
[ "$pkg_arch" = "noarch" ] || pkg_arch=$buildarch
|
||||
pkg_version=${pkg_header[2]};
|
||||
pkg_release=${pkg_header[3]};
|
||||
pkg_group=${pkg_header[4]};
|
||||
pkg_license=${pkg_header[5]};
|
||||
pkg_size=${pkg_header[6]};
|
||||
pkg_buildtime=${pkg_header[7]};
|
||||
pkg_altrep=${pkg_header[8]};
|
||||
return 0
|
||||
pkg_altrep=${pkg_header[8]};
|
||||
pkg_repository=${pkg_header[9]};
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
unset pkg_name pkg_arch pkg_version pkg_release \
|
||||
pkg_group pkg_license pkg_size pkg_buildtime pkg_altrep
|
||||
|
||||
pkg_group pkg_license pkg_size pkg_buildtime pkg_altrep pkg_repository
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function import_file() {
|
||||
[ $1 ] || exit 1
|
||||
|
||||
|
||||
local f import_mode
|
||||
f=$1
|
||||
import_mode=$2
|
||||
@ -107,28 +123,27 @@ function import_file() {
|
||||
echo "Error: cannot move file $ORIG_URL_LOCAL_ARCH/$f to $DEST_URL_ARCH/$f; aborting."
|
||||
exit 1
|
||||
}
|
||||
chown ftp$DEST_REPOSITORY:users $DEST_URL_ARCH/$f
|
||||
eval curl -s -u$ftpuser:$ftppass $ORIG_URL_ARCH $curl_delete_add >/dev/null && {
|
||||
rm -f $ORIG_URL_LOCAL_ARCH/$f
|
||||
} || {
|
||||
echo
|
||||
echo "Warning: cannot delete remote file $ORIG_URL_ARCH/$f; you'll have to delete it."
|
||||
echo curl -s -u$ftpuser:$ftppass $ORIG_URL_ARCH $curl_delete_add
|
||||
}
|
||||
else
|
||||
echo -n "(R) "
|
||||
curl -s -u$ftpuser:$ftppass \
|
||||
--get $ORIG_URL_ARCH/$f \
|
||||
-o $DEST_URL_ARCH/$f $curl_delete_add || {
|
||||
echo
|
||||
echo "Error: cannot get file $ORIG_URL_ARCH/$f; aborting."
|
||||
echo curl -s -u$ftpuser:$ftppass \
|
||||
--get $ORIG_URL_ARCH/$f \
|
||||
-o $DEST_URL_ARCH/$f $curl_delete_add
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
else
|
||||
# remote -> remote
|
||||
echo "Error: remote to remote file import is not implemented yet; aborting."
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if [ "$DEST_MODE" = "local" ]; then
|
||||
@ -137,6 +152,7 @@ function import_file() {
|
||||
echo "Error: cannot copy file $ORIG_URL_ARCH/$f to $DEST_URL_ARCH/$f; aborting."
|
||||
exit 1
|
||||
}
|
||||
chown ftp$DEST_REPOSITORY:users $DEST_URL_ARCH/$f
|
||||
if [ "$import_mode" = "backup" ]; then
|
||||
rm -f $ORIG_URL_ARCH/$f || {
|
||||
echo "Error: cannot remove file $ORIG_URL_ARCH/$f; aborting."
|
||||
@ -145,8 +161,19 @@ function import_file() {
|
||||
fi
|
||||
else
|
||||
# local -> remote
|
||||
echo "Error: local to remote file import is not implemented yet; aborting."
|
||||
exit 1
|
||||
echo -n "(R) "
|
||||
curl -s -u$ftpuser:$ftppass \
|
||||
-T $ORIG_URL_ARCH/$f \
|
||||
$DEST_URL_ARCH/ || {
|
||||
echo
|
||||
echo "Error: cannot send file $ORIG_URL_ARCH/$f; aborting."
|
||||
exit 1
|
||||
}
|
||||
rm -f $ORIG_URL_ARCH/$f || {
|
||||
echo
|
||||
echo "Warning: cannot delete local file $ORIG_URL_ARCH/$f; you'll have to delete it."
|
||||
}
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -154,7 +181,7 @@ function import_file() {
|
||||
|
||||
function backup_local_file() {
|
||||
[ $1 ] || return
|
||||
|
||||
|
||||
[ -e $LOCAL_BACKUP ] || mkdir -p $LOCAL_BACKUP
|
||||
movefiles=$1
|
||||
|
||||
@ -173,97 +200,215 @@ function backup_local_file() {
|
||||
|
||||
function backup_package() {
|
||||
local rep reg i
|
||||
|
||||
|
||||
[ "$1" ] || return
|
||||
[ "$2" ] && rep=$2 || rep=$destrepository
|
||||
[ "$3" ] && reg=$3 || reg=$DESTREGFILE
|
||||
|
||||
archive_pkg=$1
|
||||
|
||||
get_pkg_buildinfo $rep $archive_pkg
|
||||
get_pkg_buildinfo $rep any $archive_pkg
|
||||
|
||||
if [ "$pkg_name" ]; then
|
||||
PKG_FILENAME="$pkg_name-$pkg_version-$pkg_release.src.rpm"
|
||||
LOCAL_BACKUP=$DEST_URL_LOCAL/old/${pkg_name}_${BACKUP_DATE}
|
||||
|
||||
[ -f $DEST_URL_LOCAL/SRPMS.base/$PKG_FILENAME ] || {
|
||||
echo "Error: package $PKG_FILENAME does not exist in local repository; aborting."
|
||||
exit 1
|
||||
}
|
||||
if [ "$pkg_name" ]; then
|
||||
PKG_FILENAME="$pkg_name-$pkg_version-$pkg_release.src.rpm"
|
||||
|
||||
backup_local_file $DEST_URL_LOCAL/SRPMS.base/$PKG_FILENAME
|
||||
if [ "$simulate" != "1" -a "$DEST_MODE" = "remote" ]; then
|
||||
curl -s -u$ftpuser:$ftppass $DEST_URL/SRPMS.base/ -Q "-DELE $PKG_FILENAME" >/dev/null || {
|
||||
echo "Warning: cannot delete remote file $DEST_URL/SRPMS.base/$PKG_FILENAME; you'll have to delete it."
|
||||
}
|
||||
fi
|
||||
|
||||
for i in ${pkg_builds[*]}; do
|
||||
if [ -f $DEST_URL_LOCAL/SRPMS.base/$PKG_FILENAME ]; then
|
||||
backup_local_file $DEST_URL_LOCAL/SRPMS.base/$PKG_FILENAME
|
||||
else
|
||||
echo "Warning: package $PKG_FILENAME does not exist in local repository"
|
||||
fi
|
||||
|
||||
if [ "$simulate" != "1" -a "$DEST_MODE" = "remote" ]; then
|
||||
curl -s -u$ftpuser:$ftppass $DEST_URL/SRPMS.base/ -Q "-DELE $PKG_FILENAME" >/dev/null || {
|
||||
echo "Warning: cannot delete remote file $DEST_URL/SRPMS.base/$PKG_FILENAME; you'll have to delete it."
|
||||
}
|
||||
fi
|
||||
|
||||
for a in ${pkg_archs[*]}; do
|
||||
get_pkg_buildinfo $rep $a $archive_pkg
|
||||
|
||||
for i in ${pkg_builds[*]}; do
|
||||
PKG_FILENAME="$i-$pkg_version-$pkg_release.$pkg_arch.rpm"
|
||||
[ -f $DEST_URL_LOCAL/RPMS.i586/$PKG_FILENAME ] || {
|
||||
echo "Error: package $PKG_FILENAME does not exist in local repository; aborting."
|
||||
exit 1
|
||||
}
|
||||
if [ -f $DEST_URL_LOCAL/RPMS.$a/$PKG_FILENAME ]; then
|
||||
backup_local_file $DEST_URL_LOCAL/RPMS.$a/$PKG_FILENAME
|
||||
else
|
||||
echo "Warning: package $PKG_FILENAME does not exist in local repository"
|
||||
fi
|
||||
|
||||
backup_local_file $DEST_URL_LOCAL/RPMS.i586/$PKG_FILENAME
|
||||
if [ "$simulate" != "1" -a "$DEST_MODE" = "remote" ]; then
|
||||
curl -s -u$ftpuser:$ftppass $DEST_URL/RPMS.i586/ -Q "-DELE $PKG_FILENAME" >/dev/null || {
|
||||
echo "Warning: cannot delete remote file $DEST_URL/RPMS.i586/$PKG_FILENAME; you'll have to delete it."
|
||||
curl -s -u$ftpuser:$ftppass $DEST_URL/RPMS.$a/ -Q "-DELE $PKG_FILENAME" >/dev/null || {
|
||||
echo "Warning: cannot delete remote file $DEST_URL/RPMS.$pkg_arch/$PKG_FILENAME; you'll have to delete it."
|
||||
}
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
# write register
|
||||
[ "$simulate" != "1" ] && {
|
||||
echo "`date +%Y%m%d%H%M` Package <a href=\"/distribution/distromatic.html?tag=$rep&pkg=$pkg_name.source\">$pkg_name</a> ($pkg_version-$pkg_release) archived" >> $reg
|
||||
# write register
|
||||
[ "$simulate" != "1" ] && {
|
||||
echo "`date +%Y%m%d%H%M` Package <a href=\"/distribution/distromatic.html?tag=$rep&pkg=$pkg_name.source\">$pkg_name</a> ($pkg_version-$pkg_release) archived" >> $reg
|
||||
# | \
|
||||
# tee -a $ORIGREGFILE $DESTREGFILE >/dev/null
|
||||
# echo "`date +%Y%m%d%H%M` \"\" \"package $pkg_name ($pkg_version-$pkg_release) archived from $rep\"" >> $reg
|
||||
}
|
||||
else
|
||||
echo "Warning: package $archive_pkg does not exists in $rep; skipping."
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_local_file() {
|
||||
[ $1 ] || return
|
||||
[ $2 ] || return
|
||||
|
||||
restorefiles=$1
|
||||
backupprefix=$2
|
||||
ARCH=$3
|
||||
|
||||
|
||||
#`find $DEST_URL_ARCH -maxdepth 1 -regex ".*/${pkgname}-[^-]*-[^-]*"`
|
||||
for r in $restorefiles; do
|
||||
[ "$ARCH" ] && restoredest=$DEST_URL_LOCAL/RPMS.$ARCH/ || restoredest=$DEST_URL_LOCAL/SRPMS.base/
|
||||
echo "restoring $r"
|
||||
if [ "$simulate" != "1" ]; then
|
||||
cp ${backupprefix}/$r $restoredest || {
|
||||
echo "Error: can't copy $p to $restoredest; aborting."
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
echo "Warning: package $archive_pkg does not exists in $rep; skipping."
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
function restore_package() {
|
||||
local rep reg i
|
||||
|
||||
[ "$1" ] || return
|
||||
[ "$2" ] && rep=$2 || rep=$destrepository
|
||||
[ "$3" ] && reg=$3 || reg=$DESTREGFILE
|
||||
|
||||
restore_pkg=$1
|
||||
|
||||
get_pkg_buildinfo $rep any $restore_pkg
|
||||
|
||||
if [ ! "$pkg_name" ]; then
|
||||
echo "Info: package $restore_pkg does not exists in $rep"
|
||||
fi
|
||||
|
||||
LOCAL_RESTORE_PREFIX=$DEST_URL_LOCAL/old/${restore_pkg}_
|
||||
|
||||
local cnt=0
|
||||
local RESTORE_NAMES=()
|
||||
ls ${LOCAL_RESTORE_PREFIX}* &>/dev/null && \
|
||||
for f in ${LOCAL_RESTORE_PREFIX}*; do
|
||||
[ "$cnt" = 0 ] && echo "Available backups: "
|
||||
cnt=`expr $cnt + 1`
|
||||
RESTORE_NAMES=(${RESTORE_NAMES[*]} `echo ${f/*_/}`)
|
||||
echo "($cnt) ${RESTORE_NAMES[$cnt-1]}"
|
||||
done
|
||||
[ "$cnt" == "0" ] && {
|
||||
echo "Sorry, no backups availables for ${restore_pkg} in $rep"
|
||||
return
|
||||
}
|
||||
local ans=0
|
||||
while [ $ans -le 0 2>/dev/null -o $ans -gt $cnt 2>/dev/null ]; do
|
||||
echo
|
||||
echo -n "Please select the entry to restore or press ENTER to skip (1-$cnt): "
|
||||
read ans
|
||||
[ "$ans" ] || return
|
||||
[ $ans -eq $ans 2>/dev/null ] || ans=0
|
||||
done
|
||||
|
||||
echo "Restoring: "
|
||||
for f in `ls ${LOCAL_RESTORE_PREFIX}${RESTORE_NAMES[$ans-1]}`; do
|
||||
echo -n "${f/*\/} "
|
||||
done
|
||||
echo
|
||||
echo -n "Ok to restore [y/N]? "
|
||||
read ans1
|
||||
[ "$ans1" != "y" -a "$ans1" != "Y" ] && return
|
||||
|
||||
for a in ${archs[*]}; do
|
||||
for f in `ls ${LOCAL_RESTORE_PREFIX}${RESTORE_NAMES[$ans-1]}/*.${a}.rpm 2>/dev/null`; do
|
||||
restore_local_file ${f/*\/} ${LOCAL_RESTORE_PREFIX}${RESTORE_NAMES[$ans-1]}/ $a
|
||||
done
|
||||
done
|
||||
|
||||
for f in `ls ${LOCAL_RESTORE_PREFIX}${RESTORE_NAMES[$ans-1]}/*.src.rpm 2>/dev/null`; do
|
||||
restore_local_file ${f/*\/} ${LOCAL_RESTORE_PREFIX}${RESTORE_NAMES[$ans-1]}/
|
||||
done
|
||||
|
||||
# write register
|
||||
[ "$simulate" != "1" ] && {
|
||||
echo "`date +%Y%m%d%H%M` Package <a href=\"/distribution/distromatic.html?tag=$rep&pkg=$restore_pkg.source\">$restore_pkg</a> restored" >> $reg
|
||||
}
|
||||
}
|
||||
|
||||
function import_package() {
|
||||
[ $1 ] || exit 1
|
||||
|
||||
local import_pkg import_mode
|
||||
|
||||
|
||||
import_pkg=$1
|
||||
import_mode=$2
|
||||
|
||||
|
||||
get_pkg_buildinfo $destrepository any $import_pkg
|
||||
|
||||
# check for all architectures
|
||||
for a in ${pkg_archs[*]}; do
|
||||
# check release in dest repository
|
||||
get_pkg_buildinfo $destrepository $a $import_pkg
|
||||
[ "$pkg_name" ] && {
|
||||
# IMPORT_ORIG_ARCHS=(${IMPORT_ORIG_ARCHS[*]} $a)
|
||||
get_pkg_buildinfo $origrepository $a $import_pkg
|
||||
[ "$pkg_name" ] || {
|
||||
[ "$a" == "$basearch" ] && {
|
||||
echo "Error: package $import_pkg does not exist in $origrepository($a); skipping."
|
||||
return
|
||||
}
|
||||
if [ "$force" = "1" ]; then
|
||||
echo "Warning: package $import_pkg is missing in $origrepository($a) but present in $destrepository($a)."
|
||||
echo "Import forced. You will need to port package to the missing arch."
|
||||
else
|
||||
echo "Error: package $import_pkg is missing in $origrepository($a). This would break package in $destrepository($a) repository. Skipping."
|
||||
return
|
||||
fi
|
||||
}
|
||||
}
|
||||
done
|
||||
|
||||
# check release in dest repository
|
||||
get_pkg_buildinfo $destrepository $import_pkg
|
||||
get_pkg_buildinfo $destrepository any $import_pkg
|
||||
|
||||
[ "$pkg_version" ] && {
|
||||
destpkgname="$pkg_name"
|
||||
destpkgversion="$pkg_version-$pkg_release"
|
||||
destpkgarch="$pkg_arch"
|
||||
# destpkgarch="$pkg_arch"
|
||||
} || destpkgversion="none"
|
||||
|
||||
get_pkg_buildinfo $origrepository $import_pkg
|
||||
|
||||
|
||||
get_pkg_buildinfo $origrepository any $import_pkg
|
||||
|
||||
[ "$pkg_version" ] && {
|
||||
origpkgname="$pkg_name"
|
||||
origpkgversion="$pkg_version-$pkg_release"
|
||||
origpkgarch="$pkg_arch"
|
||||
# origpkgarch="$pkg_arch"
|
||||
} || origpkgversion="none"
|
||||
|
||||
|
||||
[ $origpkgname ] || {
|
||||
echo "Error: package $import_pkg does not exist; aborting."
|
||||
echo "Error: package $import_pkg does not exist in $origrepository; aborting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
DEST_URL_ARCH=$DEST_URL/SRPMS.base/
|
||||
ORIG_URL_ARCH=$ORIG_URL/SRPMS.base/
|
||||
ORIG_URL_LOCAL_ARCH=$ORIG_URL_LOCAL/SRPMS.base/
|
||||
|
||||
|
||||
PKG_FILENAME="$origpkgname-$origpkgversion.src.rpm"
|
||||
|
||||
[ "$ORIG_MODE" = "remote" ] &&
|
||||
ORIG_FILELIST=`curl -s -l -u$ftpuser:$ftppass --url $ORIG_URL_ARCH/` ||
|
||||
ORIG_FILELIST=`ls $ORIG_URL_ARCH`
|
||||
|
||||
|
||||
check_existence=0;
|
||||
|
||||
for i in $ORIG_FILELIST; do
|
||||
@ -276,22 +421,29 @@ function import_package() {
|
||||
echo "Warning: same version of $origpkgname exists in destination"
|
||||
}
|
||||
|
||||
echo -n "Import $PKG_FILENAME ($origpkgversion -> $destpkgversion) [y/N]?"
|
||||
read ans
|
||||
if [ "$assume_yes" != "1" ]; then
|
||||
echo -n "Import $PKG_FILENAME ($origpkgversion -> $destpkgversion) [y/N]?"
|
||||
read ans
|
||||
fi
|
||||
|
||||
[ "$ans" = "y" -o "$ans" = "Y" ] && {
|
||||
[ "$assume_yes" = "1" -o "$ans" = "y" -o "$ans" = "Y" ] && {
|
||||
|
||||
echo -n "Importing $PKG_FILENAME "
|
||||
import_file $PKG_FILENAME $import_mode
|
||||
|
||||
for i in ${pkg_builds[*]}; do
|
||||
PKG_FILENAME="$i-$origpkgversion.$origpkgarch.rpm"
|
||||
DEST_URL_ARCH=$DEST_URL/RPMS.i586/
|
||||
ORIG_URL_ARCH=$ORIG_URL/RPMS.i586/
|
||||
ORIG_URL_LOCAL_ARCH=$ORIG_URL_LOCAL/RPMS.i586/
|
||||
|
||||
echo -n "$PKG_FILENAME "
|
||||
import_file $PKG_FILENAME $import_mode
|
||||
get_pkg_buildinfo $origrepository any $import_pkg
|
||||
|
||||
for a in ${pkg_archs[*]}; do
|
||||
get_pkg_buildinfo $origrepository $a $import_pkg
|
||||
for i in ${pkg_builds[*]}; do
|
||||
PKG_FILENAME="$i-$origpkgversion.$pkg_arch.rpm"
|
||||
DEST_URL_ARCH=$DEST_URL/RPMS.$a/
|
||||
ORIG_URL_ARCH=$ORIG_URL/RPMS.$a/
|
||||
ORIG_URL_LOCAL_ARCH=$ORIG_URL_LOCAL/RPMS.$a/
|
||||
|
||||
echo -n "$PKG_FILENAME "
|
||||
import_file $PKG_FILENAME $import_mode
|
||||
done
|
||||
done
|
||||
echo
|
||||
|
||||
@ -301,41 +453,42 @@ function import_package() {
|
||||
tee -a $ORIGREGFILE $DESTREGFILE >/dev/null
|
||||
}
|
||||
|
||||
if [ "$import_mode" = "backup" ]; then
|
||||
# backup stuff
|
||||
# if [ "$import_mode" = "backup" ]; then
|
||||
# backup old stuff in destination repository
|
||||
[ "$destpkgversion" != "none" -a \
|
||||
"$destpkgversion" != "$origpkgversion" ] && {
|
||||
backup_package $import_pkg $destrepository $DESTREGFILE
|
||||
}
|
||||
}
|
||||
# remove distromatic extra files associated with this package
|
||||
[ -e $local_distromatic/$rep/warnings/$import_pkg.in ] && {
|
||||
rm -f $local_distromatic/$rep/warnings/$import_pkg.in ||
|
||||
echo "Warning: cannot remove file $local_distromatic/$rep/warnings/$import_pkg.in"
|
||||
}
|
||||
fi
|
||||
# fi
|
||||
|
||||
#for i in ${pkg_obsoletes}; do
|
||||
# PKG_FILENAME="$i-$pkg_version-$pkg_release.$namearch.rpm"
|
||||
# DEST_URL_ARCH=$DEST_URL/RPMS.i586/$PKG_FILENAME
|
||||
# DEST_URL_ARCH=$DEST_URL/RPMS.$namearch/$PKG_FILENAME
|
||||
# [ -e $DEST_URL_ARCH ] && echo "Warning: obsoleted package $i exists"
|
||||
# backup_package $i $destrepository $DESTREGFILE
|
||||
# #echo rm $DEST_URL_ARCH
|
||||
#done
|
||||
|
||||
} # ans = y
|
||||
|
||||
|
||||
else # check_existence != 1
|
||||
echo "Warning: $import_pkg reported by distromatic does no longer exist"
|
||||
fi
|
||||
}
|
||||
|
||||
# FIXME: only works with basearch
|
||||
function extract_diffinfo() {
|
||||
PKG=$1
|
||||
REP=$2
|
||||
TMP=$3
|
||||
local i
|
||||
|
||||
get_pkg_buildinfo $REP $PKG
|
||||
|
||||
get_pkg_buildinfo $REP $basearch $PKG
|
||||
if [ "$pkg_name" ]; then
|
||||
PKG_FILENAME="$local_ftp/$REP/SRPMS.base/$pkg_name-$pkg_version-$pkg_release.src.rpm"
|
||||
[ -e "$PKG_FILENAME" ] || {
|
||||
@ -356,7 +509,7 @@ function extract_diffinfo() {
|
||||
> $TMP/requires
|
||||
> $TMP/provides
|
||||
for i in ${pkg_builds[*]}; do
|
||||
PKG_FILENAME="$local_ftp/$REP/RPMS.i586/$i-$pkg_version-$pkg_release.$pkg_arch.rpm"
|
||||
PKG_FILENAME="$local_ftp/$REP/RPMS.$basearch/$i-$pkg_version-$pkg_release.$pkg_arch.rpm"
|
||||
[ -e "$PKG_FILENAME" ] || {
|
||||
echo "Error: package $PKG_FILENAME missing in $origrepository; skipping"
|
||||
return 1
|
||||
@ -384,20 +537,35 @@ while [ "$1" ]; do
|
||||
case $1 in
|
||||
-d)
|
||||
destrepository=$2; shift ;;
|
||||
-r)
|
||||
searchrep=$2; shift ;;
|
||||
-s)
|
||||
simulate=1 ;;
|
||||
-t)
|
||||
shift
|
||||
warningtext="$@"
|
||||
break ;;
|
||||
-f)
|
||||
force=1 ;;
|
||||
-i)
|
||||
ignorecase=1 ;;
|
||||
-y)
|
||||
assume_yes=1 ;;
|
||||
*)
|
||||
if [ "$command" ]; then
|
||||
case "$command" in
|
||||
"import"|"release"|"query"|"verify"|"archive"|"diff"|"inspect"|"setwarning"|"distromatic")
|
||||
[ "$origrepository" ] &&
|
||||
"import"|"release"|"query"|"verify"|"archive"|"restore"|"diff"|"inspect"|"setwarning"|"distromatic")
|
||||
[ "$origrepository" ] &&
|
||||
packages="$packages $1" ||
|
||||
origrepository=$1
|
||||
;;
|
||||
"search")
|
||||
[ "$searchstring" ] && {
|
||||
echo "Error: invalid option $1; aborting."
|
||||
exit 1
|
||||
}
|
||||
searchstring="$1"
|
||||
;;
|
||||
*) usage
|
||||
echo "Error: invalid option $1; aborting."
|
||||
exit 1
|
||||
@ -405,8 +573,8 @@ while [ "$1" ]; do
|
||||
esac
|
||||
else
|
||||
case "$1" in
|
||||
"import"|"release"|"query"|"verify"|"archive"|"list"|"diff"|"inspect"|"setwarning"|"distromatic") command=$1 ;;
|
||||
*)
|
||||
"import"|"release"|"query"|"verify"|"archive"|"restore"|"list"|"diff"|"inspect"|"setwarning"|"distromatic"|"search") command=$1 ;;
|
||||
*)
|
||||
usage
|
||||
echo "Errror: $1 is not a valid command; aborting."
|
||||
exit 1
|
||||
@ -417,7 +585,6 @@ while [ "$1" ]; do
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[ "$command" = "" ] && { usage; exit 1; }
|
||||
|
||||
[ "$command" = "list" ] && echo "Local repositories:"
|
||||
@ -434,6 +601,30 @@ for a in ${remote_reps[*]}; do
|
||||
done
|
||||
[ "$command" = "list" ] && exit 0;
|
||||
|
||||
[ "$command" = "search" ] && {
|
||||
[ "$ignorecase" ] && GREP_OPTS="-i"
|
||||
for rep in ${local_reps[*]} ${remote_reps[*]}; do
|
||||
[[ "$rep" =~ "$searchrep" ]] || continue
|
||||
[ -r $local_ftp/$rep/SRPMS.base ] || continue
|
||||
ls $local_ftp/$rep/SRPMS.base | grep $GREP_OPTS "$searchstring" 2>/dev/null | \
|
||||
while read PKGLINE; do
|
||||
[ "$PKGLINE" ] && {
|
||||
echo "$rep(source): ${PKGLINE/ *}"
|
||||
}
|
||||
done
|
||||
for a in ${archs[*]}; do
|
||||
[ -r $local_ftp/$rep/RPMS.$a ] || continue
|
||||
ls $local_ftp/$rep/RPMS.$a | grep $GREP_OPTS "$searchstring" 2>/dev/null | \
|
||||
while read PKGLINE; do
|
||||
[ "$PKGLINE" ] && {
|
||||
echo "$rep($a): ${PKGLINE/ *}"
|
||||
}
|
||||
done
|
||||
done
|
||||
done
|
||||
exit 0
|
||||
}
|
||||
|
||||
[ "$origrepository" ] || { usage; exit 1; }
|
||||
|
||||
[ "$DEST_MODE" ] || { echo "Error: $destrepository is not a valid repository; aborting."; exit 1; }
|
||||
@ -443,61 +634,68 @@ done
|
||||
[ "$command" = "query" ] && {
|
||||
[ "$packages" ] || { usage; exit 1; }
|
||||
for i in $packages; do
|
||||
get_pkg_buildinfo $origrepository $i
|
||||
get_pkg_buildinfo $origrepository any $i
|
||||
if [ ! "$pkg_name" ]; then
|
||||
echo "$i: package not found in $origrepository repository"
|
||||
else
|
||||
echo "Name: $pkg_name"
|
||||
echo "BuildArch: $pkg_arch"
|
||||
echo "Version: $pkg_version"
|
||||
echo "Release: $pkg_release"
|
||||
echo "Group: $pkg_group"
|
||||
echo "License: $pkg_license"
|
||||
echo "Size: $pkg_size"
|
||||
echo "Builds: ${pkg_builds[*]}"
|
||||
echo "Obsoletes: ${pkg_obsoletes[*]}"
|
||||
echo
|
||||
else
|
||||
for a in ${pkg_archs[*]}; do
|
||||
get_pkg_buildinfo $origrepository $a $i
|
||||
if [ "$pkg_name" ]; then
|
||||
echo "Repository:$origrepository($a)"
|
||||
echo "Name: $pkg_name"
|
||||
echo "BuildArch: $pkg_arch"
|
||||
echo "Version: $pkg_version"
|
||||
echo "Release: $pkg_release"
|
||||
echo "Group: $pkg_group"
|
||||
echo "License: $pkg_license"
|
||||
echo "Size: $pkg_size"
|
||||
echo "Builds: ${pkg_builds[*]}"
|
||||
echo "Obsoletes: ${pkg_obsoletes[*]}"
|
||||
echo
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
[ "$command" = "verify" ] && {
|
||||
[ "$packages" ] || {
|
||||
get_pkg_buildinfo $origrepository
|
||||
get_pkg_buildinfo $origrepository any
|
||||
packages=${pkg_list[*]}
|
||||
}
|
||||
for i in $packages; do
|
||||
get_pkg_buildinfo $origrepository $i
|
||||
get_pkg_buildinfo $origrepository any $i
|
||||
if [ ! "$pkg_name" ]; then
|
||||
echo "$i: package not found in $origrepository repository"
|
||||
else
|
||||
PKG_FILENAME="$i-$pkg_version-$pkg_release.src.rpm"
|
||||
rpm2cpio $local_ftp/${origrepository}/SRPMS.base/$PKG_FILENAME &>/dev/null || {
|
||||
echo "Warning: source package $PKG_FILENAME is empty or corrupted."
|
||||
echo "Warning: source package $PKG_FILENAME is empty or corrupted."
|
||||
}
|
||||
|
||||
for l in ${pkg_builds[*]}; do
|
||||
PKG_FILENAME="$l-$pkg_version-$pkg_release.$pkg_arch.rpm"
|
||||
rpm2cpio $local_ftp${origrepository}/RPMS.i586/$PKG_FILENAME &>/dev/null || {
|
||||
echo "Warning: package $PKG_FILENAME is empty or corrupted."
|
||||
}
|
||||
|
||||
for a in ${archs[*]}; do
|
||||
get_pkg_buildinfo $origrepository $a $i
|
||||
if [ "$pkg_name" ]; then
|
||||
for l in ${pkg_builds[*]}; do
|
||||
PKG_FILENAME="$l-$pkg_version-$pkg_release.$pkg_arch.rpm"
|
||||
rpm2cpio $local_ftp${origrepository}/RPMS.$a/$PKG_FILENAME &>/dev/null || {
|
||||
echo "Warning: package $PKG_FILENAME($a) is empty or corrupted."
|
||||
}
|
||||
done
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
[ "$command" = "diff" ] && {
|
||||
[ "$packages" ] || {
|
||||
get_pkg_buildinfo $origrepository
|
||||
get_pkg_buildinfo $origrepository any
|
||||
packages=${pkg_list[*]}
|
||||
}
|
||||
TMP_SPEC_DIR=`mktemp -d`
|
||||
TMP_SPEC_DIR=`mktemp -d --tmpdir=/dev/shm`
|
||||
for i in $packages; do
|
||||
echo
|
||||
echo "*******************************************************************"
|
||||
@ -643,15 +841,14 @@ done
|
||||
|
||||
[ "$simulate" = "1" ] && echo "Simulation mode enabled."
|
||||
#
|
||||
# import and other active commands
|
||||
# import and other active commands
|
||||
#
|
||||
DEST_URL=$local_ftp/$destrepository
|
||||
if [ "$DEST_MODE" = "remote" ]; then
|
||||
DEST_URL=$dest_ftp/pub/openmamba/$destrepository
|
||||
else
|
||||
DEST_URL=$local_ftp/$destrepository
|
||||
fi
|
||||
DEST_URL_LOCAL=$local_ftp/$destrepository
|
||||
LOCAL_BACKUP=$DEST_URL/old
|
||||
|
||||
# operation files are always in the local copy of the repository
|
||||
ORIGREGFILE=$local_ftp/$origrepository/operations.log.html
|
||||
DESTREGFILE=$local_ftp/$destrepository/operations.log.html
|
||||
|
||||
# ORIG_URL_LOCAL is set if a local copy of the repository exists
|
||||
# and will be preferred for file transfer optimizations
|
||||
@ -662,11 +859,18 @@ else
|
||||
fi
|
||||
ORIG_URL_LOCAL=$local_ftp/$origrepository
|
||||
|
||||
BACKUP_DATE=`date +%y%m%d.%H%M%S`
|
||||
LOCAL_BACKUP=$DEST_URL/old
|
||||
|
||||
# operation files are always in the local copy of the repository
|
||||
ORIGREGFILE=$local_ftp/$origrepository/operations.log.html
|
||||
DESTREGFILE=$local_ftp/$destrepository/operations.log.html
|
||||
|
||||
|
||||
[ "$command" = "archive" ] && {
|
||||
DEST_URL=$ORIG_URL
|
||||
DEST_URL_LOCAL=$ORIG_URL_LOCAL
|
||||
DEST_MODE=$ORIG_MODE
|
||||
LOCAL_BACKUP=$DEST_URL_LOCAL/old/archived
|
||||
|
||||
[ "$packages" ] || { usage; exit 1; }
|
||||
|
||||
@ -677,10 +881,28 @@ ORIG_URL_LOCAL=$local_ftp/$origrepository
|
||||
exit 0
|
||||
}
|
||||
|
||||
[ "$command" = "import" -o "$command" = "release" ] && {
|
||||
LOCAL_BACKUP=$DEST_URL/old/import-$origrepository
|
||||
[ "$command" = "restore" ] && {
|
||||
DEST_URL=$ORIG_URL
|
||||
DEST_URL_LOCAL=$ORIG_URL_LOCAL
|
||||
DEST_MODE=$ORIG_MODE
|
||||
|
||||
[ "$origrepository" = "$destrepository" ] && {
|
||||
[ "$ORIG_MODE" = "remote" ] && {
|
||||
echo "Error: restore is only implemented in local repository; exiting."
|
||||
exit 1
|
||||
}
|
||||
[ "$packages" ] || { usage; exit 1; }
|
||||
|
||||
for i in $packages; do
|
||||
restore_package $i $origrepository $ORIGREGFILE
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
}
|
||||
|
||||
[ "$command" = "import" -o "$command" = "release" ] && {
|
||||
|
||||
[ "$origrepository" = "$destrepository" ] && {
|
||||
echo "Error: source and destination repository cannot be the same; aborting."; exit 1; }
|
||||
|
||||
if [ "$command" = "import" ]; then
|
||||
@ -692,8 +914,8 @@ ORIG_URL_LOCAL=$local_ftp/$origrepository
|
||||
fi
|
||||
|
||||
if [ ! "$packages" ]; then
|
||||
get_pkg_buildinfo $origrepository
|
||||
|
||||
get_pkg_buildinfo $origrepository any
|
||||
|
||||
for i in ${pkg_list[*]}; do
|
||||
import_package $i $backup_mode
|
||||
done
|
||||
@ -702,9 +924,8 @@ ORIG_URL_LOCAL=$local_ftp/$origrepository
|
||||
import_package $i $backup_mode
|
||||
done
|
||||
fi
|
||||
|
||||
openmamba-repository-fix-permissions
|
||||
exit 0
|
||||
|
||||
}
|
||||
|
||||
usage
|
||||
|
Loading…
Reference in New Issue
Block a user