openqa-testrepos/tools/testpackages9

80 lines
2.9 KiB
Text
Raw Permalink Normal View History

2023-12-29 20:18:06 +00:00
#!/usr/bin/env python3
# Copyright Red Hat
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Author: Adam Williamson <awilliam@redhat.com>
# Modifications: Trevor Cooper <tcooper@rockylinux.org>
# Original Source: https://pagure.io/fedora-qa/qa-misc/blob/master/f/testpackages
# Script to create test packages and repos (currently, a single repo
# containing a fake acpica-tools package) for openQA package
# management testing.
import os
import shutil
import sys
import rpmfluff
import rpmfluff.yumrepobuild
# The concept behind using a fake (low-versioned) acpica-tools is
# so we can test updating from the official repos. It gives us a 99%
# assurance we have a package we will be able to update, as it's a
# very simple package that has minimal dependencies and rarely
# changes. It is not critical path, so updates to it do not themselves
# get tested (which can produce odd consequences and is why we no
# longer use python3-kickstart). It is present in both Rocky Linux 8
# Rocky Linux 9 as well as in upstream Fedora mainline and Fedora ELN
# allowing us to match upstream changes more easily.
pkgacpi = rpmfluff.SimpleRpmBuild('acpica-tools', '1', '1', ['noarch'])
pkgacpi.addVendor("Rocky Enterprise Software Foundation")
pkgacpi.addPackager("Rocky Linux Build System (Peridot) <releng@rockylinux.org>")
# temporary, while we're switching from pandoc to acpi
pkgpandoc = rpmfluff.SimpleRpmBuild('pandoc-common', '1', '1', ['noarch'])
pkgpandoc.addVendor("Rocky Enterprise Software Foundation")
pkgpandoc.addPackager("Rocky Linux Build System (Peridot) <releng@rockylinux.org>")
repo1 = rpmfluff.yumrepobuild.YumRepoBuild([pkgacpi, pkgpandoc])
repo1dir = 'openqa-testrepo-1'
def cleanup(repos=True):
dirs = [pkgacpi.get_base_dir(), pkgpandoc.get_base_dir()]
if repos:
dirs.extend((repo1dir,))
for _dir in dirs:
if os.path.isdir(_dir):
shutil.rmtree(_dir)
cleanup()
os.mkdir(repo1dir)
repo1.repoDir = repo1dir
repo1.make('noarch')
README = """This repository contains empty test packages for openQA package
management tool testing. The repository and packages were created with the
'tools/testpackages9' script from the openqa-testrepos repository:
https://git.resf.org/testing/openqa-testrepos
"""
with open('/'.join((repo1dir, 'README')), 'w') as rmfh:
rmfh.write(README)
cleanup(repos=False)