[PATCH v2 lkp-tests] test/build-pkg: fix a softlink will be established if the package fails

[why] After packaging fails, a softlink will be established, but this is wrong. If the packaging fails, the soft connection should not be established. Signed-off-by: Sun Yukui <sun.yukui@foxmail.com> --- tests/build-pkg | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/build-pkg b/tests/build-pkg index ad8d4843..093bbe4d 100755 --- a/tests/build-pkg +++ b/tests/build-pkg @@ -65,6 +65,19 @@ request_pkg() [ -s PKGBUILD ] || die "PKGBUILD is empty" } +create_softlink() +{ + local soft_path="$PKG_MNT/${pack_to}/${pkgname}" + local bm_name=$(basename $(realpath ${cgz_name})) + + if [ -n "$upstream_tag" ]; then + echo "create soft link: ${upstream_tag}.cgz -> ${bm_name}" + ln -sf "${bm_name}" "${soft_path}/${upstream_tag}.cgz" + fi + + echo "create soft link: latest.cgz -> ${bm_name}" + ln -sf "${bm_name}" "${soft_path}/latest.cgz" +} build_source_pkg() { @@ -86,24 +99,11 @@ build_source_pkg() cgz_name="$PKG_MNT/${pack_to}/${pkgname}/${upstream_commit}.cgz" PACMAN=true BUILDDIR=$TMP CARCH=$os_arch PKGEXT=.cgz CGZDEST="$cgz_name" \ $LKP_SRC/sbin/makepkg -A --check --skippgpcheck --config $LKP_SRC/etc/makepkg.conf 2>&1 -} -create_softlink() -{ - local soft_path="$PKG_MNT/${pack_to}/${pkgname}" - local bm_name=$(basename $(realpath ${cgz_name})) - - if [ -n "$upstream_tag" ]; then - echo "create soft link: ${upstream_tag}.cgz -> ${bm_name}" - ln -sf "${bm_name}" "${soft_path}/${upstream_tag}.cgz" - fi - - echo "create soft link: latest.cgz -> ${bm_name}" - ln -sf "${bm_name}" "${soft_path}/latest.cgz" + [ "$?" == 0 ] || create_softlink } check_vars mount_dest request_pkg build_source_pkg -create_softlink -- 2.23.0

On Thu, Nov 12, 2020 at 05:11:05PM +0800, Sun Yukui wrote:
[why] After packaging fails, a softlink will be established, but this is wrong. If the packaging fails, the soft connection should not be established.
soft connection => softlink Keep the same thing the same name, that would makes your log easier to understand. Thanks, Yuanchao

On Thu, Nov 12, 2020 at 05:23:56PM +0800, Li Yuanchao wrote:
On Thu, Nov 12, 2020 at 05:11:05PM +0800, Sun Yukui wrote:
[why] After packaging fails, a softlink will be established, but this is wrong. If the packaging fails, the soft connection should not be established.
soft connection => softlink
Keep the same thing the same name, that would makes your log easier to understand.
ok, Thanks, Liushaofei
Thanks, Yuanchao

