From c36e77ad0b7b496712966fa597322f300db5ec49 Mon Sep 17 00:00:00 2001 From: "biao716.wang" Date: Mon, 1 Aug 2022 11:22:13 +0900 Subject: 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 --- init_buildsystem | 71 +++++++++++++++++++++++++++++++++++++++++++++++--------- order | 9 +++++-- 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; } -- cgit v1.2.3 From 6c707fb723d99c774febdae2973b5b54364b4af0 Mon Sep 17 00:00:00 2001 From: "biao716.wang" Date: Wed, 3 Aug 2022 15:18:01 +0900 Subject: retry 3 times to download once failing to download Change-Id: Ifba958d5a69746fe44c8beb874ba93516cb5b8cc Signed-off-by: biao716.wang --- download | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/download b/download index 9297e30..6b374d3 100755 --- a/download +++ b/download @@ -96,7 +96,7 @@ for my $url (@ARGV) { my $res = $ua->mirror($url, $dest); last if $res->is_success; # if it's a redirect we probably got a bad mirror and should just retry - die "reqesting " . hide_passwd($original) . " failed: ".$res->status_line."\n" unless $retry && $res->previous; + die "reqesting " . hide_passwd($original) . " failed: ".$res->status_line."\n" unless $retry; warn "retrying " . hide_passwd($original) . "\n"; } rename($dest, "$dir/".basename($url->path)); -- cgit v1.2.3 From 48d2be133255c2e5bc05e99cf9cbd7962ce4e8bf Mon Sep 17 00:00:00 2001 From: "biao716.wang" Date: Wed, 3 Aug 2022 17:15:29 +0900 Subject: update tizen version to tizen20220803 Change-Id: I925f2447245f2e8b47e5a65a0f8eb234f4ca53dd Signed-off-by: biao716.wang --- debian/changelog | 8 ++++++++ packaging/build.changes | 7 +++++++ packaging/build.spec | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index e0f2dfa..f72e75e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +build (20160629-tizen20220803) unstable; urgency=high + + * Update tizen version to tizen20220803 + * Always retry 3 times to download if download fail. + * Add logic to re-downloading packages in reorder step if some packages is missed! + + -- Wang Biao Wed, 03 Aug 2022 09:30:00 +0800 + build (20160629-tizen20220705) unstable; urgency=high * Update tizen version to tizen20220705 diff --git a/packaging/build.changes b/packaging/build.changes index aa9312e..a718ad3 100644 --- a/packaging/build.changes +++ b/packaging/build.changes @@ -1,3 +1,10 @@ +-------------------------------------------------------------------- +Wed Aug 03 09:30:00 CST 2022 - biao716.wang@samsung.com + +- Update tizen version to tizen20220803 +- Always retry 3 times to download if download fail. +- Add logic to re-downloading packages in reorder step if some packages is missed! + -------------------------------------------------------------------- Thu Jul 05 09:30:00 CST 2022 - biao716.wang@samsung.com diff --git a/packaging/build.spec b/packaging/build.spec index 302008c..c8c7a55 100644 --- a/packaging/build.spec +++ b/packaging/build.spec @@ -72,7 +72,7 @@ Requires: build-mkbaselibs %if 0%{?suse_version} > 1120 || 0%{?mdkversion} Recommends: build-mkdrpms %endif -Provides: tizen-build = 20220705 +Provides: tizen-build = 20220803 %description This package provides a script for building RPMs for SUSE Linux in a chroot environment. @@ -116,7 +116,7 @@ Group: Development/Tools/Building Requires: build BuildRequires: gcc BuildRequires: glibc-devel -Provides: tizen-build-initvm-%{initvm_arch} = 20220705 +Provides: tizen-build-initvm-%{initvm_arch} = 20220803 Obsoletes: build-initvm %if 0%{?suse_version} BuildRequires: glibc-devel-static -- cgit v1.2.3