#300 Draft: Remove with_html, instead use built-in .README.html
Merged 9 months ago by spetros. Opened 9 months ago by spetros.
rpms/ spetros/linux-system-roles remove-readmehtml-conversion  into  rawhide

file modified
+1
@@ -573,3 +573,4 @@ 

  /timesync-1.7.7.tar.gz

  /kdump-1.3.8.tar.gz

  /ansible-sshd-v0.21.0.tar.gz

+ /auto-maintenance-eadd06cfa98d244b096cff24cd11b668428b1613.tar.gz

file modified
+39 -57
@@ -11,14 +11,6 @@ 

  

  %bcond_with collection_artifact

  

- %if 0%{?fedora} || 0%{?rhel} >= 8

- %bcond_without html

- %else

- # pandoc is not supported in rhel 7 and older,

- # which is needed for converting .md to .html.

- %bcond_with html

- %endif

- 

  %if 0%{?rhel}

  Name: rhel-system-roles

  %else
@@ -27,7 +19,7 @@ 

  Url: https://github.com/linux-system-roles

  Summary: Set of interfaces for unified system management

  Version: 1.54.0

- Release: 1%{?dist}

+ Release: 2%{?dist}

  

  License: GPLv3+ and MIT and BSD and Python

  %global _pkglicensedir %{_licensedir}/%{name}
@@ -86,7 +78,7 @@ 

  %%global rolestodir %%{?rolestodir} %%{roletodir%{1}}

  }

  

- %global mainid 5fa4921e5761565890f69f8f9bab2ef2cbc5bb8f

+ %global mainid eadd06cfa98d244b096cff24cd11b668428b1613

  Source: %{url}/auto-maintenance/archive/%{mainid}/auto-maintenance-%{mainid}.tar.gz

  

  # BEGIN AUTOGENERATED SOURCES
@@ -219,17 +211,6 @@ 

  

  BuildArch: noarch

  

- %if %{with html}

- # Requirements for md2html.sh to build the documentation

- %if 0%{?fedora} || 0%{?rhel} >= 9

- BuildRequires: rubygem-kramdown-parser-gfm

- %else

- BuildRequires: pandoc

- BuildRequires: asciidoc

- BuildRequires: highlight

- %endif

- %endif

- 

  # Requirements for galaxy_transform.py

  BuildRequires: python3

  BuildRequires: python%{python3_pkgversion}-ruamel-yaml
@@ -295,6 +276,8 @@ 

          fi

      fi

      mv "$dir_from_archive" ${rolename}

+     # Move a hidden .README.html to a not hidden README.html

+     mv $rolename/.README.html $rolename/README.html

  done

  

  %if 0%{?rhel}
@@ -312,7 +295,7 @@ 

       -e "s/ansible-sshd/linux-system-roles.sshd/" \

       -e "s/ willshersystems.sshd/ linux-system-roles.sshd/" "$file"

  done

- sed -r -i -e "s/ willshersystems.sshd/ linux-system-roles.sshd/" README.md

+ sed -r -i -e "s/ willshersystems.sshd/ linux-system-roles.sshd/" README.md README.html

  sed -r -i -e 's/min_ansible_version: 2.8/min_ansible_version: "2.9"/' meta/main.yml

  cd ..

  
@@ -363,29 +346,43 @@ 

  # remove upstream-only documentation - for example, documentation

  # about collection dependencies is not needed in Fedora and EL RPMs

  # since the dependencies are already provided

- sed -e '/^## Requirements/,/^#/s/^See below$/None/' \

-     -e '/^### Collection requirements/,/^#/ {/^### Collection/d;/^#/!d}' \

+ sed -e '/# Requirements/,/^#/s/^See below$/None/' \

+     -e '/# Collection requirements/,/^#/ {/# Collection requirements/d;/^#/!d}' \

      -i */README.md

+ sed -e '/id="requirements">Requirements<\/h/,/^<h/s/See below/None/' \

+     -e '/id="collection-requirements">/,/^<h/ {/id="collection-requirements">/d;/^<h/!d}' \

+     -i */README.html

+ 

+ for role in %{rolenames}; do

+     # awk: Remove collection-requirements from README.html TOC

+     # 1. If match found, add the line and -2,+1 lines' line number in an array "d".

+     # 2. Save all lines in an array with line number as index

+     # 3. Print only those index not in array "d"

+     awk '/id="toc-collection-requirements">/{for(x=NR-2;x<=NR+1;x++)d[x];} \

+         {a[NR]=$0} \

+         END{for(i=1;i<=NR;i++)if(!(i in d))print a[i]}' \

+         $role/README.html > $role/README.html.tmp

+     mv $role/README.html.tmp $role/README.html

+ done

+ 

  # sshd README is not in the same format

- sed -e '/^### Optional requirements/,/^Role variables/ {/^### Optional/d;/^Role variables/!d}' \

