Skip to content

Commit e05edf4

Browse files
committed
ndctl: rework release collateral
Prompted by a request to have the spec file reference the github tarball URL, rework spec file generation: 1/ Use noinst_SCRIPTS to do the token replacements in ndctl.spec.in using sed, kill contrib/genspec and kill the %lname and %dname variables 2/ Use the LIBNDCTL_CURRENT variable to name the sles library package 3/ Unify the git snapshot naming with github archive naming. Split git-version off from git-version-gen as a helper for make-git-snapshot.sh. 4/ Specify --disable-silent-rules to configure Reported-by: Ralf Corsepius <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent e870005 commit e05edf4

File tree

11 files changed

+87
-160
lines changed

11 files changed

+87
-160
lines changed

Documentation/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ man1_MANS = \
88
ndctl-create-namespace.1 \
99
ndctl-list.1
1010

11+
CLEANFILES = $(man1_MANS)
12+
1113
XML_DEPS = \
1214
$(top_srcdir)/version.m4 \
1315
Makefile \

Makefile.am

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@ LIBNDCTL_CURRENT=6
4949
LIBNDCTL_REVISION=0
5050
LIBNDCTL_AGE=0
5151

52+
noinst_SCRIPTS = rhel/ndctl.spec sles/ndctl.spec
53+
CLEANFILES += $(noinst_SCRIPTS)
54+
55+
do_rhel_subst = sed -e 's,VERSION,$(VERSION),g' \
56+
-e 's,DNAME,ndctl-devel,g' \
57+
-e 's,LNAME,libndctl,g'
58+
59+
do_sles_subst = sed -e 's,VERSION,$(VERSION),g' \
60+
-e 's,DNAME,libndctl-devel,g' \
61+
-e 's,LNAME,libndctl$(LIBNDCTL_CURRENT),g'
62+
63+
rhel/ndctl.spec: ndctl.spec.in Makefile.am
64+
$(AM_V_GEN)$(MKDIR_P) rhel; $(do_rhel_subst) < $< > $@
65+
66+
sles/ndctl.spec: ndctl.spec.in Makefile.am
67+
$(AM_V_GEN)$(MKDIR_P) sles; cat sles/header $< | $(do_sles_subst) > $@
68+
5269
pkginclude_HEADERS = lib/ndctl/libndctl.h
5370
lib_LTLIBRARIES = lib/libndctl.la
5471

contrib/Makefile

Lines changed: 0 additions & 39 deletions
This file was deleted.

contrib/genspec.c

Lines changed: 0 additions & 53 deletions
This file was deleted.

contrib/rpmbuild.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

git-version

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
3+
dirty() {
4+
git update-index -q --refresh
5+
if test -z "$(git diff-index --name-only HEAD --)"; then
6+
echo "$1"
7+
else
8+
echo "${1}.dirty"
9+
fi
10+
}
11+
12+
DEF_VER=v50
13+
14+
LF='
15+
'
16+
17+
# First see if there is a version file (included in release tarballs),
18+
# then try git-describe, then default.
19+
if test -f version; then
20+
VN=$(cat version) || VN="$DEF_VER"
21+
elif test -d ${GIT_DIR:-.git} -o -f .git &&
22+
VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null) &&
23+
case "$VN" in
24+
*$LF*) (exit 1) ;;
25+
v[0-9]*)
26+
VN="$(dirty $VN)"
27+
esac; then
28+
VN=$(echo "$VN" | sed -e 's/-/./g');
29+
else
30+
read COMMIT COMMIT_SUBJECT <<EOF
31+
$(git log --oneline --abbrev=8 -n1 HEAD)
32+
EOF
33+
VN="$(dirty ${DEF_VER}.git$COMMIT)"
34+
fi
35+
36+
#drop leading 'v' out of the version so its a pure number
37+
if [ ${VN:0:1} = v ]; then
38+
VN=${VN:1}
39+
fi
40+
41+
echo $VN

git-version-gen

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,16 @@
11
#!/bin/sh
22

3-
dirty() {
4-
git update-index -q --refresh
5-
if test -z "$(git diff-index --name-only HEAD --)"; then
6-
echo "$1"
7-
else
8-
echo "${1}.dirty"
9-
fi
10-
}
11-
123
GVF=version.m4
13-
DEF_VER=v50
14-
15-
LF='
16-
'
17-
18-
# First see if there is a version file (included in release tarballs),
19-
# then try git-describe, then default.
20-
if test -f version; then
21-
VN=$(cat version) || VN="$DEF_VER"
22-
elif test -d ${GIT_DIR:-.git} -o -f .git &&
23-
VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null) &&
24-
case "$VN" in
25-
*$LF*) (exit 1) ;;
26-
v[0-9]*)
27-
VN="$(dirty $VN)"
28-
esac; then
29-
VN=$(echo "$VN" | sed -e 's/-/./g');
30-
else
31-
read COMMIT COMMIT_SUBJECT <<EOF
32-
$(git log --oneline --abbrev=8 -n1 HEAD)
33-
EOF
34-
VN="$(dirty ${DEF_VER}.git$COMMIT)"
35-
fi
364

