add function for rpmbuild-pkg and install-rpm
Signed-off-by: Wang Yong <wangyong0117(a)qq.com>
---
lib/rpm.sh | 20 ++++++++++++++++++++
tests/install-rpm | 22 +---------------------
tests/rpmbuild-pkg | 6 ++++++
3 files changed, 27 insertions(+), 21 deletions(-)
create mode 100755 lib/rpm.sh
diff --git a/lib/rpm.sh b/lib/rpm.sh
new file mode 100755
index 000000000..91f234da4
--- /dev/null
+++ b/lib/rpm.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+add_repo()
+{
+ custom_repo_name=($custom_repo_name)
+ custom_repo_addr=($custom_repo_addr)
+
+ for i in ${!custom_repo_name[@]}
+ do
+ cat <<EOF >> /etc/yum.repos.d/"${custom_repo_name[$i]}.repo"
+[${custom_repo_name[$i]}]
+name=${custom_repo_name[$i]}
+baseurl=${custom_repo_addr[$i]}
+enabled=1
+gpgcheck=0
+priority=100
+
+EOF
+ done
+}
\ No newline at end of file
diff --git a/tests/install-rpm b/tests/install-rpm
index d69d2d4c1..7449b3bd1 100755
--- a/tests/install-rpm
+++ b/tests/install-rpm
@@ -9,6 +9,7 @@
. $LKP_SRC/lib/debug.sh
. $LKP_SRC/lib/upload.sh
. $LKP_SRC/lib/log.sh
+. $LKP_SRC/lib/rpm.sh
: "${compat_os:=budding-openeuler}"
: "${DISTRO:=openeuler}"
@@ -19,29 +20,8 @@
[ -n "${custom_repo_name}" ] || die "custom_repo_name is empty"
[ -n "${custom_repo_addr}" ] || die "custom_repo_addr is empty"
-custom_repo_name=($custom_repo_name)
-custom_repo_addr=($custom_repo_addr)
rpm_name=($rpm_name)
-add_repo()
-{
- custom_repo_name=($custom_repo_name)
- custom_repo_addr=($custom_repo_addr)
-
- for i in ${!custom_repo_name[@]}
- do
- cat <<EOF >> /etc/yum.repos.d/"${custom_repo_name[$i]}.repo"
-[${custom_repo_name[$i]}]
-name=${custom_repo_name[$i]}
-baseurl=${custom_repo_addr[$i]}
-enabled=1
-gpgcheck=0
-priority=100
-
-EOF
- done
-}
-
install_rpm()
{
log_info "Starting install test: yum install -y ${rpm_name[@]}"
diff --git a/tests/rpmbuild-pkg b/tests/rpmbuild-pkg
index 312582d16..5c694b9d4 100755
--- a/tests/rpmbuild-pkg
+++ b/tests/rpmbuild-pkg
@@ -3,10 +3,15 @@
# - compat_os
# - repo_name
# - repo_addr
+# - custom_repo_name
+# - custom_repo_addr
# Git repo jobs only use the first two parameters, SRPMs jobs use all
+# user can add custom_repo_name and custom_repo_addr to setup
+# local repo, value can be an array
. $LKP_SRC/lib/debug.sh
. $LKP_SRC/lib/upload.sh
+. $LKP_SRC/lib/rpm.sh
: "${compat_os:=budding-openeuler}"
@@ -133,6 +138,7 @@ update_repo_mq()
-d "{\"upload_rpms\": ["${full_list}"]}"
}
+add_repo
[ -n "$repo_name" ] && from_srpm || from_git
build_rpm
upload_rpm_pkg
--
2.23.0