summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbiao716.wang <biao716.wang@samsung.com>2022-08-01 11:22:13 +0900
committerbiao716.wang <biao716.wang@samsung.com>2022-08-01 11:22:17 +0900
commitc36e77ad0b7b496712966fa597322f300db5ec49 (patch)
treeb68203353e6383e546dfa76b9125e2d965ee5985
parent32c08dfde20cdf29399db02a52ef3111477500ca (diff)
downloadbuild-c36e77ad0b7b496712966fa597322f300db5ec49.tar.gz
build-c36e77ad0b7b496712966fa597322f300db5ec49.tar.bz2
build-c36e77ad0b7b496712966fa597322f300db5ec49.zip
Add logic to re-downloading packages in reorder step if some packages is missed!
https://github.sec.samsung.net/RS-tizen-build/issues/issues/920 Change-Id: I4ca5d1515ecb9d0e1e89e70242e4ccf690e9b445 Signed-off-by: biao716.wang <biao716.wang@samsung.com>
-rwxr-xr-xinit_buildsystem71
-rwxr-xr-xorder9
2 files changed, 67 insertions, 13 deletions
diff --git a/init_buildsystem b/init_buildsystem
index 6876514..dfab8e3 100755
--- a/init_buildsystem
+++ b/init_buildsystem
@@ -270,15 +270,6 @@ run_pkg_scripts() {
done
}
-reorder() {
- test -z "$*" && return
- rm -f "$BUILD_ROOT"/.init_b_cache/order.manifest
- for PKG in "$@" ; do
- echo "$PKG" >> "$BUILD_ROOT"/.init_b_cache/order.manifest
- done
- $BUILD_DIR/order --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir $CONFIG_DIR --manifest "$BUILD_ROOT"/.init_b_cache/order.manifest "$BUILD_ROOT"/.init_b_cache/rpms || touch "$BUILD_ROOT"/exit
- rm -f "$BUILD_ROOT"/.init_b_cache/order.manifest
-}
create_devs() {
local com file mode arg
@@ -445,7 +436,9 @@ downloadpkg() {
local destdir="$cachedir/tmp_$$"
mkdir -p "$destdir"
- echo "downloading $url ... ";
+ if [ ! -f "$BUILD_ROOT"/exit ] ; then
+ echo "downloading $url ... ";
+ fi
$BUILD_DIR/download "$destdir" "$url" || cleanup_and_exit 1
local destfile="$destdir/${url##*/}"
if test ! -e "$destfile" ; then
@@ -468,6 +461,61 @@ downloadpkg() {
rm -rf $destdir
}
+reorder() {
+ test -z "$*" && return
+ rm -f "$BUILD_ROOT"/.init_b_cache/order.manifest
+ for PKG in "$@" ; do
+ echo "$PKG" >> "$BUILD_ROOT"/.init_b_cache/order.manifest
+ done
+
+ #NOTICE: in reorder, you can't print any logs, or it will treate the logs as pacakges outside
+ #Change: If reorder failed because of missing packages, add logic to re-download the missed packages.
+ touch "$BUILD_ROOT"/missedPKG
+ echo "" > "$BUILD_ROOT"/missedPKG
+ while true
+ do
+ #remove exit file, it will create exit file if reorder fail.
+ rm -f "$BUILD_ROOT"/exit
+ #call order operation
+ $BUILD_DIR/order --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir $CONFIG_DIR --manifest "$BUILD_ROOT"/.init_b_cache/order.manifest "$BUILD_ROOT"/.init_b_cache/rpms "$BUILD_ROOT"/missedPKG || touch "$BUILD_ROOT"/exit
+
+ #order operation OK, exit reorder funciton
+ if [ ! -f "$BUILD_ROOT"/exit ]; then
+ #after reorder again, if reorder is normal, should delete tmp file.
+ rm -f "$BUILD_ROOT"/missedPKG
+ rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist_reorder_check.download
+ break
+ fi
+ #order operation failed!
+ if [ -f "$BUILD_ROOT"/exit ]; then
+ #fail reason: binary not found. To try to download packages again.
+ if test -s "$BUILD_ROOT"/missedPKG; then
+ for line in `cat "$BUILD_ROOT"/missedPKG`; do
+ while read PKG SRC; do
+ if [ "$PKG" = "$line" ]; then
+ downloadpkg "$SRC"
+ # downloadpkg missed packages
+ SRCSUF=${SRC/%.pkg.tar.?z/.arch}
+ #remove the soft link that already existed.
+ rm -f "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
+ ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
+ break
+ fi
+ done < "$BUILD_ROOT"/.init_b_cache/rpmlist_reorder_check.download
+ done
+ #clear file. use it next loop if needed.
+ echo "" > "$BUILD_ROOT"/missedPKG
+ #Other fail reason. Exit!
+ else
+ rm -f "$BUILD_ROOT"/missedPKG
+ rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist_reorder_check.download
+ break
+ fi
+ fi
+ done
+ rm -f "$BUILD_ROOT"/.init_b_cache/order.manifest
+}
+
getcachedir() {
local url=$1
for repo in "${repos[@]}" ; do
@@ -838,6 +886,7 @@ else
SRCSUF=${SRCSUF/%.pkg.tar.?z/.arch}
ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
done < "$BUILD_ROOT"/.init_b_cache/rpmlist.download
+ cp "$BUILD_ROOT"/.init_b_cache/rpmlist.download "$BUILD_ROOT"/.init_b_cache/rpmlist_reorder_check.download
rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist.download
echo
fi
@@ -973,7 +1022,7 @@ if ! test -e "$BUILD_ROOT"/.build/init_buildsystem.data ; then
echo -n 'reordering...'
PACKAGES_TO_INSTALL=`reorder $PACKAGES_TO_INSTALL`
check_exit
- echo 'done'
+ echo 'reordering done'
fi
#
diff --git a/order b/order
index a3c9d8e..398c8ab 100755
--- a/order
+++ b/order
@@ -57,7 +57,7 @@ while (@ARGV) {
die("usage: order [--manifest manifest] cachedir [packages...]\n") unless @ARGV;
my $cachedir = shift @ARGV;
-
+my $missedpkgfile = shift @ARGV;
my @p;
if ($manifest) {
if ($manifest eq '-') {
@@ -92,7 +92,12 @@ for my $p (@p) {
delete $q->{'filelist'};
last;
}
- die("binary not found: $p\n") unless $q;
+ unless ($q) {
+ open(MISS, ">$missedpkgfile");
+ print MISS "$p";
+ close(MISS);
+ die("binary not found: $p, try to download it again!\n");
+ }
$deps{$p} = $q;
}