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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ linux-system-roles repos.
* [sync-template.sh](#sync-templatesh)
* [lsr_role2collection.py](#lsr_role2collectionpy)
* [release_collection.py](#release_collectionpy)
* [check_rpmspec_collection.sh](#check_rpmspec_collectionsh)
<!--te-->


Expand Down Expand Up @@ -451,7 +452,7 @@ For each repo, checkout the main branch and make sure it is up-to-date:
LSR_BASE_DIR=~/working-lsr ./local-repo-dev-sync.sh "git checkout main || git checkout master; git pull"
```

The arguments will be passed to `eval` to be evaulated in the context of each
The arguments will be passed to `eval` to be evaluated in the context of each
repo. This is useful if you need to just refresh your local copy of the repo,
or perform a very simple task in each repo.

Expand Down Expand Up @@ -518,3 +519,12 @@ EOF
```
If your `$USER` is not the same as your github username, use your github
username instead of `$USER`.

# check_rpmspec_collection.sh

This script is to be executed in the dist-git directory.
It locally builds rpm packages with various combination of `ansible` and `collection_artifact` options,
and checks whether the built rpm count is correct or not.
Then, it verifies that `README.html` files are only in /usr/share/doc/ area.

Usage: ./check_rpmspec_collection.sh [ -h | --help ] | [ fedpkg | rhpkg [ branch_name ] ]
51 changes: 51 additions & 0 deletions check_rpmspec_collection.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/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

if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Description - Verify rpm package count with various combination of ansible and collection_artifact options."
echo " - Check there is no README.html files in /usr/share/andible/collections."
echo "Usage: $0 [ -h | --help ] | [ fedpkg | rhpkg [ branch_name ] ]"
exit 0
fi

if [ "$( find . -maxdepth 1 -name '*.spec' | wc -l )" -ne 1 ]; then
echo There must exactly 1 spec file in "$( pwd )".
exit 1
fi

set -euo pipefail

pkgcmd=${1:-"fedpkg"}
branch=${2:-"rawhide"}
run() {
local option=$1
local ext=$2
local expect=$3
rm -rf noarch
output=/tmp/$pkgcmd.$ext
cmdline="$pkgcmd --release $branch local $option"
echo "$cmdline"
$cmdline > "$output" 2>&1
count=$( find noarch -name "*.rpm" | wc -l )
if [ "$count" -eq "$expect" ]; then
echo OK - result "$count" is "$expect"
else
echo FAILED - result "$count" is not "$expect"
fi

filename=$( "$pkgcmd" --release "$branch" verrel )
if rpm -qlp noarch/"${filename}"*.rpm | grep -F '.html' | grep collection | grep -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
}

run "--without ansible" "without_ansible" 1
run "--without ansible --with collection_artifact" "without_ansible-with_collection_artifact" 1
run "--without ansible --without collection_artifact" "without_ansible-without_collection_artifact" 1
run "--without collection_artifact" "without_collection_artifact" 1
run "--with ansbile --without collection_artifact" "with_ansible-without_collection_artifact" 1
run "" "no_opt" 1
run "--with ansbile" "with_ansible" 1
run "--with collection_artifact" "with_collection_artifact" 2
run "--with ansible --with collection_artifact" "with_ansible-with_collection_artifact" 2