Skip to content

Commit

Permalink
Merge pull request #199 from IBM/spec_file_improvements
Browse files Browse the repository at this point in the history
add flag to remove disable_source_fetch in generated bob.spec
  • Loading branch information
edmundreinhardt authored Feb 10, 2023
2 parents 5a4c0f8 + e077b24 commit 3d47d92
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ibmi_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
echo " StrictHostKeyChecking no" >> ~/.ssh/config
- name: Generate the RPM spec file
run: |
python3 tools/release/generate_spec.py ${{ steps.get_version.outputs.VERSION }} CHANGELOG
python3 tools/release/generate_spec.py ${{ steps.get_version.outputs.VERSION }} CHANGELOG True
- name: Create rpmbuild directory
run: |
mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,BUILDROOT}
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def publish(session: nox.Session) -> None:

session.log(f"Generating the spec file for v{current_version}")

session.run("python", "tools/release/generate_spec.py", current_version, os.fsdecode(changelog_file))
session.run("python", "tools/release/generate_spec.py", current_version, os.fsdecode(changelog_file), "False")

session.log(f"Publishing the spec file for v{current_version}")
session.run("python", "tools/release/publish_spec.py", current_version, os.fsdecode(spec_file))
16 changes: 11 additions & 5 deletions tools/release/generate_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def replace_changelog(template: str,
return re.sub(r"\${CHANGELOG}", changelog, template)


def generate_spec(version: str, changelog_file: pathlib.Path) -> str:
def generate_spec(version: str, changelog_file: pathlib.Path, fetch_source: bool) -> str:
"""Generate the spec file by replacing ${VERSION} and ${CHANGELOG} in the given template string.
Args:
Expand All @@ -57,25 +57,31 @@ def generate_spec(version: str, changelog_file: pathlib.Path) -> str:
Returns:
str: The modified spec file.
"""
template = template_file.read_text()
if fetch_source:
template = "%undefine _disable_source_fetch\n"
else:
template = ""
template = template + template_file.read_text()
template = replace_version(template, version)
template = replace_changelog(template, changelog_file)
return template


def main():
"""Generate the spec file by replacing ${VERSION} and ${CHANGELOG} in the template file."""
if len(sys.argv) != 3:
print("Usage: generate_spec.py VERSION CHANGELOG_FILE")
if len(sys.argv) != 4:
print("Usage: generate_spec.py VERSION CHANGELOG_FILE FETCH_SOURCE")
sys.exit(1)
version = sys.argv[1]
changelog_file = pathlib.Path(sys.argv[2])
fetch_source = sys.argv[3] == "True"


if not changelog_file.exists():
print(f"Changelog file {changelog_file} does not exist")
sys.exit(1)

spec = generate_spec(version, changelog_file)
spec = generate_spec(version, changelog_file, fetch_source)
with open("bob.spec", "w", encoding="utf-8") as out_file:
out_file.write(spec)

Expand Down

0 comments on commit 3d47d92

Please sign in to comment.