[PATCH v5 lkp-tests] tests/cci-makepkg: add download PKGBUILD patch function

[Why] Support more version's PKGBUILD. [How] Download the required file through remote-git from /srv/git/pkg/ usage: job yaml add new field: PKGBUILD_TAG About $PKGBUILD_TAG, it is from PKGBUILD file's $pkgver-$pkgrel. example: PKGBUILD_TAG: 1.0-20 You should create a git repo that name same as $benchmark in /srv/git/pkg/ before you add PKGBUILD_TAG to yaml. If not, cci-makepkg will report an error. And everything same as before if no PKGBUILD_TAG. Signed-off-by: Lin Jiaxin <ljx.joe@qq.com> --- tests/cci-makepkg | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/cci-makepkg b/tests/cci-makepkg index 44be44b3..530c9fef 100755 --- a/tests/cci-makepkg +++ b/tests/cci-makepkg @@ -39,12 +39,29 @@ cd $LKP_SRC/pkg/$benchmark || die "pkg is empty" mount -t cifs -o guest,vers=1.0,noacl,nouser_xattr //$LKP_SERVER$PKG_MNT $PKG_MNT || die "Failed to run mount" } +curl_pkgfile() +{ + curl -sS -H 'Content-Type: Application/json' -XPOST "$LKP_SERVER"':8100/git_command' \ + -d '{"git_repo": "'$1'", "git_command": ["git-show", "HEAD:'$2'"]}' -o "$2" +} + +download_pkgfile() +{ + local pkg_tag_file="PKGBUILD-$PKGBUILD_TAG" + + curl_pkgfile "pkg/$benchmark" "$pkg_tag_file" + + [ -f "$pkg_tag_file" ] || die "$pkg_tag_file not exist" + [ -s "$pkg_tag_file" ] || die "$pkg_tag_file is empty" +} + get_pkg_info() { var=$1 pkg_dir=${2:-.} ( . $pkg_dir/PKGBUILD + [ -n "$PKGBUILD_TAG" ] && . $pkg_dir/PKGBUILD-$PKGBUILD_TAG eval echo '$'$var ) } @@ -71,6 +88,8 @@ update_shared_pkg() echo "update shared pkg link ${benchmark}.cgz -> ${bm_name}/${cgz_name}" } +[ -n "$PKGBUILD_TAG" ] && download_pkgfile + distro_install_depends lkp-dev [ $os = "centos" ] && -- 2.23.0

+curl_pkgfile() +{ + curl -sS -H 'Content-Type: Application/json' -XPOST "$LKP_SERVER"':8100/git_command' \ + -d '{"git_repo": "'$1'", "git_command": ["git-show", "HEAD:'$2'"]}' -o "$2" +} + +download_pkgfile() +{ + local pkg_tag_file="PKGBUILD-$PKGBUILD_TAG" + + curl_pkgfile "pkg/$benchmark" "$pkg_tag_file"
The below two lines it's better to put it before curl_pkgfile. Thanks, Zhangyu
participants (2)
-
Lin Jiaxin
-
Zhang Yu