Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding check_rpmspec_collection.sh #63

Merged
merged 1 commit into from
Apr 17, 2021
Merged

Conversation

nhosoi
Copy link
Contributor

@nhosoi nhosoi commented Apr 16, 2021

Description

  • Verify rpm package count with various combination of ansible and
    collection_artifact options.
  • Check there is no README.html files in /usr/share/andible/collections.

Usage: ./check_rpmspec_collection.sh [ -h | --help ] | [ fedpkg | rhpkg [ branch_name ] ]

@@ -0,0 +1,50 @@
#!/bin/bash

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use set -euo pipefail

exit 0
fi

if [ ! -f *.spec ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is more than one spec file you will get an error like this:

bash: [: another.spec: binary operator expected

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like this:

if ls -1 *.spec | wc -l | grep -q '^1$'; then
  echo good
else
  echo there must exactly 1 spec file in $(pwd)
  exit 1
fi

if there are no spec files the output looks like this:

ls: cannot access '*.spec': No such file or directory
there must exactly 1 spec file in /home/rmeggins/fedpkg/linux-system-roles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is more than one spec file you will get an error like this:

bash: [: another.spec: binary operator expected

Thanks for the solution. I was wondering if there were such case having multiple spec files (and hoping there isn't... :). But, there could be?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, there could be?

There should only ever be one file matching *.spec - so if you want to keep if [ -f *.spec ] that's fine - it should be pretty obvious to a developer what the problem is.

local option=$1
local ext=$2
local expect=$3
\rm -rf noarch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra backslash?

fi

filename=$( $pkgcmd --release $branch verrel )
rval=$( rpm -ql noarch/${filename}*.rpm | egrep '.html' | egrep collection | egrep -v '/usr/share/doc/' || : )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need rpm -qlp here? I guess rpm is now smart enough to know that the given argument is the name of a package filename instead of a package.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean fgrep (literal match e.g. match the literal . in .html instead of treating . as "match any char") here instead of egrep (extended regular expression match)?


filename=$( $pkgcmd --release $branch verrel )
rval=$( rpm -ql noarch/${filename}*.rpm | egrep '.html' | egrep collection | egrep -v '/usr/share/doc/' || : )
if [ "$rval" = "" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if rpm -ql noarch/${filename}*.rpm | egrep '.html' | egrep collection | egrep -v '/usr/share/doc/'; then
  echo FAILED - '.html' files are in noarch/${filename}*.rpm other than doc
else
  echo OK - '.html' files are only in doc in noarch/${filename}*.rpm
fi

@nhosoi nhosoi force-pushed the ah branch 2 times, most recently from 6b1e6b0 to 53fdb4c Compare April 16, 2021 22:28
@nhosoi nhosoi changed the title Adding check_rpmspec_collection.sh [WIP] - Adding check_rpmspec_collection.sh Apr 16, 2021
Description - Verify rpm package count with various combination of ansible and
              collection_artifact options.
            - Check there is no README.html files in /usr/share/andible/collections.
Usage: ./check_rpmspec_collection.sh [ -h | --help ] | [ fedpkg | rhpkg [ branch_name ] ]

Fixed the issues found in the review and tox -e shellcheck.
@nhosoi nhosoi changed the title [WIP] - Adding check_rpmspec_collection.sh Adding check_rpmspec_collection.sh Apr 16, 2021
Copy link
Contributor

@richm richm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@richm richm merged commit 24c3a71 into linux-system-roles:master Apr 17, 2021
@pcahyna
Copy link
Member

pcahyna commented Apr 18, 2021

What is the intended use of this tool? It seems that it makes plenty of restrictive assumptions about the build environment (only dist-git build supported).

@nhosoi
Copy link
Contributor Author

nhosoi commented Apr 19, 2021

What is the intended use of this tool? It seems that it makes plenty of restrictive assumptions about the build environment (only dist-git build supported).

That is correct. I'm going to use this script to verify the collection is properly packaged using the spec file. Luckily, the entire auto-maintenance is available in dist-git, I took advantage of it.

So far, it checks --with collection_artifact works as expected and README.html files are not included in the collection format. If necessary, e.g., we could add galaxy-importer to the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants