
download_upstream_repo() { - git clone "git://$GIT_SERVER/openeuler/${upstream_repo}" || die "clone git repo ${package_name} failed: git://$GIT_SERVER/openeuler/${upstream_repo}" - cd $package_name || exit + git clone "git://${GIT_SERVER}/openeuler/${upstream_repo}" || die "clone git repo ${package_name} failed: git://${GIT_SERVER}/openeuler/${upstream_repo}"
too long line, maybe you can use '\' to wrap line.
can define a variable for the repo url Thanks, Luan Shengde
Thanks, Liushaofei
+ cd "$package_name" || exit filelist=$(git ls-files) + for pkgfile in ${filelist[@]} do local dir="SOURCES" - echo $pkgfile | egrep "\.spec$" && dir="SPECS" + + echo "$pkgfile" | grep -E "\\.spec$" && dir="SPECS" mv "$pkgfile" "${HOME}/rpmbuild/${dir}/" done }
-build_rpm() +install_srpm() { - local spec_file=${HOME}/rpmbuild/SPECS/$package_name.spec - - # HTTP is proxy cache friendly - sed -i 's/^\(Source[^ ]*:[ \t]*\)https/\1http/g' `grep http -rl $spec_file` + rpm -i "${repo_addr}/${upstream_repo}" >/dev/null || die "failed to install source rpm: ${repo_addr}/${upstream_repo}" +}
+build_rpm() +{ + local spec_dir="${HOME}/rpmbuild/SPECS" + [ -n "$package_name" ] && + { + # HTTP is proxy cache friendly + sed -i 's/^\(Source[^ ]*:[ \t]*\)https/\1http/g' "$(grep http -rl "$spec_dir/${package_name}.spec")" + } # Install build depends - yum-builddep -y $spec_file || exit + yum-builddep -y "$spec_dir"/*.spec || die "failed to solve dependencies" # Download tar.gz to default path ${HOME}/rpmbuild/SOURCE - spectool -g -R $spec_file || exit + [ -n "$package_name" ] && + { + spectool -g -R "$spec_dir/${package_name}.spec" || die "failed to download source file" + } # Building rpm or srpm packages - rpmbuild -ba $spec_file || exit + rpmbuild -ba "$spec_dir"/*.spec || die "failed to build rpms" }
show_rpm_files() @@ -71,7 +113,6 @@ upload_rpm_pkg() done }
-init_workspace -download_upstream_repo +check_flow build_rpm upload_rpm_pkg -- 2.23.0