#83 Remove all code unrelated to Fedora to simplify spec
Closed 2 years ago by spetros. Opened 2 years ago by spetros.
rpms/ spetros/linux-system-roles simplify-spec  into  rawhide

file modified
+77 -277
@@ -1,37 +1,10 @@ 

- # NOTE: Even though ansible-core is in 8.6, it is only available

- # at *runtime*, not at *buildtime* - so we can't have

- # ansible-core as a build_dep on RHEL8

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

- %bcond_without ansible

- %global ansible_build_dep ansible-core >= 2.11.0

- %else

- %if 0%{?rhel} && ! 0%{?epel}

- %bcond_with ansible

- %else

- %bcond_without ansible

- %global ansible_build_dep ansible >= 2.9.10

- %endif

- %endif

- 

  %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

  Name: linux-system-roles

- %endif

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

  Summary: Set of interfaces for unified system management

  Version: 1.21.1

- Release: 3%{?dist}

+ Release: 4%{?dist}

  

  #Group: Development/Libraries

  License: GPLv3+ and MIT and BSD and Python
@@ -41,60 +14,12 @@ 

  %global roleprefix %{name}.

  %global roleinstprefix %{nil}

  %global rolealtrelpath ../../linux-system-roles/

- %if 0%{?rhel}

- %global roleinstprefix %{roleprefix}

- %global installbase %{_datadir}/ansible/roles

- %global rolealtrelpath %{nil}

- %endif

  

- %if 0%{?rhel}

- %global collection_namespace redhat

- %global collection_name rhel_system_roles

- %else

  %global collection_namespace fedora

  %global collection_name linux_system_roles

- %endif

  

  %global collection_version %{version}

  

- # Helper macros originally from macros.ansible by Igor Raits <ignatenkobrain>

- # Not available on RHEL, so we must define those macros locally here without using ansible-galaxy

- 

- # Not used (yet). Could be made to point to AH in RHEL - but what about CentOS Stream?

- #%%{!?ansible_collection_url:%%define ansible_collection_url() https://galaxy.ansible.com/%%{collection_namespace}/%%{collection_name}}

- 

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

- %{!?ansible_collection_files:%define ansible_collection_files %{_datadir}/ansible/collections/ansible_collections/%{collection_namespace}/}

- %else

- # Define undefined macro using "!?ansible_collection_files:..." does not work for rhel-7

- %if %{?ansible_collection_files:0}%{!?ansible_collection_files:1}

- %define ansible_collection_files %{_datadir}/ansible/collections/ansible_collections/%{collection_namespace}/

- %endif

- %endif

- 

- # ansible-core is in rhel 8.6 and later - default to ansible-core, but allow

- # the use of ansible if present - we may revisit this if the automatic dependency

- # generator is added to ansible-core in RHEL

- # Fedora - the automatic generator will add this - no need to explicit declare

- # it in the spec file

- # EL7 - no dependency on ansible because there is no ansible in el7 - user is

- # responsible for knowing they have to install ansible

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

- Requires: (ansible-core >= 2.11.0 or ansible >= 2.9.0)

- %endif

- 

- %if %{with ansible}

- BuildRequires: %{ansible_build_dep}

- %endif

- 

- %if %{without ansible}

- # We don't have ansible-galaxy.

- # Simply copy everything instead of galaxy-installing the built artifact.

- %define ansible_collection_build_install() tar -cf %{_tmppath}/%{collection_namespace}-%{collection_name}-%{version}.tar.gz .; mkdir -p %{buildroot}%{ansible_collection_files}%{collection_name}; (cd %{buildroot}%{ansible_collection_files}%{collection_name}; tar -xf %{_tmppath}/%{collection_namespace}-%{collection_name}-%{version}.tar.gz)

- %else

- %define ansible_collection_build_install() ansible-galaxy collection build; ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz

- %endif

- 

  # For each role, call either defcommit() or deftag(). The other macros

  # (%%id and %%shortid) can be then used in the same way in both cases.

  # This way  the rest of the spec file des not need to know whether we are
@@ -245,78 +170,39 @@ 

  # only used on Fedora

  Source997: spec-to-changelog-md.sh

  

- # Script to convert the collection README to Automation Hub.

- # Not used on Fedora.

- Source998: collection_readme.sh

- 

  Patch51: network-disable-bondtests.diff

  

  BuildArch: noarch

  

- %if %{with html}