375
if test -r $GVF; then
386
VC=$(sed -e 's/m4_define(\[GIT_VERSION], \[//' <$GVF)
397
VC=$(echo $VC | sed -e 's/\])//')
408
else
419
VC=unset
4210
fi
11+
12+
VN=$(./git-version)
13+
4314
test "$VN" = "$VC" || {
4415
echo >&2 "GIT_VERSION = $VN"
4516
echo "m4_define([GIT_VERSION], [$VN])" >$GVF
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,8 @@ trap 'rm -rf $WORKDIR' exit
1414
[ -d "$REFDIR" ] && REFERENCE="--reference $REFDIR"
1515
git clone $REFERENCE "$UPSTREAM" "$WORKDIR"
1616

17-
pushd "$WORKDIR" > /dev/null
18-
git branch to-archive $HEAD
19-
read COMMIT_SHORTID COMMIT_TITLE <<EOGIT
20-
$(git log to-archive^..to-archive --pretty='format:%h %s')
21-
EOGIT
22-
popd > /dev/null
17+
VERSION=$(./git-version)
18+
DIRNAME="ndctl-${VERSION}"
19+
git archive --remote="$WORKDIR" --format=tar --prefix="$DIRNAME/" HEAD | gzip > $OUTDIR/"v${VERSION}.tar.gz"
2320

24-
echo "Making git snapshot using commit: $COMMIT_SHORTID $COMMIT_TITLE"
25-
26-
DIRNAME="$NAME-git$COMMIT_SHORTID"
27-
git archive --remote="$WORKDIR" --format=tar --prefix="$DIRNAME/" to-archive | xz -9 > $OUTDIR/"$DIRNAME.tar.xz"
28-
29-
echo "Written $OUTDIR/$DIRNAME.tar.xz"
21+
echo "Written $OUTDIR/v${VERSION}.tar.gz"
Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
%global gitcommit
2-
%define lname
3-
%define dname
4-
51
Name: ndctl
6-
Version:
2+
Version: VERSION
73
Release: 1%{?dist}
84
Summary: Manage "libnvdimm" subsystem devices (Non-volatile Memory)
95
License: GPLv2
106
Group: Hardware/Other
117
Url: https://github.com/pmem/ndctl
12-
# Snapshot tarball can be created using: ./make-git-shapshot.sh [gitcommit]
13-
Source0: %{name}-git%{gitcommit}.tar.xz
8+
Source0: https://github.com/pmem/ndctl/archive/v%{version}.tar.gz
149

1510
BuildRequires: autoconf
1611
BuildRequires: asciidoc
@@ -26,36 +21,36 @@ BuildRequires: pkgconfig(json-c)
2621
%description
2722
Utility library for managing the "libnvdimm" subsystem. The "libnvdimm"
2823
subsystem defines a kernel device model and control message interface for
29-
platform NVDIMM resources like those defined by the ACPI 6.0 NFIT (NVDIMM
24+
platform NVDIMM resources like those defined by the ACPI 6+ NFIT (NVDIMM
3025
Firmware Interface Table).
3126

3227

33-
%package -n %dname
28+
%package -n DNAME
3429
Summary: Development files for libndctl
3530
License: LGPLv2
3631
Group: Development/Libraries/Other
37-
Requires: %{lname}%{?_isa} = %{version}-%{release}
32+
Requires: LNAME%{?_isa} = %{version}-%{release}
3833

39-
%description -n %dname
34+
%description -n DNAME
4035
The %{name}-devel package contains libraries and header files for
4136
developing applications that use %{name}.
4237

4338

44-
%package -n %lname
39+
%package -n LNAME
4540
Summary: Management library for "libnvdimm" subsystem devices (Non-volatile Memory)
4641
License: LGPLv2
4742
Group: System/Libraries
4843

49-
%description -n %lname
44+
%description -n LNAME
5045
Libraries for %{name}.
5146

5247
%prep
53-
%setup -q %{?gitcommit:-n %{name}-git%{gitcommit}}
48+
%setup -q v%{version}
5449

5550
%build
56-
echo "" > version
51+
echo "VERSION" > version
5752
./autogen.sh
58-
%configure --disable-static --enable-local
53+
%configure --disable-static --enable-local --disable-silent-rules
5954
make %{?_smp_mflags}
6055

6156
%install
@@ -65,23 +60,23 @@ find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
6560
%check
6661
make check
6762

68-
%post -n %lname -p /sbin/ldconfig
63+
%post -n LNAME -p /sbin/ldconfig
6964

70-
%postun -n %lname -p /sbin/ldconfig
65+
%postun -n LNAME -p /sbin/ldconfig
7166

7267
%files
7368
%defattr(-,root,root)
7469
%license licenses/GPLv2 licenses/BSD-MIT licenses/CC0
7570
%{_bindir}/ndctl
7671
%{_mandir}/man1/*
7772

78-
%files -n %lname
73+
%files -n LNAME
7974
%defattr(-,root,root)
8075
%doc README.md
8176
%license COPYING licenses/BSD-MIT licenses/CC0
8277
%{_libdir}/libndctl.so.*
8378

84-
%files -n %dname
79+
%files -n DNAME
8580
%defattr(-,root,root)
8681
%license COPYING
8782
%{_includedir}/ndctl/

rpmbuild.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
pushd $(dirname $0) >/dev/null
3+
./make-git-snapshot.sh
4+
popd > /dev/null
5+
rpmbuild -ba $(dirname $0)/rhel/ndctl.spec

0 commit comments

Comments
 (0)