"make srpm" may fail to build package due to diff in git commit lengths
karibou opened this issue · comments
Bug report
Running "make srpm" may fail to build a SRPM package due to difference in the length of the git hash used in the top directory of the tarball.
Steps to reproduce the problem
$ docker run -ti --rm fedora:39 bash
[root] cd /root
[root] dnf -y install dnf-plugins-core
[root] dnf -y builddep cloud-init
[root] dnf -y install git make rpm-build e2fsprogs hostname net-tools procps python3-pytest-cov rsyslog
[root] git clone https://github.com/canonical/cloud-init.git -b 23.2
[root] cd cloud-init
[root] git checkout -b 23.2 refs/tags/23.2
[root] make srpm
[root] rpm -vih *.src.rpm
[root] rpmbuild --clean -ba /root/rpmbuild/SPECS/cloud-init.spec
warning: source_date_epoch_from_changelog set but %changelog is missing
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.Q0Klh2
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf cloud-init-23.2-0-gcdc24d864
+ /usr/lib/rpm/rpmuncompress -x /root/rpmbuild/SOURCES/cloud-init-23.2-0-gcdc24d864.tar.gz
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd cloud-init-23.2-0-gcdc24d864
/var/tmp/rpm-tmp.Q0Klh2: line 41: cd: cloud-init-23.2-0-gcdc24d864: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.Q0Klh2 (%prep)
RPM build warnings:
source_date_epoch_from_changelog set but %changelog is missing
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.Q0Klh2 (%pre
The source of this issue is that the script ./package/brpm
uses ./tools/read-version --json
to define the name of the tarball. The name comes from version_long
which is defined by :
[root] git describe HEAD --long
23.2-0-gcdc24d864
This will be used to name the tarball.
To create the tarball, the script ./tools/make-tarball
uses the following command to define the top directory of the tarball :
git describe --abbrev=8 "--match=[0-9]*" --long HEAD
23.2-0-gcdc24d86
Notice the extra digit in the name of the tarball. Since rpmbuild
expect the directory in rpmbuild/BUILD
to be the version in the name of the tarball, it fails.
The command git describe --abbrev=8 "--match=[0-9]*" --long HEAD
should be used in read-version
as well to be sure that they output the same number of digits.
Environment details
- Cloud-init version:
- Operating System Distribution:
- Cloud provider, platform or installer type:
cloud-init logs
In tip of main, I see tools/read-version
calling
git describe --abbrev=8
Which gives the correct (matching tarball) version identifier. From your comment in IRC, I think you only see this issue on the 23.2.x branch, is that correct?
Closing as already fixed on the main branch.