+ # Requirement for %%ansible_collection_build, %%ansible_collection_install, %%ansible_collection_files

+ BuildRequires: ansible-packaging

+ 

  # 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

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

  BuildRequires: %{py3_dist ruamel.yaml}

- %else

- BuildRequires: python3-ruamel-yaml

- %endif

  

  Obsoletes: rhel-system-roles-techpreview < 1.0-3

  

- %if %{undefined __ansible_provides}

- Provides: ansible-collection(%{collection_namespace}.%{collection_name}) = %{collection_version}

- %endif

- # be compatible with the usual Fedora Provides:

- Provides: ansible-collection-%{collection_namespace}-%{collection_name} = %{version}-%{release}

- 

- # We need to put %%description within the if block to avoid empty

- # lines showing up.

- %if 0%{?rhel}

- %description

- Collection of Ansible roles and modules that provide a stable and

- consistent configuration interface for managing multiple versions

- of Red Hat Enterprise Linux.

- %else

  %description

  Collection of Ansible roles and modules that provide a stable and

  consistent configuration interface for managing multiple versions

  of Fedora, Red Hat Enterprise Linux & CentOS.

- %endif

  

  %if %{with collection_artifact}

  %package collection-artifact

  Summary: Collection artifact to import to Automation Hub / Ansible Galaxy

  

  %description collection-artifact

- Collection artifact for %{name}. This package contains %{collection_namespace}-%{collection_name}-%{version}.tar.gz

+ Collection artifact for %{name}. This package contains

+ %{collection_namespace}-%{collection_name}-%{version}.tar.gz

  %endif

  

  %prep

  %setup -q -a1 -a2 -a3 -a4 -a5 -a6 -a7 -a8 -a9 -a10 -a11 -a12 -a13 -a14 -a15 -a16 -a17 -a18 -a19 -a20 -n %{getarchivedir 0}

  

- for file in %_sourcedir/*.tar.gz; do

-     if [[ "$file" =~ %_sourcedir/([^-]+)-([^-]+)-(.+).tar.gz ]]; then

-         ns=${BASH_REMATCH[1]}

-         name=${BASH_REMATCH[2]}

-         ver=${BASH_REMATCH[3]}

-         mkdir -p .external/$ns/$name

-         pushd .external/$ns/$name > /dev/null

-         tar xfz "$file"

-         popd > /dev/null

-     fi

- done

- 

  declare -A ROLESTODIR=(%{rolestodir})

  for rolename in %{rolenames}; do

      dir_from_archive="${ROLESTODIR[${rolename}]}"
@@ -364,67 +250,6 @@ 

  fi

  cd ..

  

- %if 0%{?rhel}

- # Unpack tar.gz to retrieve to be vendored modules and place them in the roles library.

- # ansible.posix:

- #   - library:

- #     - Module selinux and seboolean for the selinux role

- #     - Module mount for the storage role

- declare -A module_map=( ["selinux.py"]="selinux" ["seboolean.py"]="selinux"  ["mount.py"]="storage" )

- for module in "${!module_map[@]}"; do

-   role="${module_map[${module}]}"

-   if [ ! -d $role/library ]; then

-     mkdir $role/library

-   fi

-   cp -pL .external/ansible/posix/plugins/modules/$module $role/library/$module

-   sed -i -e ':a;N;$!ba;s/description:\n\( *\)/description:\n\1- WARNING: Do not use this module directly! It is only for role internal use.\n\1/' -e "s/ansible_collections.ansible.posix.plugins.module_utils/ansible.module_utils.${role}_lsr/" $role/library/$module

- done

- 

- # ansible.posix:

- #   - module_utils:

- #     - Module_util mount for the storage role

- module_map=( ["mount.py"]="storage" )

- for module in "${!module_map[@]}"; do

-   role="${module_map[${module}]}"

-   if [ ! -d $role/module_utils/${role}_lsr ]; then

-     mkdir -p $role/module_utils/${role}_lsr

-   fi

-   cp -pL .external/ansible/posix/plugins/module_utils/$module $role/module_utils/${role}_lsr/$module

-   sed -i -e ':a;N;$!ba;s/description:\n\( *\)/description:\n\1- WARNING: Do not use this module directly! It is only for role internal use.\n\1/' $role/library/$module

- done

- 

- # community.general:

- #   - library:

- #     - Module seport, sefcontext and selogin for the selinux role rolename2

- #     - Module ini_file for role tlog

- module_map=( ["seport.py"]="selinux" ["sefcontext.py"]="selinux"  ["selogin.py"]="selinux" ["ini_file.py"]="tlog" )

- for module in "${!module_map[@]}"; do

-   role="${module_map[${module}]}"

-   if [ ! -d $role/library ]; then

-     mkdir $role/library

-   fi

-   # version 5.x seems to be broken?

-   moduledir=.external/community/general/plugins/modules

-   if [ ! -f $moduledir/$module ]; then

-     moduledir=.external/community/general/plugins/modules/system

-   fi

-   if [ ! -f $moduledir/$module ]; then

-     moduledir=.external/community/general/plugins/modules/files

-   fi

-   cp -pL $moduledir/$module $role/library/$module

-   ls -alrtF $role/library/$module

-   sed -i -e ':a;N;$!ba;s/description:\n\( *\)/description:\n\1- WARNING: Do not use this module directly! It is only for role internal use.\n\1/' $role/library/$module

- done

- %endif

- 

- # Replacing "linux-system-roles.rolename" with "rhel-system-roles.rolename" in each role

- %if "%{roleprefix}" != "linux-system-roles."

- for rolename in %{rolenames}; do

-     find $rolename -type f -exec \

-          sed "s/linux-system-roles[.]${rolename}\\>/%{roleprefix}${rolename}/g" -i {} \;

- done

- %endif

- 

  # Removing symlinks in tests/roles

  for rolename in %{rolenames}; do

      if [ -d ${rolename}/tests/roles ]; then
@@ -437,6 +262,7 @@ 

  rm %{rolename5}/tests/modules

  rm %{rolename5}/tests/module_utils

  rm %{rolename5}/tests/playbooks/roles

+ 

  # Drop network/{scripts/print_all_options.py,tests/ensure_provider_tests.py}

  # from rpm. These 2 files fail in brp-python-bytecompile due to f-strings

  # when python2 is default python.
@@ -450,47 +276,28 @@ 

       sed -i -r -e '1s@^(#! */usr/bin/env python)(\s|$)@#\13\2@' '{}' +

  

  %build

