Add Epoch to rpm query command 97/156297/3
authory0169.zhang <y0169.zhang@samsung.com>
Thu, 12 Oct 2017 02:46:10 +0000 (10:46 +0800)
committery0169.zhang <y0169.zhang@samsung.com>
Thu, 19 Oct 2017 03:01:21 +0000 (11:01 +0800)
Fix bug: https://bugs.tizen.org/browse/DEVT-342

Change-Id: I8bdf9c55762be61ef53fc0bc6f492423a5024173

init_buildsystem

index 27492f7..bf319a7 100755 (executable)
@@ -463,7 +463,13 @@ can_reuse_cached_package() {
     local cachepkgid pkgid xpkgid
     test -s "$1" || return 1
     if test -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.id" ; then
-           pkgid=$(rpm -qp --qf "${RPMIDFMT}" $RPMCHECKOPTS_HOST "${1}")
+       local ep=$(rpm -qp --qf "%{EPOCH}" "${1}")
+       if test "$ep" != "(none)"; then
+               RPMIDFMT_EP="%{NAME}-%{EPOCH}:%{VERSION}-%{RELEASE} %{BUILDTIME}-%{ARCH}\n"
+               pkgid=`rpm -qp --qf "${RPMIDFMT_EP}" $RPMCHECKOPTS_HOST "${1}"`
+       else
+               pkgid=`rpm -qp --qf "${RPMIDFMT}" $RPMCHECKOPTS_HOST "${1}"`
+       fi
        read cachepkgid < $BUILD_ROOT/.init_b_cache/rpms/$PKG.id
        # check if the build time is zero
        case $cachepkgid in
@@ -1019,12 +1025,18 @@ for PKG in $MAIN_LIST ; do
            continue
        fi
     fi
-   
-   # revert use rpm to query pkgid if building rpm package 
+
+   # revert use rpm to query pkgid if building rpm package
    if test "$PSUF" != "rpm" ; then
        PKGID=$(perl -I$BUILD_DIR -MBuild -e Build::showquery "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" buildid)
    else
-       PKGID=`rpm -qp --qf "$RPMIDFMT" $RPMCHECKOPTS_HOST $BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm`
+       ep=$(rpm -qp --qf "%{EPOCH}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF")
+       if test "$ep" != "(none)"; then
+           RPMIDFMT_EP="%{NAME}-%{EPOCH}:%{VERSION}-%{RELEASE} %{BUILDTIME}-%{ARCH}\n"
+           PKGID=`rpm -qp --qf "${RPMIDFMT_EP}" $RPMCHECKOPTS_HOST "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF"`
+       else
+           PKGID=`rpm -qp --qf "${RPMIDFMT}" $RPMCHECKOPTS_HOST "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF"`
+       fi
    fi
 
     if test -f $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG ; then