From bac3e963a56d17d57fed3882cd5b8db1438be926 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 15 Jul 2020 10:53:17 +0800 Subject: [PATCH] ceph-*-build,ceph-release-rpm: extract build_ceph_release_rpm for less repeating Signed-off-by: Kefu Chai --- ceph-dev-build/build/build_rpm | 105 +-------------------- ceph-dev-new-build/build/build_rpm | 105 +-------------------- ceph-release-rpm/build/build | 110 +--------------------- scripts/build_utils.sh | 142 +++++++++++++++++++++++++++++ 4 files changed, 145 insertions(+), 317 deletions(-) diff --git a/ceph-dev-build/build/build_rpm b/ceph-dev-build/build/build_rpm index f95c1ed6..17b0381c 100644 --- a/ceph-dev-build/build/build_rpm +++ b/ceph-dev-build/build/build_rpm @@ -43,110 +43,7 @@ PACKAGE_MANAGER_VERSION="$RPM_VERSION-$RPM_RELEASE" BUILDAREA=$(setup_rpm_build_area ./rpm/$dist) build_rpms $BUILDAREA ${CEPH_EXTRA_RPMBUILD_ARGS} - -# The following was copied from autobuild-ceph/build-ceph-rpm.sh -# which creates the ceph-release rpm meant to create the repository file for the repo -# that will be built and served later. -# Create and build an RPM for the repository - -cat < ${BUILDAREA}/SPECS/ceph-release.spec -Name: ceph-release -Version: 1 -Release: 0%{?dist} -Summary: Ceph Development repository configuration -Group: System Environment/Base -License: GPLv2 -URL: ${chacra_url}r/ceph/${chacra_ref}/${SHA1}/${DISTRO}/${RELEASE}/flavors/$FLAVOR/ -Source0: ceph.repo -#Source0: RPM-GPG-KEY-CEPH -#Source1: ceph.repo -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildArch: noarch - -%description -This package contains the Ceph repository GPG key as well as configuration -for yum and up2date. - -%prep - -%setup -q -c -T -install -pm 644 %{SOURCE0} . -#install -pm 644 %{SOURCE1} . - -%build - -%install -rm -rf %{buildroot} -#install -Dpm 644 %{SOURCE0} \ -# %{buildroot}/%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-CEPH -%if 0%{defined suse_version} -install -dm 755 %{buildroot}/%{_sysconfdir}/zypp -install -dm 755 %{buildroot}/%{_sysconfdir}/zypp/repos.d -install -pm 644 %{SOURCE0} \ - %{buildroot}/%{_sysconfdir}/zypp/repos.d -%else -install -dm 755 %{buildroot}/%{_sysconfdir}/yum.repos.d -install -pm 644 %{SOURCE0} \ - %{buildroot}/%{_sysconfdir}/yum.repos.d -%endif - -%clean -#rm -rf %{buildroot} - -%post - -%postun - -%files -%defattr(-,root,root,-) -#%doc GPL -%if 0%{defined suse_version} -/etc/zypp/repos.d/* -%else -/etc/yum.repos.d/* -%endif -#/etc/pki/rpm-gpg/* - -%changelog -* Fri Aug 12 2016 Alfredo Deza 1-1 -- Initial Package -EOF -# End of ceph-release.spec file. - -# GPG Key -#gpg --export --armor $keyid > ${BUILDAREA}/SOURCES/RPM-GPG-KEY-CEPH -#chmod 644 ${BUILDAREA}/SOURCES/RPM-GPG-KEY-CEPH - -# Install ceph.repo file -cat < $BUILDAREA/SOURCES/ceph.repo -[Ceph] -name=Ceph packages for \$basearch -baseurl=${chacra_url}/r/ceph/${chacra_ref}/${SHA1}/${DISTRO}/${RELEASE}/flavors/${FLAVOR}/\$basearch -enabled=1 -gpgcheck=0 -type=rpm-md -gpgkey=https://download.ceph.com/keys/autobuild.asc - -[Ceph-noarch] -name=Ceph noarch packages -baseurl=${chacra_url}/r/ceph/${chacra_ref}/${SHA1}/${DISTRO}/${RELEASE}/flavors/${FLAVOR}/noarch -enabled=1 -gpgcheck=0 -type=rpm-md -gpgkey=https://download.ceph.com/keys/autobuild.asc - -[ceph-source] -name=Ceph source packages -baseurl=${chacra_url}/r/ceph/${chacra_ref}/${SHA1}/${DISTRO}/${RELEASE}/flavors/${FLAVOR}/SRPMS -enabled=1 -gpgcheck=0 -type=rpm-md -gpgkey=https://download.ceph.com/keys/autobuild.asc -EOF -# End of ceph.repo file - -rpmbuild -bb --define "_topdir ${BUILDAREA}" ${BUILDAREA}/SPECS/ceph-release.spec - +build_ceph_release_rpm $BUILDAREA true # Make sure we execute at the top level directory cd "$WORKSPACE" diff --git a/ceph-dev-new-build/build/build_rpm b/ceph-dev-new-build/build/build_rpm index 97fe6004..2c95e1f2 100644 --- a/ceph-dev-new-build/build/build_rpm +++ b/ceph-dev-new-build/build/build_rpm @@ -44,110 +44,7 @@ PACKAGE_MANAGER_VERSION="$RPM_VERSION-$RPM_RELEASE" BUILDAREA=$(setup_rpm_build_area ./rpm/$dist) build_rpms ${BUILDAREA} ${CEPH_EXTRA_RPMBUILD_ARGS} - -# The following was copied from autobuild-ceph/build-ceph-rpm.sh -# which creates the ceph-release rpm meant to create the repository file for the repo -# that will be built and served later. -# Create and build an RPM for the repository - -cat < ${BUILDAREA}/SPECS/ceph-release.spec -Name: ceph-release -Version: 1 -Release: 0%{?dist} -Summary: Ceph Development repository configuration -Group: System Environment/Base -License: GPLv2 -URL: ${chacra_url}r/ceph/${chacra_ref}/${SHA1}/${DISTRO}/${RELEASE}/flavors/$FLAVOR/ -Source0: ceph.repo -#Source0: RPM-GPG-KEY-CEPH -#Source1: ceph.repo -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildArch: noarch - -%description -This package contains the Ceph repository GPG key as well as configuration -for yum and up2date. - -%prep - -%setup -q -c -T -install -pm 644 %{SOURCE0} . -#install -pm 644 %{SOURCE1} . - -%build - -%install -rm -rf %{buildroot} -#install -Dpm 644 %{SOURCE0} \ -# %{buildroot}/%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-CEPH -%if 0%{defined suse_version} -install -dm 755 %{buildroot}/%{_sysconfdir}/zypp -install -dm 755 %{buildroot}/%{_sysconfdir}/zypp/repos.d -install -pm 644 %{SOURCE0} \ - %{buildroot}/%{_sysconfdir}/zypp/repos.d -%else -install -dm 755 %{buildroot}/%{_sysconfdir}/yum.repos.d -install -pm 644 %{SOURCE0} \ - %{buildroot}/%{_sysconfdir}/yum.repos.d -%endif - -%clean -#rm -rf %{buildroot} - -%post - -%postun - -%files -%defattr(-,root,root,-) -#%doc GPL -%if 0%{defined suse_version} -/etc/zypp/repos.d/* -%else -/etc/yum.repos.d/* -%endif -#/etc/pki/rpm-gpg/* - -%changelog -* Fri Aug 12 2016 Alfredo Deza 1-1 -- Initial Package -EOF -# End of ceph-release.spec file. - -# GPG Key -#gpg --export --armor $keyid > ${BUILDAREA}/SOURCES/RPM-GPG-KEY-CEPH -#chmod 644 ${BUILDAREA}/SOURCES/RPM-GPG-KEY-CEPH - -# Install ceph.repo file -cat < $BUILDAREA/SOURCES/ceph.repo -[Ceph] -name=Ceph packages for \$basearch -baseurl=${chacra_url}/r/ceph/${chacra_ref}/${SHA1}/${DISTRO}/${RELEASE}/flavors/${FLAVOR}/\$basearch -enabled=1 -gpgcheck=0 -type=rpm-md -gpgkey=https://download.ceph.com/keys/autobuild.asc - -[Ceph-noarch] -name=Ceph noarch packages -baseurl=${chacra_url}/r/ceph/${chacra_ref}/${SHA1}/${DISTRO}/${RELEASE}/flavors/${FLAVOR}/noarch -enabled=1 -gpgcheck=0 -type=rpm-md -gpgkey=https://download.ceph.com/keys/autobuild.asc - -[ceph-source] -name=Ceph source packages -baseurl=${chacra_url}/r/ceph/${chacra_ref}/${SHA1}/${DISTRO}/${RELEASE}/flavors/${FLAVOR}/SRPMS -enabled=1 -gpgcheck=0 -type=rpm-md -gpgkey=https://download.ceph.com/keys/autobuild.asc -EOF -# End of ceph.repo file - -rpmbuild -bb --define "_topdir ${BUILDAREA}" ${BUILDAREA}/SPECS/ceph-release.spec - +build_ceph_release_rpm ${BUILDAREA} true # Make sure we execute at the top level directory cd "$WORKSPACE" diff --git a/ceph-release-rpm/build/build b/ceph-release-rpm/build/build index 6f672000..ec8b5ab8 100644 --- a/ceph-release-rpm/build/build +++ b/ceph-release-rpm/build/build @@ -43,118 +43,10 @@ check_binary_existence $chacra_baseurl/noarch mkdir -p RPMBUILD/{BUILD,RPMS,SOURCES,SPECS,SRPMS} BUILDAREA=$WORKSPACE/RPMBUILD -# Create and build an RPM for the repository -cat < ${BUILDAREA}/SPECS/ceph-release.spec -%if 0%{?centos} == 7 -%define dist .el7 -%endif -%if 0%{?centos} == 8 -%define dist .el8 -%endif - - -Name: ceph-release -Version: 1 -Release: 1%{?dist} -Summary: Ceph repository configuration -Group: System Environment/Base -License: GPLv2 -URL: http://download.ceph.com/ -Source0: ceph.repo -#Source0: RPM-GPG-KEY-CEPH -#Source1: ceph.repo -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildArch: noarch - -%description -This package contains the Ceph repository GPG key as well as configuration -for yum and up2date. - -%prep - -%setup -q -c -T -install -pm 644 %{SOURCE0} . -#install -pm 644 %{SOURCE1} . - -%build - -%install -rm -rf %{buildroot} -#install -Dpm 644 %{SOURCE0} \ -# %{buildroot}/%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-CEPH -%if 0%{defined suse_version} -install -dm 755 %{buildroot}/%{_sysconfdir}/zypp -install -dm 755 %{buildroot}/%{_sysconfdir}/zypp/repos.d -install -pm 644 %{SOURCE0} \ - %{buildroot}/%{_sysconfdir}/zypp/repos.d -%else -install -dm 755 %{buildroot}/%{_sysconfdir}/yum.repos.d -install -pm 644 %{SOURCE0} \ - %{buildroot}/%{_sysconfdir}/yum.repos.d -%endif - -%clean -#rm -rf %{buildroot} - -%post - -%postun - -%files -%defattr(-,root,root,-) -#%doc GPL -%if 0%{defined suse_version} -%config(noreplace) /etc/zypp/repos.d/* -%else -%config(noreplace) /etc/yum.repos.d/* -%endif -#/etc/pki/rpm-gpg/* - -%changelog -* Mon Jan 12 2015 Travis Rhoden 1-1 -- Make .repo files be %config(noreplace) -* Tue Mar 10 2013 Gary Lowell - 1-0 -- Handle both yum and zypper -- Use URL to ceph git repo for key -- remove config attribute from repo file -* Tue Aug 27 2012 Gary Lowell - 1-0 -- Initial Package -EOF -# End of ceph-release.spec file. -# Install ceph.repo file - ceph_release="$RELEASE" - -cat < $BUILDAREA/SOURCES/ceph.repo -[Ceph] -name=Ceph packages for \$basearch -baseurl=http://download.ceph.com/rpm-${ceph_release}/${target}/\$basearch -enabled=1 -gpgcheck=1 -type=rpm-md -gpgkey=https://download.ceph.com/keys/release.asc - -[Ceph-noarch] -name=Ceph noarch packages -baseurl=http://download.ceph.com/rpm-${ceph_release}/${target}/noarch -enabled=1 -gpgcheck=1 -type=rpm-md -gpgkey=https://download.ceph.com/keys/release.asc - -[ceph-source] -name=Ceph source packages -baseurl=http://download.ceph.com/rpm-${ceph_release}/${target}/SRPMS -enabled=1 -gpgcheck=1 -type=rpm-md -gpgkey=https://download.ceph.com/keys/release.asc -EOF -# End of ceph.repo file +build_ceph_release_rpm ${BUILDAREA} false [ "$FORCE" = true ] && chacra_flags="--force" || chacra_flags="" - -rpmbuild -ba --define "_topdir ${BUILDAREA}" --define "_unpackaged_files_terminate_build 0" ${BUILDAREA}/SPECS/ceph-release.spec if [ $? -eq 0 ] ; then # we actually do noarch stuff here find $BUILDAREA/RPMS/* | grep noarch | grep rpm | $VENV/chacractl binary ${chacra_flags} create ${chacra_baseurl}/noarch diff --git a/scripts/build_utils.sh b/scripts/build_utils.sh index 4466d407..882ec6b5 100644 --- a/scripts/build_utils.sh +++ b/scripts/build_utils.sh @@ -1111,3 +1111,145 @@ build_rpms() { rpmbuild -ba --define "_topdir ${build_area}" ${extra_rpm_build_args} ceph.spec echo done } + +build_ceph_release_rpm() { + local build_area=$1 + shift + local is_dev_release=$1 + shift + + # The following was copied from autobuild-ceph/build-ceph-rpm.sh + # which creates the ceph-release rpm meant to create the repository file for the repo + # that will be built and served later. + # Create and build an RPM for the repository + + if $is_dev_release; then + summary="Ceph Development repository configuration" + project_url=${chacra_url}r/ceph/${chacra_ref}/${SHA1}/${DISTRO}/${RELEASE}/flavors/$FLAVOR/ + epoch=0 + repo_base_url="${chacra_url}/r/ceph/${chacra_ref}/${SHA1}/${DISTRO}/${RELEASE}/flavors/${FLAVOR}" + gpgcheck=0 + gpgkey=autobuild.asc + else + summary="Ceph repository configuration" + project_url=http://download.ceph.com/ + epoch=1 + repo_base_url="http://download.ceph.com/rpm-${ceph_release}/${target}" + gpgcheck=1 + gpgkey=release.asc + fi + cat < ${build_area}/SPECS/ceph-release.spec +Name: ceph-release +Version: 1 +Release: ${epoch}%{?dist} +Summary: Ceph Development repository configuration +Group: System Environment/Base +License: GPLv2 +URL: ${project_url} +Source0: ceph.repo +#Source0: RPM-GPG-KEY-CEPH +#Source1: ceph.repo +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildArch: noarch + +%description +This package contains the Ceph repository GPG key as well as configuration +for yum and up2date. + +%prep + +%setup -q -c -T +install -pm 644 %{SOURCE0} . +#install -pm 644 %{SOURCE1} . + +%build + +%install +rm -rf %{buildroot} +#install -Dpm 644 %{SOURCE0} \ +# %{buildroot}/%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-CEPH +%if 0%{defined suse_version} +install -dm 755 %{buildroot}/%{_sysconfdir}/zypp +install -dm 755 %{buildroot}/%{_sysconfdir}/zypp/repos.d +install -pm 644 %{SOURCE0} \ + %{buildroot}/%{_sysconfdir}/zypp/repos.d +%else +install -dm 755 %{buildroot}/%{_sysconfdir}/yum.repos.d +install -pm 644 %{SOURCE0} \ + %{buildroot}/%{_sysconfdir}/yum.repos.d +%endif + +%clean +#rm -rf %{buildroot} + +%post + +%postun + +%files +%defattr(-,root,root,-) +#%doc GPL +%if 0%{defined suse_version} +/etc/zypp/repos.d/* +%else +/etc/yum.repos.d/* +%endif +#/etc/pki/rpm-gpg/* + +%changelog +* Fri Aug 12 2016 Alfredo Deza 1-1 +* Mon Jan 12 2015 Travis Rhoden 1-1 +- Make .repo files be %config(noreplace) +* Tue Mar 10 2013 Gary Lowell - 1-0 +- Handle both yum and zypper +- Use URL to ceph git repo for key +- remove config attribute from repo file +* Tue Aug 27 2012 Gary Lowell - 1-0 +- Initial Package +EOF + # End of ceph-release.spec file. + + # GPG Key + #gpg --export --armor $keyid > ${build_area}/SOURCES/RPM-GPG-KEY-CEPH + #chmod 644 ${build_area}/SOURCES/RPM-GPG-KEY-CEPH + + # Install ceph.repo file + cat < $build_area/SOURCES/ceph.repo +[Ceph] +name=Ceph packages for \$basearch +baseurl=${repo_base_url}/\$basearch +enabled=1 +gpgcheck=${gpgcheck} +type=rpm-md +gpgkey=https://download.ceph.com/keys/${gpgkey} + +[Ceph-noarch] +name=Ceph noarch packages +baseurl=${repo_base_url/noarch +enabled=1 +gpgcheck=${gpgcheck} +type=rpm-md +gpgkey=https://download.ceph.com/keys/${gpgkey} + +[ceph-source] +name=Ceph source packages +baseurl=${repo_base_url}/SRPMS +enabled=1 +gpgcheck=${gpgcheck} +type=rpm-md +gpgkey=https://download.ceph.com/keys/${gpgkey} +EOF +# End of ceph.repo file + + if $is_dev_release; then + rpmbuild -bb \ + --define "_topdir ${build_area}" \ + ${build_area}/SPECS/ceph-release.spec + else + # build source packages for official releases + rpmbuild -ba \ + --define "_topdir ${build_area}" \ + --define "_unpackaged_files_terminate_build 0" \ + ${build_area}/SPECS/ceph-release.spec + fi +} -- 2.39.5