Skip to content

Commit

Permalink
Merge pull request #333 from prestonsn/missing-error-build-script
Browse files Browse the repository at this point in the history
Fix missing error when repo build script setup-repo.sh fails.
  • Loading branch information
oliverkurth authored Jul 11, 2022
2 parents 895d348 + 4912399 commit e5044ff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
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

0 comments on commit e5044ff

Please sign in to comment.