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

Fix missing error when repo build script setup-repo.sh fails. #333

Merged
merged 1 commit into from
Jul 11, 2022
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
7 changes: 6 additions & 1 deletion pytests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ def __init__(self, cli_args=None):
self.config.update(cli_args)
self.config['distribution'] = os.environ.get('DIST', 'photon')
script = os.path.join(self.config['test_path'], 'repo/setup-repo.sh')
self.run(['sh', script, self.config['repo_path']])
ret = self.run(['sh', script, self.config['repo_path']])
if ret['retval']:
pytest.exit("An error occured while running {}, stdout: \n{}".format(
script,
"\n".join(ret['stdout'])
))
self.tdnf_config = configparser.ConfigParser()
self.tdnf_config.read(os.path.join(self.config['repo_path'],
'tdnf.conf'))
Expand Down
17 changes: 16 additions & 1 deletion pytests/repo/setup-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ if [ $# -ne 1 ]; then
exit 1
fi

fix_dir_perms()
function fix_dir_perms()
{
chmod 755 ${TEST_REPO_DIR}
find ${TEST_REPO_DIR} -type d -exec chmod 0755 {} \;
find ${TEST_REPO_DIR} -type f -exec chmod 0644 {} \;
}

## used to check return code for each command.
function check_err {
rc=$?
if [ $rc -ne 0 ]; then
echo $1
exit $rc
fi
}

TEST_REPO_DIR=$1
if [ -d $1 ]; then
echo "Repo already exists"
Expand Down Expand Up @@ -56,6 +65,7 @@ EOF
#generate a key non interactively. this is used in testing
#repogpgcheck plugin
gpg --batch --generate-key ${TEST_REPO_DIR}/gpgkeydata
check_err "Failed to generate gpg key."

cat << EOF > ~/.rpmmacros
%_gpg_name [email protected]
Expand All @@ -69,8 +79,10 @@ done
echo building packages
rpmbuild --define "_topdir ${BUILD_PATH}" \
-r ${BUILD_PATH} -ba ${REPO_SRC_DIR}/*.spec
check_err "Failed to build packages."
rpmsign --addsign ${BUILD_PATH}/RPMS/*/*.rpm
cp -r ${BUILD_PATH}/RPMS ${PUBLISH_PATH}
check_err "Failed to sign built packages."

# save key to later be imported:
mkdir -p ${PUBLISH_PATH}/keys
Expand All @@ -79,12 +91,15 @@ gpg --armor --export [email protected] > ${PUBLISH_PATH}/keys/pubkey.asc
createrepo ${PUBLISH_PATH} > /dev/null 2>&1

modifyrepo ${REPO_SRC_DIR}/updateinfo-1.xml ${PUBLISH_PATH}/repodata
check_err "Failed to modify repo with updateinfo-1.xml."
modifyrepo ${REPO_SRC_DIR}/updateinfo-2.xml ${PUBLISH_PATH}/repodata
check_err "Failed to modify repo with updateinfo-2.xml."

#gpg sign repomd.xml
gpg --batch --passphrase-fd 0 \
--pinentry-mode loopback \
--detach-sign --armor ${PUBLISH_PATH}/repodata/repomd.xml
check_err "Failed to gpg sign repomd.xml."

cat << EOF > ${TEST_REPO_DIR}/yum.repos.d/photon-test.repo
[photon-test]
Expand Down