#390 [F38] Make percentage signs escaping work with RPM 4.19 as well
Merged a year ago by churchyard. Opened a year ago by churchyard.
rpms/ churchyard/pyproject-rpm-macros rpm4.19  into  f38

file modified
+7
@@ -104,7 +104,14 @@ 

  %pyproject_extras_subpkg(n:i:f:F) %{expand:%{?python_extras_subpkg:%{python_extras_subpkg%{?!-i:%{?!-f:%{?!-F: -f %{_pyproject_ghost_distinfo}}}} %**}}}

  

  

+ # Escaping an actual percentage sign in path by 8 signs has been verified in RPM 4.16 and 4.17.

+ # See this thread http://lists.rpm.org/pipermail/rpm-list/2021-June/002048.html

+ # Since RPM 4.19, 2 signs are needed instead.

+ # On the CI, we build tests/escape_percentages.spec to verify the assumptions.

+ # We should check RPM version here instead of Fedora/RHEL, but it's hard;

+ # see https://github.com/rpm-software-management/rpm/issues/2523

  %pyproject_save_files() %{expand:\\\

+ %{expr:0%{?fedora} >= 39 || 0%{?rhel} >= 10 ? "RPM_PERCENTAGES_COUNT=2" : "RPM_PERCENTAGES_COUNT=8" } \\

  %{__python3} %{_rpmconfigdir}/redhat/pyproject_save_files.py \\

    --output-files "%{pyproject_files}" \\

    --output-modules "%{_pyproject_modules}" \\

@@ -163,6 +163,7 @@ 

  %changelog

  * Wed May 31 2023 Miro Hrončok <mhroncok@redhat.com> - 1.8.1-1

  - On Python older than 3.11, use tomli instead of deprecated toml

+ - Fix literal %% handling in %%{pyproject_files} on RPM 4.19

  

  * Tue May 23 2023 Miro Hrončok <mhroncok@redhat.com> - 1.8.0-2

  - Rebuilt for ELN dependency changes

file modified
+7 -7
@@ -12,6 +12,9 @@ 

  # From RPM's build/files.c strtokWithQuotes delim argument

  RPM_FILES_DELIMETERS = ' \n\t'

  

+ # See the comment in the macro that wraps this script

+ RPM_PERCENTAGES_COUNT = int(os.getenv('RPM_PERCENTAGES_COUNT', '2'))

+ 

  # RPM hardcodes the lists of manpage extensions and directories,

  # so we have to maintain separate ones :(

  # There is an issue for RPM to provide the lists as macros:
@@ -441,13 +444,13 @@ 

          '"/usr/lib/python3.9/site-packages/setuptools/script (dev).tmpl"'

  

          >>> escape_rpm_path('/usr/share/data/100%valid.path')

-         '/usr/share/data/100%%%%%%%%valid.path'

+         '/usr/share/data/100%%valid.path'

  

          >>> escape_rpm_path('/usr/share/data/100 % valid.path')

-         '"/usr/share/data/100 %%%%%%%% valid.path"'

+         '"/usr/share/data/100 %% valid.path"'

  

          >>> escape_rpm_path('/usr/share/data/1000 %% valid.path')

-         '"/usr/share/data/1000 %%%%%%%%%%%%%%%% valid.path"'

+         '"/usr/share/data/1000 %%%% valid.path"'

  

          >>> escape_rpm_path('/usr/share/data/spaces and "quotes"')

          Traceback (most recent call last):
@@ -461,10 +464,7 @@ 

      """

      orig_path = path = str(path)

      if "%" in path:

-         # Escaping by 8 %s has been verified in RPM 4.16 and 4.17, but probably not stable

-         # See this thread http://lists.rpm.org/pipermail/rpm-list/2021-June/002048.html

-         # On the CI, we build tests/escape_percentages.spec to verify this assumption

-         path = path.replace("%", "%" * 8)

+         path = path.replace("%", "%" * RPM_PERCENTAGES_COUNT)

      if any(symbol in path for symbol in RPM_FILES_DELIMETERS):

          if '"' in path:

              # As far as we know, RPM cannot list such file individually

file modified
+48 -8
@@ -1,5 +1,5 @@ 

  Name:           escape_percentages

- Version:        0

+ Version:        0.1

  Release:        0

  Summary:        ...

  License:        MIT
@@ -7,19 +7,59 @@ 

  

  %description

  This spec file verifies that escaping percentage signs in paths is possible via

- exactly 8 percentage signs in a filelist and directly in the %%files section.

+ exactly 2 (or 8) percentage signs in a filelist and directly in the %%files section.

  It serves as a regression test for pyproject_save_files:escape_rpm_path().

  When this breaks, the function needs to be adapted.

  

- %install

+ 

+ %prep

+ cat > pyproject.toml << EOF

+ [build-system]

+ requires = ["setuptools"]

+ build-backend = "setuptools.build_meta"

+ EOF

+ 

+ cat > setup.cfg << EOF

+ [metadata]

+ name = escape_percentages

+ version = 0.1

+ [options]

+ packages =

+     escape_percentages

+ [options.package_data]

+ escape_percentages =

+     *

+ EOF

+ 

+ mkdir -p escape_percentages

+ touch escape_percentages/__init__.py

  # the paths on disk will have 1 percentage sign if we type 2 in the spec

  # we use the word 'version' after the sign, as that is a known existing macro

- touch '%{buildroot}/one%%version'

+ touch 'escape_percentages/one%%version'

+ 

+ 

+ %generate_buildrequires

+ %pyproject_buildrequires

+ 

+ 

+ %build

+ %pyproject_wheel

+ 

+ 

+ %install

+ %pyproject_install

+ %pyproject_save_files escape_percentages

  touch '%{buildroot}/two%%version'

  

- # the filelist will contain 8 percentage signs when we type 16 in spec

- echo '/one%%%%%%%%%%%%%%%%version' > filelist

- test $(wc -c filelist | cut -f1 -d' ') -eq 20  # 8 signs + /one (4) + version (7) + newline (1)

  

- %files -f filelist

+ %check

+ grep '/escape_percentages/one' %{pyproject_files}

+ 

+ 

+ 

+ %files -f %{pyproject_files}

+ %if 0%{?fedora} >= 39 || 0%{?rhel} >= 10

+ /two%%version

+ %else

  /two%%%%%%%%version

+ %endif

file modified
+1 -1
@@ -93,7 +93,7 @@ 

          run: ./mocktest.sh python-virtualenv

      - escape_percentages:

          dir: .

-         run: rpmbuild -ba escape_percentages.spec

+         run: ./mocktest.sh escape_percentages

      required_packages:

      - mock

      - rpmdevtools

no initial comment

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/530f49e433ab425292c0232e43a27597

6 new commits added

  • Make percentage signs escaping work with RPM 4.19 as well
  • Bump the release for ELN dependency changes
  • Don't run tox tests on RHEL by default, as tox is unwanted in RHEL
  • Use lowercase tox in test case names, as upstream wants it
  • don't use pytest-xdist in RHEL
  • In %check, assert the two signatures of %pyproject_buildrequires match exactly
a year ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/ea71ba0944ad4df2a1dc4475bf0ebd54

1 new commit added

  • fixup! Make percentage signs escaping work with RPM 4.19 as well
a year ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/bfeb43d3d5864d2cb867aba4ea38d119

1 new commit added

  • Rework the escape_percentages.spec to actually run our code as well
a year ago

1 new commit added

  • fixup: don't render the comment in the parsed specfile
a year ago

1 new commit added

  • typo
a year ago

rebased onto d372624a24abc63ef55cf50f2e9762df848340a0

a year ago

rebased onto 02cd9a317bc5a4037c87b74c92be79f210fbdddc

a year ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/c615b9f641b54e6aa5e4c01d16a65a13

rebased onto 5ab7319

a year ago

rebased onto 31606d1eae0c34e5a46d4349a6000b8fbe9fc1b2

a year ago

rebased onto 5ab7319

a year ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/1ade4cad03444ff889a6bc2b90a8a1b6

rebased onto 638ba27

a year ago

Pull-Request has been merged by churchyard

a year ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/e8e1aec053af4cb59b7c05a99bfa63b1