autodist-repository: set return code as the number of import or release errors
This commit is contained in:
parent
ae9e5c3be5
commit
ed2de4963a
@ -41,7 +41,7 @@ function get_packages_from_last_build() {
|
|||||||
[ "$rep" ] || return
|
[ "$rep" ] || return
|
||||||
[ -r $SRCPKGLIST ] || {
|
[ -r $SRCPKGLIST ] || {
|
||||||
echo "ERROR: srcpkglist file missing for $origrepository repository; aborting." >&2
|
echo "ERROR: srcpkglist file missing for $origrepository repository; aborting." >&2
|
||||||
exit 1
|
exit 200
|
||||||
}
|
}
|
||||||
tmpfile=`mktemp`
|
tmpfile=`mktemp`
|
||||||
packages=()
|
packages=()
|
||||||
@ -61,8 +61,8 @@ get_pkg_srcinfo() {
|
|||||||
|
|
||||||
local rep pkg line
|
local rep pkg line
|
||||||
|
|
||||||
[ $1 ] && rep=$1 || exit 1
|
[ $1 ] && rep=$1 || exit 200
|
||||||
[ $2 ] && pkg=$2 || exit 1
|
[ $2 ] && pkg=$2 || exit 200
|
||||||
|
|
||||||
unset pkg_archs pkg_name pkg_version pkg_release
|
unset pkg_archs pkg_name pkg_version pkg_release
|
||||||
|
|
||||||
@ -93,8 +93,8 @@ function get_pkg_buildinfo() {
|
|||||||
|
|
||||||
local pkg i a
|
local pkg i a
|
||||||
|
|
||||||
[ $1 ] && rep=$1 || exit 1
|
[ $1 ] && rep=$1 || exit 200
|
||||||
[ $2 ] && buildarch=$2 || exit 1
|
[ $2 ] && buildarch=$2 || exit 200
|
||||||
[ $3 ] && pkg=$3
|
[ $3 ] && pkg=$3
|
||||||
|
|
||||||
pkg_archs=();
|
pkg_archs=();
|
||||||
@ -153,7 +153,7 @@ function get_pkg_buildinfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function import_file() {
|
function import_file() {
|
||||||
[ $1 ] || exit 1
|
[ $1 ] || exit 200
|
||||||
|
|
||||||
local f import_mode
|
local f import_mode
|
||||||
f=$1
|
f=$1
|
||||||
@ -178,7 +178,7 @@ function import_file() {
|
|||||||
# if file exists in a local mirror use it by preference
|
# if file exists in a local mirror use it by preference
|
||||||
cp $ORIG_URL_LOCAL_ARCH/$f $DEST_URL_ARCH/ || {
|
cp $ORIG_URL_LOCAL_ARCH/$f $DEST_URL_ARCH/ || {
|
||||||
echo "ERROR: cannot move file $ORIG_URL_LOCAL_ARCH/$f to $DEST_URL_ARCH/$f; aborting." >&2
|
echo "ERROR: cannot move file $ORIG_URL_LOCAL_ARCH/$f to $DEST_URL_ARCH/$f; aborting." >&2
|
||||||
exit 1
|
exit 200
|
||||||
}
|
}
|
||||||
#chown ftp$DEST_REPOSITORY:users $DEST_URL_ARCH/$f
|
#chown ftp$DEST_REPOSITORY:users $DEST_URL_ARCH/$f
|
||||||
eval curl -s -u${AUTODIST_REPOSITORIES_REMOTE_FTPUSER}:${AUTODIST_REPOSITORIES_REMOTE_FTPPASS} $ORIG_URL_ARCH $curl_delete_add >/dev/null && {
|
eval curl -s -u${AUTODIST_REPOSITORIES_REMOTE_FTPUSER}:${AUTODIST_REPOSITORIES_REMOTE_FTPPASS} $ORIG_URL_ARCH $curl_delete_add >/dev/null && {
|
||||||
@ -195,27 +195,27 @@ function import_file() {
|
|||||||
-o $DEST_URL_ARCH/$f $curl_delete_add || {
|
-o $DEST_URL_ARCH/$f $curl_delete_add || {
|
||||||
echo
|
echo
|
||||||
echo "ERROR: cannot get file $ORIG_URL_ARCH/$f; aborting." >&2
|
echo "ERROR: cannot get file $ORIG_URL_ARCH/$f; aborting." >&2
|
||||||
exit 1
|
exit 200
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# remote -> remote
|
# remote -> remote
|
||||||
echo "ERROR: remote to remote file import is not implemented yet; aborting." >&2
|
echo "ERROR: remote to remote file import is not implemented yet; aborting." >&2
|
||||||
exit 1
|
exit 200
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$DEST_MODE" = "local" ]; then
|
if [ "$DEST_MODE" = "local" ]; then
|
||||||
# local -> local
|
# local -> local
|
||||||
cp $ORIG_URL_ARCH/$f $DEST_URL_ARCH/ || {
|
cp $ORIG_URL_ARCH/$f $DEST_URL_ARCH/ || {
|
||||||
echo "ERROR: cannot copy file $ORIG_URL_ARCH/$f to $DEST_URL_ARCH/$f; aborting." >&2
|
echo "ERROR: cannot copy file $ORIG_URL_ARCH/$f to $DEST_URL_ARCH/$f; aborting." >&2
|
||||||
exit 1
|
exit 200
|
||||||
}
|
}
|
||||||
#chown ftp$DEST_REPOSITORY:users $DEST_URL_ARCH/$f
|
#chown ftp$DEST_REPOSITORY:users $DEST_URL_ARCH/$f
|
||||||
touch $DEST_URL_ARCH
|
touch $DEST_URL_ARCH
|
||||||
if [ "$import_mode" = "backup" ]; then
|
if [ "$import_mode" = "backup" ]; then
|
||||||
rm -f $ORIG_URL_ARCH/$f || {
|
rm -f $ORIG_URL_ARCH/$f || {
|
||||||
echo "ERROR: cannot remove file $ORIG_URL_ARCH/$f; aborting." >&2
|
echo "ERROR: cannot remove file $ORIG_URL_ARCH/$f; aborting." >&2
|
||||||
exit 1
|
exit 200
|
||||||
}
|
}
|
||||||
touch $ORIG_URL_ARCH
|
touch $ORIG_URL_ARCH
|
||||||
fi
|
fi
|
||||||
@ -227,7 +227,7 @@ function import_file() {
|
|||||||
$DEST_URL_ARCH/ || {
|
$DEST_URL_ARCH/ || {
|
||||||
echo
|
echo
|
||||||
echo "ERROR: cannot send file $ORIG_URL_ARCH/$f; aborting." >&2
|
echo "ERROR: cannot send file $ORIG_URL_ARCH/$f; aborting." >&2
|
||||||
exit 1
|
exit 200
|
||||||
}
|
}
|
||||||
rm -f $ORIG_URL_ARCH/$f || {
|
rm -f $ORIG_URL_ARCH/$f || {
|
||||||
echo
|
echo
|
||||||
@ -251,7 +251,7 @@ function backup_local_file() {
|
|||||||
if [ "$simulate" != "1" ]; then
|
if [ "$simulate" != "1" ]; then
|
||||||
mv $m $LOCAL_BACKUP/ || {
|
mv $m $LOCAL_BACKUP/ || {
|
||||||
echo "ERROR: can't move $m to $LOCAL_BACKUP; aborting." >&2
|
echo "ERROR: can't move $m to $LOCAL_BACKUP; aborting." >&2
|
||||||
exit 1
|
exit 200
|
||||||
}
|
}
|
||||||
touch `dirname $m`
|
touch `dirname $m`
|
||||||
fi
|
fi
|
||||||
@ -341,7 +341,7 @@ function restore_local_file() {
|
|||||||
if [ "$simulate" != "1" ]; then
|
if [ "$simulate" != "1" ]; then
|
||||||
cp ${backupprefix}/$r $restoredest || {
|
cp ${backupprefix}/$r $restoredest || {
|
||||||
echo "ERROR: can't copy $p to $restoredest; aborting." >&2
|
echo "ERROR: can't copy $p to $restoredest; aborting." >&2
|
||||||
exit 1
|
exit 200
|
||||||
}
|
}
|
||||||
touch $restoredest
|
touch $restoredest
|
||||||
fi
|
fi
|
||||||
@ -414,7 +414,7 @@ function restore_package() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function import_package() {
|
function import_package() {
|
||||||
[ $1 ] || exit 1
|
[ $1 ] || exit 200
|
||||||
|
|
||||||
local import_pkg import_mode
|
local import_pkg import_mode
|
||||||
|
|
||||||
@ -440,7 +440,7 @@ function import_package() {
|
|||||||
if [ "$dest_ver-$dest_rel" != "$pkg_version-$pkg_release" ]; then
|
if [ "$dest_ver-$dest_rel" != "$pkg_version-$pkg_release" ]; then
|
||||||
[ "$a" == "$basearch" -a "$force" != "1" ] && {
|
[ "$a" == "$basearch" -a "$force" != "1" ] && {
|
||||||
echo "ERROR: package $import_pkg for $a does not exist in $origrepository and can't merge due to different versions; skipping." >&2
|
echo "ERROR: package $import_pkg for $a does not exist in $origrepository and can't merge due to different versions; skipping." >&2
|
||||||
return 255
|
return 254
|
||||||
}
|
}
|
||||||
if [ "$force" = "1" ]; then
|
if [ "$force" = "1" ]; then
|
||||||
echo "WARNING: package $import_pkg for $a is missing in $origrepository but present in $destrepository." >&2
|
echo "WARNING: package $import_pkg for $a is missing in $origrepository but present in $destrepository." >&2
|
||||||
@ -473,7 +473,7 @@ function import_package() {
|
|||||||
|
|
||||||
[ $origpkgname ] || {
|
[ $origpkgname ] || {
|
||||||
echo "ERROR: package $import_pkg does not exist in $origrepository; aborting." >&2
|
echo "ERROR: package $import_pkg does not exist in $origrepository; aborting." >&2
|
||||||
exit 1
|
exit 200
|
||||||
}
|
}
|
||||||
|
|
||||||
DEST_URL_ARCH=$DEST_URL/$destrepository/SRPMS.base/
|
DEST_URL_ARCH=$DEST_URL/$destrepository/SRPMS.base/
|
||||||
@ -555,7 +555,7 @@ function import_package() {
|
|||||||
|
|
||||||
else # check_existence != 1
|
else # check_existence != 1
|
||||||
echo "ERROR: $import_pkg reported by distromatic does no longer exist" >&2
|
echo "ERROR: $import_pkg reported by distromatic does no longer exist" >&2
|
||||||
return 255
|
return 253
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,7 +608,7 @@ function extract_diffinfo() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
[ $1 ] || { usage; exit 1; }
|
[ $1 ] || { usage; exit 0; }
|
||||||
|
|
||||||
origrepository=
|
origrepository=
|
||||||
destrepository=devel
|
destrepository=devel
|
||||||
@ -668,7 +668,7 @@ while [ "$1" ]; do
|
|||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
[ "$command" = "" ] && { usage; exit 1; }
|
[ "$command" = "" ] && { usage; exit 0; }
|
||||||
|
|
||||||
#[ "$command" = "list" ] && echo "Local repositories:"
|
#[ "$command" = "list" ] && echo "Local repositories:"
|
||||||
for a in ${AUTODIST_REPOSITORIES_LOCAL_REPS[*]}; do
|
for a in ${AUTODIST_REPOSITORIES_LOCAL_REPS[*]}; do
|
||||||
@ -708,11 +708,11 @@ done
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "$origrepository" ] || { usage; exit 1; }
|
[ "$origrepository" ] || { usage; exit 200; }
|
||||||
SRCPKGLIST="${LOCAL_REPS_BASE_DIR}/$origrepository/srcpkglist"
|
SRCPKGLIST="${LOCAL_REPS_BASE_DIR}/$origrepository/srcpkglist"
|
||||||
|
|
||||||
[ "$DEST_MODE" ] || { echo "ERROR: $destrepository is not a valid repository; aborting." >&2; exit 1; }
|
[ "$DEST_MODE" ] || { echo "ERROR: $destrepository is not a valid repository; aborting." >&2; exit 200; }
|
||||||
[ "$ORIG_MODE" ] || { echo "ERROR: $origrepository is not a valid repository; aborting." >&2; exit 1; }
|
[ "$ORIG_MODE" ] || { echo "ERROR: $origrepository is not a valid repository; aborting." >&2; exit 200; }
|
||||||
[ "$DEST_MODE" = "remote" ] && { echo "Waring: destination is a remote repository; this is an EXPERIMENTAL feature."; }
|
[ "$DEST_MODE" = "remote" ] && { echo "Waring: destination is a remote repository; this is an EXPERIMENTAL feature."; }
|
||||||
|
|
||||||
[ "$command" = "query" ] && {
|
[ "$command" = "query" ] && {
|
||||||
@ -986,7 +986,7 @@ DESTREGFILE=${LOCAL_REPS_BASE_DIR}/$destrepository/operations.log.html
|
|||||||
[ "$command" = "import" -o "$command" = "release" ] && {
|
[ "$command" = "import" -o "$command" = "release" ] && {
|
||||||
|
|
||||||
[ "$origrepository" = "$destrepository" ] && {
|
[ "$origrepository" = "$destrepository" ] && {
|
||||||
echo "ERROR: source and destination repository cannot be the same; aborting." >&2; exit 1; }
|
echo "ERROR: source and destination repository cannot be the same; aborting." >&2; exit 200; }
|
||||||
|
|
||||||
if [ "$command" = "import" ]; then
|
if [ "$command" = "import" ]; then
|
||||||
echo "Importing $1: $origrepository ($ORIG_MODE) => $destrepository ($DEST_MODE)"
|
echo "Importing $1: $origrepository ($ORIG_MODE) => $destrepository ($DEST_MODE)"
|
||||||
@ -1000,9 +1000,11 @@ DESTREGFILE=${LOCAL_REPS_BASE_DIR}/$destrepository/operations.log.html
|
|||||||
get_packages_from_last_build $origrepository
|
get_packages_from_last_build $origrepository
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
RET=0
|
||||||
for i in ${packages[*]}; do
|
for i in ${packages[*]}; do
|
||||||
import_package $i $backup_mode
|
import_package $i $backup_mode
|
||||||
if [ $? -eq 255 -a "${AUTODIST_REPOSITORIES_TRANSITIONAL_REP}" -a \
|
IMPORT_RET=$?
|
||||||
|
if [ $IMPORT_RET -eq 255 -a "${AUTODIST_REPOSITORIES_TRANSITIONAL_REP}" -a \
|
||||||
"${AUTODIST_REPOSITORIES_TRANSITIONAL_REP}" != "$destrepository" -a \
|
"${AUTODIST_REPOSITORIES_TRANSITIONAL_REP}" != "$destrepository" -a \
|
||||||
"${AUTODIST_REPOSITORIES_TRANSITIONAL_REP}" != "$origrepository" -a \
|
"${AUTODIST_REPOSITORIES_TRANSITIONAL_REP}" != "$origrepository" -a \
|
||||||
"${AUTODIST_REPOSITORIES_TRANSITIONAL_REP/-*}" = "${destrepository/-*}" ]; then
|
"${AUTODIST_REPOSITORIES_TRANSITIONAL_REP/-*}" = "${destrepository/-*}" ]; then
|
||||||
@ -1010,11 +1012,15 @@ DESTREGFILE=${LOCAL_REPS_BASE_DIR}/$destrepository/operations.log.html
|
|||||||
destrepositorysave=$destrepository
|
destrepositorysave=$destrepository
|
||||||
destrepository=${AUTODIST_REPOSITORIES_TRANSITIONAL_REP}
|
destrepository=${AUTODIST_REPOSITORIES_TRANSITIONAL_REP}
|
||||||
import_package $i $backup_mode
|
import_package $i $backup_mode
|
||||||
|
IMPORT_RET=$?
|
||||||
destrepository=$destrepositorysave
|
destrepository=$destrepositorysave
|
||||||
fi
|
fi
|
||||||
|
if [ $IMPORT_RET -ne 0 ]; then
|
||||||
|
RET=`expr $RET + 1`
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
exit 0
|
exit $RET
|
||||||
}
|
}
|
||||||
|
|
||||||
usage
|
usage
|
||||||
|
Loading…
Reference in New Issue
Block a user