+ sed -e '/# Optional requirements/,/# Role variables/ {/# Optional/d;/# Role variables/!d}' \

      -i sshd/README.md

+ sed -e '/id="optional-requirements">/,/^<h/ {/id="optional-requirements">/d;/^<h/!d}' \

+     -i sshd/README.html

+ # Remove optional-requirements from README.html TOC

+ awk '/id="toc-optional-requirements">/{for(x=NR-2;x<=NR+1;x++)d[x];} \

+     {a[NR]=$0} \

+     END{for(i=1;i<=NR;i++)if(!(i in d))print a[i]}' \

+     sshd/README.html > sshd/README.html.tml

+ mv sshd/README.html.tml sshd/README.html

  

- 

- %if %{with html}

- # HACK HACK HACK

- # pandoc/asciidoc on rhel 8.9 does not like the journald README badge links

- # remove all of the badge links from all README.md files

- # in the first 14 lines of the file, remove any line that looks like a

- # github action badge

- # HACK HACK HACK

- readmes=""

  matchstr="actions/workflows/"

  for role in %{rolenames}; do

+     # in the first 14 lines of README.md, remove any line that looks like a

+     # github action badge. README.html doesn't have these lines.

      sed -e "1,14 {\\,${matchstr},d; /\!\[/d}" -i $role/README.md

-     readmes="${readmes} $role/README.md"

  done

- sh md2html.sh $readmes

- %endif

  

  mkdir .collections

  %if 0%{?rhel}
@@ -396,7 +393,7 @@ 

                        "https://linux-system-roles.github.io" \

                        "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/administration_and_configuration_tasks_using_system_roles_in_rhel" \

                        "https://access.redhat.com/articles/3050101" \

-                       "https://bugzilla.redhat.com/enter_bug.cgi?product=Red%20Hat%20Enterprise%20Linux%208&component=rhel-system-roles" \

+                       "https://issues.redhat.com/secure/CreateIssueDetails!init.jspa?pid=12332745&summary=Your%20request%20summary&issuetype=1&priority=10200&labels=Partner-Feature-Request&components=12380283" \

                        > galaxy.yml.tmp

  # we vendor-in all of the dependencies on rhel, so remove them

  rm -f lsr_role2collection/collection_requirements.txt
@@ -428,13 +425,6 @@ 

      --src-path $(pwd) --dest-path $(pwd)/.collections $includes --force --no-update \

      --src-owner %{name} --skip-git --skip-check --skip-changelog $extra_mapping --debug

  

- # Remove table of contents from logging README.md

- # It is not needed for html and AH/Galaxy

- sed -i -e 's/^\(## Table of Contents\)/## Background\n\1/' \

-   .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/logging/README.md

- sed -i -e '/^## Table of Contents/,/^## Background/d' \

-   .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/logging/README.md

- 

  # Remove internal links from readme files

  # They are not rendered properly on AH.

  for role in %{rolenames}; do
@@ -483,10 +473,8 @@ 

         "%{buildroot}%{_pkgdocdir}/$role"

      ln -sr "%{buildroot}%{ansible_roles_dir}/%{roleinstprefix}$role/README.md" \

         "%{buildroot}%{_pkgdocdir}/$role"

- %if %{with html}

      ln -sr "%{buildroot}%{ansible_roles_dir}/%{roleinstprefix}$role/README.html" \

         "%{buildroot}%{_pkgdocdir}/$role"

- %endif

      if [ -f "%{buildroot}%{ansible_roles_dir}/%{roleinstprefix}$role/COPYING" ]; then

          ln -sr "%{buildroot}%{ansible_roles_dir}/%{roleinstprefix}$role/COPYING" \

             "%{buildroot}%{_pkglicensedir}/$role.COPYING"
@@ -545,7 +533,7 @@ 

     %{buildroot}%{_pkgdocdir}/collection

  

  for rolename in %{rolenames}; do

-   for file in CHANGELOG.md README.md; do

+   for file in CHANGELOG.md README.md README.html; do

      if [ -f %{buildroot}%{ansible_collection_files}%{collection_name}/roles/${rolename}/$file ]; then

        if [ ! -d %{buildroot}%{_pkgdocdir}/collection/roles/${rolename} ]; then

          mkdir -p %{buildroot}%{_pkgdocdir}/collection/roles/${rolename}
@@ -556,15 +544,6 @@ 

    done

  done

  

- %if %{with html}

- # converting README.md to README.html for collection in %%{buildroot}%%{_pkgdocdir}/collection

- readmes="%{buildroot}%{_pkgdocdir}/collection/README.md"

- for role in %{rolenames}; do

-     readmes="${readmes} %{buildroot}%{_pkgdocdir}/collection/roles/${role}/README.md"

- done

- sh md2html.sh $readmes

- %endif

