#1273 rpmbuild: restore /etc/mock/**.rpmnew files automatically
Merged 4 years ago by praiskup. Opened 4 years ago by praiskup.

file modified
+39 -2
@@ -151,19 +151,47 @@

  name="%{name}" version="%{version}" summary="%{summary}" %py_build

  a2x -d manpage -f manpage man/copr-rpmbuild.1.asciidoc

  

- cat > copr-update-builder <<EOF

+ %global mock_config_overrides %_sysconfdir/copr-rpmbuild/mock-config-overrides

+ 

+ cat > copr-update-builder <<'EOF'

  #! /bin/sh

  

  # Update the Copr builder machine, can be called anytime Copr build system

  # decides to do so (please keep the output idempotent).

  

+ # Remove old rpmnew config files, if they exist now it is a configuration bug

+ # anyways.

+ find /etc/mock -name '*.rpmnew' -delete

+ 

  # install the latest versions of those packages

  dnf update -y %latest_requires_packages

+ 

+ # The mock-core-configs package was potentially updated above, and it provides

+ # "noreplace" %%config files.  It means that - if the builder cloud image had

+ # baked-in locally _changed_ configuration files - the updated official

+ # configuration files from mock-core-configs package wouldn't be used.  So now

+ # make sure that they _are_ used (those, if any, would reside in .rpmnew files).

+ find /etc/mock -name '*.rpmnew' | while read -r rpmnew_file; do

+     config=${rpmnew_file%%.rpmnew}

+     mv -f "$config" "$config.copr-builder-backup"

+     mv "$rpmnew_file" "$config"

+ done

+ 

+ # And now use the overrides from %mock_config_overrides directory

+ (

+   cd %mock_config_overrides

+   find . -name '*.tpl' -o -name '*.cfg' | while read -r file; do

+     base=$(basename "$file")

+     dir=%_sysconfdir/mock/$(dirname "$file")

+     mkdir -p "$dir"

+     cp "$file" "$dir"

+   done

+ )

  EOF

  

  

  %install

- install -d %{buildroot}%{_sysconfdir}/copr-rpmbuild

+ install -d %{buildroot}%mock_config_overrides

  install -d %{buildroot}%{_sharedstatedir}/copr-rpmbuild

  install -d %{buildroot}%{_sharedstatedir}/copr-rpmbuild/results

  
@@ -175,6 +203,13 @@

  install -m 644 rpkg.conf.j2 %{buildroot}%{_sysconfdir}/copr-rpmbuild/rpkg.conf.j2

  install -m 644 make_srpm_mock.cfg %{buildroot}%{_sysconfdir}/copr-rpmbuild/make_srpm_mock.cfg

  

+ cat <<EOF > %buildroot%mock_config_overrides/README

+ Contents of this directory is used by %_bindir/copr-update-builder script.

+ When the script is executed, all files and directories (recursively) from here

+ are automatically copied to /etc/mock directory.  The files in /etc/mock are

+ overwritten if they already exist.

+ EOF

+ 

  install -d %{buildroot}%{_mandir}/man1

  install -p -m 644 man/copr-rpmbuild.1 %{buildroot}/%{_mandir}/man1/

  install -p -m 755 bin/copr-sources-custom %buildroot%_bindir
@@ -206,6 +241,8 @@

  %files -n copr-builder

  %license LICENSE

  %_bindir/copr-update-builder

+ %dir %mock_config_overrides

+ %doc %mock_config_overrides/README

  

  

  %changelog

no initial comment

Metadata Update from @praiskup:
- Pull-request tagged with: wip

4 years ago

I would say this should be in reverse foo.rpmnew rename to foo?

It is, file => file without rpmnew suffix

Metadata Update from @praiskup:
- Pull-request untagged with: wip

4 years ago

rebased onto 979c7ac9de0e5aa7d506156a182a2deb084e0cf1

4 years ago

rebased onto 7d7dcc02438e76bd3e810836429c7597e2fa9f02

4 years ago

Metadata Update from @praiskup:
- Pull-request tagged with: needs-work

4 years ago

rebased onto f1ff799d64c227d1e010fe177705855238941aa3

4 years ago

Metadata Update from @praiskup:
- Pull-request untagged with: needs-work

4 years ago

rebased onto f09f5deddd7af60e2500d31fc96e5845d97b6fd7

4 years ago

2 new commits added

  • rpmbuild: invent /etc/copr-rpmbuild/mock-config-overrides
  • rpmbuild: restore /etc/mock/**.rpmnew files automatically
4 years ago

What about: mv -f "${file%%.rpmnew}" "${file%%.rpmnew}.rpmsave" && mv -f "$file" "${file%%.rpmnew}"
I.e. backup the old one. In case, someone is running this on his workstation.

rebased onto c82d736

4 years ago

Good idea. I don't prefer .rpmsave since it looks like RPM created this itself.
So I picked different file extension... PTAL

Commit db27873 fixes this pull-request

Pull-Request has been merged by praiskup

4 years ago