On Thu, Nov 12, 2020 at 05:11:05PM +0800, Sun Yukui wrote:
[why] After packaging fails, a softlink will be established, but this is wrong. If the packaging fails, the soft connection should not be established.
Signed-off-by: Sun Yukui <sun.yukui@foxmail.com> --- tests/build-pkg | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/tests/build-pkg b/tests/build-pkg index ad8d4843..093bbe4d 100755 --- a/tests/build-pkg +++ b/tests/build-pkg @@ -65,6 +65,19 @@ request_pkg() [ -s PKGBUILD ] || die "PKGBUILD is empty" }
+create_softlink() +{ + local soft_path="$PKG_MNT/${pack_to}/${pkgname}"
how about source_path
+ local bm_name=$(basename $(realpath ${cgz_name}))
local = pwd_path
+ + if [ -n "$upstream_tag" ]; then + echo "create soft link: ${upstream_tag}.cgz -> ${bm_name}" + ln -sf "${bm_name}" "${soft_path}/${upstream_tag}.cgz" + fi + + echo "create soft link: latest.cgz -> ${bm_name}"
create symbolic links Thanks, Shenwei
+ ln -sf "${bm_name}" "${soft_path}/latest.cgz" +}
build_source_pkg() { @@ -86,24 +99,11 @@ build_source_pkg() cgz_name="$PKG_MNT/${pack_to}/${pkgname}/${upstream_commit}.cgz" PACMAN=true BUILDDIR=$TMP CARCH=$os_arch PKGEXT=.cgz CGZDEST="$cgz_name" \ $LKP_SRC/sbin/makepkg -A --check --skippgpcheck --config $LKP_SRC/etc/makepkg.conf 2>&1 -}
-create_softlink() -{ - local soft_path="$PKG_MNT/${pack_to}/${pkgname}" - local bm_name=$(basename $(realpath ${cgz_name})) - - if [ -n "$upstream_tag" ]; then - echo "create soft link: ${upstream_tag}.cgz -> ${bm_name}" - ln -sf "${bm_name}" "${soft_path}/${upstream_tag}.cgz" - fi - - echo "create soft link: latest.cgz -> ${bm_name}" - ln -sf "${bm_name}" "${soft_path}/latest.cgz" + [ "$?" == 0 ] || create_softlink }
check_vars mount_dest request_pkg build_source_pkg -create_softlink -- 2.23.0

On Thu, Nov 12, 2020 at 05:25:45PM +0800, Xiao Shenwei wrote:
On Thu, Nov 12, 2020 at 05:11:05PM +0800, Sun Yukui wrote:
[why] After packaging fails, a softlink will be established, but this is wrong. If the packaging fails, the soft connection should not be established.
Signed-off-by: Sun Yukui <sun.yukui@foxmail.com> --- tests/build-pkg | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/tests/build-pkg b/tests/build-pkg index ad8d4843..093bbe4d 100755 --- a/tests/build-pkg +++ b/tests/build-pkg @@ -65,6 +65,19 @@ request_pkg() [ -s PKGBUILD ] || die "PKGBUILD is empty" }
+create_softlink() +{ + local soft_path="$PKG_MNT/${pack_to}/${pkgname}"
how about source_path
no, it is soft link path.
+ local bm_name=$(basename $(realpath ${cgz_name}))
local = pwd_path
this is the full path for cgz file.
+ + if [ -n "$upstream_tag" ]; then + echo "create soft link: ${upstream_tag}.cgz -> ${bm_name}" + ln -sf "${bm_name}" "${soft_path}/${upstream_tag}.cgz" + fi + + echo "create soft link: latest.cgz -> ${bm_name}"
create symbolic links
ok, Thanks, Liushaofei
Thanks, Shenwei
+ ln -sf "${bm_name}" "${soft_path}/latest.cgz" +}
build_source_pkg() { @@ -86,24 +99,11 @@ build_source_pkg() cgz_name="$PKG_MNT/${pack_to}/${pkgname}/${upstream_commit}.cgz" PACMAN=true BUILDDIR=$TMP CARCH=$os_arch PKGEXT=.cgz CGZDEST="$cgz_name" \ $LKP_SRC/sbin/makepkg -A --check --skippgpcheck --config $LKP_SRC/etc/makepkg.conf 2>&1 -}
-create_softlink() -{ - local soft_path="$PKG_MNT/${pack_to}/${pkgname}" - local bm_name=$(basename $(realpath ${cgz_name})) - - if [ -n "$upstream_tag" ]; then - echo "create soft link: ${upstream_tag}.cgz -> ${bm_name}" - ln -sf "${bm_name}" "${soft_path}/${upstream_tag}.cgz" - fi - - echo "create soft link: latest.cgz -> ${bm_name}" - ln -sf "${bm_name}" "${soft_path}/latest.cgz" + [ "$?" == 0 ] || create_softlink }
check_vars mount_dest request_pkg build_source_pkg -create_softlink -- 2.23.0
participants (4)
-
Li Yuanchao
-
Liu Shaofei
-
Sun Yukui
-
Xiao Shenwei