- 

  %if %{with collection_artifact}

  # Copy collection artifact to /usr/share/ansible/collections/ for collection-artifact

  pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
@@ -666,6 +645,9 @@ 

  %endif

  

  %changelog

+ * Fri Sep 15 2023 Sergei Petrosian <spetrosi@redhat.com> - 1.54.0-2

+ - Remove with_html, instead use built-in .README.html

+ 

  * Thu Sep  14 2023 Packit <hello@packit.dev> - 1.54.0-1

  - Update to upstream version 1.54.0

  

file modified
+1 -1
@@ -1,4 +1,4 @@ 

- SHA512 (auto-maintenance-5fa4921e5761565890f69f8f9bab2ef2cbc5bb8f.tar.gz) = 0ced8ff82ee5cb0f2d918bc0d75a846934f03074f1cfb6af79ae9fd9ec87afdfc699d5f08d8c369540146a0729848cee06c8c3dfd8f7eacf7d972eb255fb8e9c

+ SHA512 (auto-maintenance-eadd06cfa98d244b096cff24cd11b668428b1613.tar.gz) = 0e5e45f8d7a05a4fee7916edb5628cdb105bab9f7770bb752fd229d13ea0d586b2938d8de5d60c14b2ff9d28d5f1bca7201b6197abf2af1e223404f0a8742068

  SHA512 (postfix-1.3.9.tar.gz) = 34ae431a8a73ee6eec35a50a8845c10ca5d2eec82d5181416a4c86838b22ad777ce2913540fb0c40ab7e899946bca09d950912a3453589505cda194ebcfdf3c5

  SHA512 (selinux-1.6.2.tar.gz) = f36be0ed11f857933d176df1b6d68e926da0072a5b31b84b2ea857059e839da2f3b5aeda157a6e6bcce2ceea66642d30fa682f654ebecdca34445d54c358fcb1

  SHA512 (timesync-1.7.7.tar.gz) = 9446bea552ce4c7c794671440b72c692b3c7326a0e1d606dc43f928e1b18fadbc6bffc63ceb93abf891e8833ed7e790a6efe66688dc41126bc95323560b078aa

This depends on https://github.com/linux-system-roles/auto-maintenance/pull/297. Timesync and sshd doesn't have .README.html yet.

rebased onto 0c98155db142cb0bf5f5a241e531526a421e16a5

9 months ago

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

I guess we can keep this - but the main reason was because it made the md -> html conversion difficult, which is no longer a problem.

On second thought, maybe we should keep this code - remove the badges for Automation Hub - not sure if AH renders the badges correctly.

Maybe we still need this for Automation Hub?

I guess we can keep this - but the main reason was because it made the md -> html conversion difficult, which is no longer a problem.

On second thought, maybe we should keep this code - remove the badges for Automation Hub - not sure if AH renders the badges correctly.

AH does render them properly, but AH docs should not link to upstream badges. And the badges are clickable images that link to upstream checks. They are easy to remove, so yes we can keep this. I am now trying to use sed to remove upstream requirements from .README.html.

Maybe we still need this for Automation Hub?

I removed table of contents from logging's README.md. Maintaining TOC in markdown is problematic.

rebased onto 64a56136d3eaaed75b185356bb8a3af86c09db10

9 months ago

@rmeggins ready for your review. I removed conditionals like if [ -f README.html ] because we from now on should treat README.html the same way as README.md - README.html should always be present and if it's not the build must fail.
I also replicated sed commands to remove upstream requirements for README.html. Needed to add an awk command to remove the requirements' entry from the TOC.
The command should do this:

 <li><a href="#limitations" id="toc-limitations">Limitations</a></li>
 <li><a href="#requirements" id="toc-requirements">Requirements</a>
-<ul>
-<li><a href="#collection-requirements"
-id="toc-collection-requirements">Collection requirements</a></li>
-</ul></li>
 <li><a href="#role-variables" id="toc-role-variables">Role Variables</a>
 <ul>
 <li><a href="#defined-in-defaultsmainyml"

I was not able to do this with sed, I came up with the following:
sed -i -e '/<a href="#collection-requirements"/,/^<li>/ {/<a href="#collection-requirements"/d;/^<li>/!d}' .README.html
It would almost do the job, but it won't remove the line above the match with <a href="#collection-requirements", which is <ul> that intends the list and breaks rendering if persists. And awk works fine because it removes n lines preceding and following the match. The one drawback is that I needed to do awk in a loop to first create .tmp and them move .tmp to the original file because it didn't work in-place for me. Using awk -i inplace ... leaves an empty file.

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/8615cf5cf3304ba6865ddffa8fb53969

rebased onto fab7c0ee2a0a17894fdfefd7a280d15a3af34a86

9 months ago

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

rebased onto 82f1e85

9 months ago

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

Pull-Request has been merged by spetros

9 months ago