- %if %{with html}

  readmes=""

  for role in %{rolenames}; do

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

  done

  sh md2html.sh $readmes

- %endif

  

  mkdir .collections

- %if 0%{?rhel}

- # Convert the upstream collection readme to the downstream one

- %{SOURCE998} lsr_role2collection/collection_readme.md

- ./galaxy_transform.py "%{collection_namespace}" "%{collection_name}" "%{collection_version}" \

-                       "Red Hat Enterprise Linux System Roles Ansible Collection" \

-                       "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" \

-                       > galaxy.yml.tmp

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

- rm -f lsr_role2collection/collection_requirements.txt

- # but leave bindep.txt

- %else

+ 

+ # Ensure correct values in galaxy.yml

  ./galaxy_transform.py "%{collection_namespace}" "%{collection_name}" "%{collection_version}" \

                        "Linux System Roles Ansible Collection" \

                        > galaxy.yml.tmp

- %endif

  mv galaxy.yml.tmp galaxy.yml

  

  includes=""

  for role in %{rolenames}; do

      includes="$includes --include $role"

- %if 0%{?rhel}

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

-     rm -f "$role/meta/requirements.yml" "$role/meta/collection-requirements.yml"

- %endif

  done

  

  LANG=en_US.utf-8 LC_ALL=en_US.utf-8 python3 release_collection.py --galaxy-yml galaxy.yml \

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

- 	--src-owner %{name} --skip-git --skip-check --debug

+     --src-owner %{name} --skip-git --skip-check --debug

  

  # Remove table of contents from logging README.md

  # It is not needed for html and AH/Galaxy
@@ -506,51 +313,49 @@ 

      .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/$role/README.md

  done

  

- %if 0%{?rhel}

- cp %{SOURCE996} \

-     .collections/ansible_collections/%{collection_namespace}/%{collection_name}/docs/CHANGELOG.md

- %else

  # Build the collection CHANGELOG.md

  %{SOURCE997} %{_specdir}/%{name}.spec \

      .collections/ansible_collections/%{collection_namespace}/%{collection_name}/docs/CHANGELOG.md

- %endif

+ 

+ # Build the collection

+ pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/

+ %ansible_collection_build

+ popd

  

  %install

