diff --git a/Dockerfile b/Dockerfile index 4707c218..97dfdd89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ FROM quay.io/centos/centos:stream8 RUN echo "tsflags=nodocs" >> /etc/yum.conf && \ - yum -y install git glibc-langpack-en epel-release python3-pip && \ - yum clean all + dnf -y install git glibc-langpack-en epel-release python3-pip dnf-utils && \ + dnf clean all ENV LANG=en_US.UTF-8 \ LANGUAGE=en_US.UTF-8 \ diff --git a/obal/data/playbooks/update/metadata.obal.yaml b/obal/data/playbooks/update/metadata.obal.yaml index 8d136e7d..d01d6b37 100644 --- a/obal/data/playbooks/update/metadata.obal.yaml +++ b/obal/data/playbooks/update/metadata.obal.yaml @@ -8,10 +8,14 @@ help: | obal update mypackage --version 3.4.5 - To update a package to a new version and create a git branch for the change from the command line: + To update a package to a new version and create a commit for the change from the command line: obal update mypackage --version 3.4.5 --commit + To update a package to a new version and create a git branch for the change from the command line: + + obal update mypackage --version 3.4.5 --branch + Updating a package that is taken from an upstream repository assumes that the package_manifest already defines the upstream location. Thus, the command line to update to a newer version that is available upstream automatically is: obal update mypackage @@ -25,5 +29,8 @@ variables: changelog: help: Optionally set the changelog. When unspecified, an entry will be generated commit: + help: When true, commits the update changes to it into the current branch + action: store_true + branch: help: When true, creates a git branch and commits the update changes to it. action: store_true diff --git a/obal/data/playbooks/update/update.yaml b/obal/data/playbooks/update/update.yaml index 44acfdb2..526cad76 100644 --- a/obal/data/playbooks/update/update.yaml +++ b/obal/data/playbooks/update/update.yaml @@ -51,9 +51,25 @@ when: - "'://' not in item" + - name: 'Get updated version from spec' + command: "rpmspec --query --queryformat=%{version} --srpm {{ spec_file_path }}" + args: + chdir: "{{ inventory_dir }}" + changed_when: false + register: updated_version + when: commit is defined and commit + + - name: 'Create git commit' + command: "git commit -a -m 'Update {{ inventory_hostname }} to {{ updated_version.stdout }}'" + args: + chdir: "{{ inventory_dir }}" + run_once: true + changed_when: true + when: commit is defined and commit + - hosts: - packages gather_facts: false roles: - - when: commit is defined and commit + - when: branch is defined and branch role: git_branch_and_commit diff --git a/tests/fixtures/help/update.txt b/tests/fixtures/help/update.txt index 9945f8d0..04c36e17 100644 --- a/tests/fixtures/help/update.txt +++ b/tests/fixtures/help/update.txt @@ -1,5 +1,5 @@ usage: obal update [-h] [-v] [-e EXTRA_VARS] [--changelog CHANGELOG] - [--commit] [--prerelease PRERELEASE] [--release RELEASE] + [--branch] [--commit] [--prerelease PRERELEASE] [--release RELEASE] [--version VERSION] target [target ...] @@ -13,6 +13,10 @@ To update a package to a new version from the command line: To update a package to a new version and create a git branch for the change from the command line: + obal update mypackage --version 3.4.5 --branch + +To update a package to a new version and create a commit for the change from the command line: + obal update mypackage --version 3.4.5 --commit Updating a package that is taken from an upstream repository assumes that the package_manifest already defines the upstream location. Thus, the command line to update to a newer version that is available upstream automatically is: @@ -28,8 +32,10 @@ optional arguments: --changelog CHANGELOG Optionally set the changelog. When unspecified, an entry will be generated - --commit When true, creates a git branch and commits the update + --branch When true, creates a git branch and commits the update changes to it. + --commit When true, commits the update changes to it into the + current branch --prerelease PRERELEASE Optionally set the prerelease macro. When unspecified, the prerelease macro will be removed