- mkdir -p $RPM_BUILD_ROOT%{installbase}

- mkdir -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles

+ mkdir -p %{buildroot}%{installbase}

+ mkdir -p %{buildroot}%{_datadir}/ansible/roles

  

  for role in %{rolenames}; do

-     cp -pR "$role" "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role"

+     cp -pR "$role" "%{buildroot}%{installbase}/%{roleinstprefix}$role"

  done

  

  %if 0%{?rolealtprefix:1}

  for role in %{rolenames}; do

-     ln -s    "%{rolealtrelpath}%{roleinstprefix}$role"   "$RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}$role"

+     ln -s    "%{rolealtrelpath}%{roleinstprefix}$role"   "%{buildroot}%{_datadir}/ansible/roles/%{rolealtprefix}$role"

  done

  %endif

  

- mkdir -p $RPM_BUILD_ROOT%{_pkglicensedir}

- rm $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/roles

+ mkdir -p %{buildroot}%{_pkglicensedir}

+ rm %{buildroot}%{installbase}/%{roleinstprefix}network/examples/roles

  for role in %{rolenames}; do

-     mkdir -p "$RPM_BUILD_ROOT%{_pkgdocdir}/$role"

-     cp -p "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/CHANGELOG.md" \

-        "$RPM_BUILD_ROOT%{_pkgdocdir}/$role"

-     cp -p "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/README.md" \

-        "$RPM_BUILD_ROOT%{_pkgdocdir}/$role"

- %if %{with html}

-     cp -p "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/README.html" \

-        "$RPM_BUILD_ROOT%{_pkgdocdir}/$role"

- %endif

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

-         cp -p "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/COPYING" \

-            "$RPM_BUILD_ROOT%{_pkglicensedir}/$role.COPYING"

+     mkdir -p "%{buildroot}%{_pkgdocdir}/$role"

+     cp -p "%{buildroot}%{installbase}/%{roleinstprefix}$role/CHANGELOG.md" \

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

+     cp -p "%{buildroot}%{installbase}/%{roleinstprefix}$role/README.md" \

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

+     cp -p "%{buildroot}%{installbase}/%{roleinstprefix}$role/README.html" \

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

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

+         cp -p "%{buildroot}%{installbase}/%{roleinstprefix}$role/COPYING" \

+            "%{buildroot}%{_pkglicensedir}/$role.COPYING"

      fi

-     if [ -f "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/LICENSE" ]; then

-         cp -p "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/LICENSE" \

-            "$RPM_BUILD_ROOT%{_pkglicensedir}/$role.LICENSE"

+     if [ -f "%{buildroot}%{installbase}/%{roleinstprefix}$role/LICENSE" ]; then

+         cp -p "%{buildroot}%{installbase}/%{roleinstprefix}$role/LICENSE" \

+            "%{buildroot}%{_pkglicensedir}/$role.LICENSE"

      fi

-     if [ -d "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples" ]; then

-         for file in "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples/"*.yml ; do

+     if [ -d "%{buildroot}%{installbase}/%{roleinstprefix}$role/examples" ]; then

+         for file in "%{buildroot}%{installbase}/%{roleinstprefix}$role/examples/"*.yml ; do

              basename=$(basename "$file" .yml)

              newname="$basename"

              if [[ "$newname" != example-* ]]; then
@@ -559,75 +364,74 @@ 

              if [[ "$newname" != *-playbook ]]; then

                  newname="${newname}-playbook"

              fi

-             cp "$file" "$RPM_BUILD_ROOT%{_pkgdocdir}/$role/${newname}.yml"

+             cp "$file" "%{buildroot}%{_pkgdocdir}/$role/${newname}.yml"

              rm "$file"

          done

-         if [ -f "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples/inventory" ]; then

-             cp "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples/inventory" \

-                "$RPM_BUILD_ROOT%{_pkgdocdir}/$role/example-inventory"

-             rm "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples/inventory"

+         if [ -f "%{buildroot}%{installbase}/%{roleinstprefix}$role/examples/inventory" ]; then

+             cp "%{buildroot}%{installbase}/%{roleinstprefix}$role/examples/inventory" \

+                "%{buildroot}%{_pkgdocdir}/$role/example-inventory"

+             rm "%{buildroot}%{installbase}/%{roleinstprefix}$role/examples/inventory"

          fi

          # special case for network

          # this will error if the directory is unexpectedly empty

-         rmdir "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples"

+         rmdir "%{buildroot}%{installbase}/%{roleinstprefix}$role/examples"

      fi

  done

  

- rm $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/semaphore

- rm -r $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/molecule

+ rm %{buildroot}%{installbase}/%{roleinstprefix}*/semaphore

+ rm -r %{buildroot}%{installbase}/%{roleinstprefix}*/molecule

  

- rm -r $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/.[A-Za-z]*

- rm $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/tests/.git*

+ # removing dot files/dirs

+ rm -r %{buildroot}%{installbase}/%{roleinstprefix}*/.[A-Za-z]*

+ rm %{buildroot}%{installbase}/%{roleinstprefix}*/tests/.git*

  

  # NOTE: sshd/examples/example-root-login.yml is

  # referenced in the configuring-openssh-servers-using-the-sshd-system-role documentation module

  # must be updated if changing the file path

  

  pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/

- %ansible_collection_build_install

+ %ansible_collection_install

  popd

  

- mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection

- mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles

+ mkdir -p %{buildroot}%{_pkgdocdir}/collection

+ mkdir -p %{buildroot}%{_pkgdocdir}/collection/roles

  

  cp -p %{buildroot}%{ansible_collection_files}%{collection_name}/README.md \

-    $RPM_BUILD_ROOT%{_pkgdocdir}/collection

+    %{buildroot}%{_pkgdocdir}/collection

  

  for rolename in %{rolenames}; do

    for file in CHANGELOG.md README.md; do

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

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

-         mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles/${rolename}

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

+         mkdir -p %{buildroot}%{_pkgdocdir}/collection/roles/${rolename}

        fi

        cp -p %{buildroot}%{ansible_collection_files}%{collection_name}/roles/${rolename}/$file \

-         $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles/${rolename}

+         %{buildroot}%{_pkgdocdir}/collection/roles/${rolename}

      fi

    done

  done

  

- %if %{with html}

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

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

+ # 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} $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles/${role}/README.md"

+     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}/

  if [ -f %{collection_namespace}-%{collection_name}-%{version}.tar.gz ]; then

      mv %{collection_namespace}-%{collection_name}-%{version}.tar.gz \

-        $RPM_BUILD_ROOT%{_datadir}/ansible/collections/

+        %{buildroot}%{_datadir}/ansible/collections/

  fi

  popd

  %endif

  

- # generate the %files section in the file files_section.txt

+ # generate the %%files section in the file files_section.txt

  format_item_for_files() {

      # $1 is directory or file name in buildroot

-     # $2 - if true, and item is a directory, use %dir

+     # $2 - if true, and item is a directory, use %%dir

      local item

      local files_item

      item="$1"
@@ -644,7 +448,7 @@ 

          fi

      elif [[ "$item" == */README.md ]] || [[ "$item" == */README.html ]] || [[ "$item" == */CHANGELOG.md ]]; then

          if [[ "$item" == */private_* ]]; then

-             # mark as regular file, not %doc

+             # mark as regular file, not %%doc

              echo "$files_item"

          else

              echo "%doc $files_item"
@@ -659,10 +463,6 @@ 

  files_section=files_section.txt

  rm -f $files_section

  touch $files_section

- %if %{without ansible}

- echo '%dir %{_datadir}/ansible' >> $files_section

- echo '%dir %{_datadir}/ansible/roles' >> $files_section

- %endif

  %if "%{installbase}" != "%{_datadir}/ansible/roles"

  echo '%dir %{installbase}' >> $files_section

  %endif
@@ -714,32 +514,16 @@ 

  %files -f files_section.txt

  %{_pkgdocdir}/*/CHANGELOG.md

  %{_pkgdocdir}/*/README.md

- %if %{with html}

  %{_pkgdocdir}/*/README.html

- %endif

  %{_pkgdocdir}/*/example-*

  %{_pkgdocdir}/collection/roles/*/CHANGELOG.md

  %{_pkgdocdir}/collection/roles/*/README.md

- %if %{with html}

  %{_pkgdocdir}/collection/roles/*/README.html

- %endif

  %license %{_pkglicensedir}/*

  %license %{installbase}/*/COPYING*

  %license %{installbase}/*/LICENSE*

  %license %{ansible_collection_files}/%{collection_name}/COPYING*

  %license %{ansible_collection_files}/%{collection_name}/LICENSE*

- %if 0%{?rhel} < 8

- # Needs to list excluded files in this hardcoded style since when

- # format_item_for_files is executed, brp-python-bytecompile is not

- # executed yet.

- %exclude %{installbase}/*/*.py?

- %exclude %{installbase}/*/*/*.py?

- %exclude %{installbase}/*/*/*/*.py?

- %exclude %{installbase}/*/*/*/*/*.py?

- %exclude %{ansible_collection_files}/%{collection_name}/*/*/*.py?

- %exclude %{ansible_collection_files}/%{collection_name}/*/*/*/*.py?

- %exclude %{ansible_collection_files}/%{collection_name}/*/*/*/*/*.py?

- %endif

  

  %if %{with collection_artifact}

  %files collection-artifact
@@ -747,6 +531,22 @@ 

  %endif

  

  %changelog

+ * Tue Sep 27 2022 Sergei Petrosian <spetrosi@redhat.com> - 1.21.1-4

+ - Remove all code unrelated to Fedora to simplify spec

+   - Remove bcond_with ansible because Fedora always have ansible

+   - Remove %bcond_with html because Fedora always can convert md to html

+   - Remove conditions related to RHEL

+   - Replace ansible_collection_build_install with biult-in build & install

+   - Remove unrelated to Fedora Provides

+   - 's|$RPM_BUILD_ROOT|%{buildroot}|g' for consistency

+   - Remove untaring collection tarballs

+     - It is not used on Fedora

+     - It uses problematic %_sourcedir

+       https://fedoraproject.org/wiki/Packaging:RPM_Source_Dir

+   - rpmlint fixes: use %% in comments, replace tab with spaces

+   - Remove unused macros, add BuildRequires: ansible-packaging

+   Resolves: rhbz#https://bugzilla.redhat.com/show_bug.cgi?id=2126902

+ 

  * Thu Sep 15 2022 Sergei Petrosian <spetrosi@redhat.com> - 1.21.1-3

  - Update community.general

  

  • Remove bcond_with ansible because Fedora always have ansible
  • Remove %bcond_with html because Fedora always can convert md to html
  • Remove conditions related to RHEL
  • Replace ansible_collection_build_install with biult-in build & install
  • Remove unrelated to Fedora Provides
  • 's|$RPM_BUILD_ROOT|%{buildroot}|g' for consistency
  • Remove untaring collection tarballs
  • It is not used on Fedora
  • It uses problematic %_sourcedir
    https://fedoraproject.org/wiki/Packaging:RPM_Source_Dir
  • rpmlint fixes: use %% in comments, replace tab with spaces
  • Remove unused macros, add BuildRequires: ansible-packaging
    Resolves: rhbz#https://bugzilla.redhat.com/show_bug.cgi?id=2126902

10 new commits added

  • Add changelog entry, bump release
  • Remove unused macros, add BuildRequires: ansible-packaging
  • rpmlint fixes: use %% in comments, replace tab with spaces
  • Remove untaring collection tarballs
  • 's|$RPM_BUILD_ROOT|%{buildroot}|g' for consistency
  • Remove unrelated to Fedora Provides
  • Replace ansible_collection_build_install with biult-in build & install
  • Remove conditions related to RHEL
  • Remove %bcond_with html because Fedora always can convert md to html
  • Remove bcond_with ansible because Fedora always have ansible
2 years ago

Hi @gotmax23, this PR addresses https://bugzilla.redhat.com/show_bug.cgi?id=2126902
I have read through the discussion in linux-system-roles bug and tried to apply your suggestions here. Please review when you have time and let me know what you think.
Thank you

Thank you! This is on my radar; I'll get to it soon.

Thanks again for working on this! Here's some feedback.

#Group: Development/Libraries

This can be removed completely. Group: is forbidden in Fedora.

Does everything still need to be installed to %{_datadir}/linux-system-roles?

Can we get rid of

%if 0%{?rolealtprefix:1}
for role in %{rolenames}; do
    ln -s    "%{rolealtrelpath}%{roleinstprefix}$role"   "%{buildroot}%{_datadir}/ansible/roles/%{rolealtprefix}$role"
done
%endif

and install everything directly into %{ansible_roles_dir}?

What is the point of all the format_item_for_files logic? Can't the %files section just be

%files -f %{ansible_collection_filelist}
%{_pkgdocdir}
%license %{_pkglicensedir}
%{ansible_roles_dir}/linux-system-roles.*
# Ideally, we could get rid of the symlink and drop this line
%{_datadir}/linux-system-roles

I am not sure marking all of the duplicate READMEs and license files with %doc/%license is worth the complication it adds. In fact, I'd suggest removing the duplicates and consolidating everything in /usr/share/docs and /usr/share/licenses.


%if 0%{?rhel}
# Collection tarballs from Automation Hub
# Not used on Fedora.
Source801: ansible-posix-1.4.0.tar.gz

# Collection tarballs from Galaxy
# Not used on Fedora.
Source901: community-general-5.6.0.tar.gz

# changelog is auto generated on Fedora
Source996: CHANGELOG.md
%endif

This can be entirely removed from the Fedora specfile.

Obsoletes: rhel-system-roles-techpreview < 1.0-3

This too.

%if %{with collection_artifact}
# Copy collection artifact to /usr/share/ansible/collections/ for collection-artifact
pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
if [ -f %{collection_namespace}-%{collection_name}-%{version}.tar.gz ]; then
    mv %{collection_namespace}-%{collection_name}-%{version}.tar.gz \
       %{buildroot}%{_datadir}/ansible/collections/
fi
popd
%endif

Is wrapping this in if [ -f %{collection_namespace}-%{collection_name}-%{version}.tar.gz ] really necessary?

I realized there was a mistake in one of my comments. Let me look over this again before you apply my feedback.

Okay, I've fixed my feedback.

and install everything directly into %{ansible_roles_dir}?

For Fedora, yes - we don't need the symlinks on Fedora - they are for RHEL where we want to provide the roles as both rhel-system-roles.NAME and linux-system-roles.NAME, to ease the migration for users who may have developed their playbooks using linux-system-roles and want to use rhel-system-roles instead.

What is the point of all the format_item_for_files logic? Can't the %files section just be

The problem is that some of the items under %{ansible_roles_dir}/linux-system-roles.* are docs, and we really want the doc items marked with %doc (in fact there was a bz quite some time ago from a user who was not happy that things like README.md were not marked as %doc).

Is wrapping this in if [ -f %{collection_namespace}-%{collection_name}-%{version}.tar.gz ] really necessary?

probably not

What is the point of all the format_item_for_files logic? Can't the %files section just be

The problem is that some of the items under %{ansible_roles_dir}/linux-system-roles.* are docs, and we really want the doc items marked with %doc (in fact there was a bz quite some time ago from a user who was not happy that things like README.md were not marked as %doc).

What about consolidating everything in %{_docdir} then? If that's not desired, I think we can at least the simplify the logic. I'll stare at it more and try to propose a solution.

What about consolidating everything in %{_docdir} then? If that's not desired, I think we can at least the simplify the logic. I'll stare at it more and try to propose a solution.

I think that would work, but wouldn't that just push the format_item_for_files logic elsewhere? I mean, we would still be iterating all of the files and determining which ones to keep, move, or remove?

What about consolidating everything in %{_docdir} then? If that's not desired, I think we can at least the simplify the logic. I'll stare at it more and try to propose a solution.

I think that would work, but wouldn't that just push the format_item_for_files logic elsewhere? I mean, we would still be iterating all of the files and determining which ones to keep, move, or remove?

It looks like the READMEs, changelog, and licenses are already being copied to %{_pkgdocdir}. Couldn't we have that section move instead of copy those files.

Take the certificate role README as an example. Currently, it's installed in:

1cff3c2fdb807d4d9d5072eccd1382de  /usr/share/ansible/collections/ansible_collections/fedora/linux_system_roles/docs/README_certificate.md
9085658c09571b584b09090233b565cc  /usr/share/doc/linux-system-roles/certificate/README.md
9085658c09571b584b09090233b565cc  /usr/share/linux-system-roles/certificate/README.md
fd68fbc1ba5eaefef735fee1fd3b3c9f  /usr/share/ansible/collections/ansible_collections/fedora/linux_system_roles/roles/certificate/README.md
fd68fbc1ba5eaefef735fee1fd3b3c9f  /usr/share/doc/linux-system-roles/collection/roles/certificate/README.md

I don't think it makes sense to install each README variant for each role to two different places. It just wastes space.

I don't think it makes sense to install each README variant for each role to two different places. It just wastes space.

I agree.

Closing, working in #84 instead.

Pull-Request has been closed by spetros

2 years ago
Metadata