From patchwork Tue Feb 9 20:38:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 8265631 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 66D0E9F3CD for ; Tue, 9 Feb 2016 20:39:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 650A620263 for ; Tue, 9 Feb 2016 20:39:02 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B2A1920254 for ; Tue, 9 Feb 2016 20:39:00 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8D2051A1DEA; Tue, 9 Feb 2016 12:39:00 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ml01.01.org (Postfix) with ESMTP id 876571A1DEA for ; Tue, 9 Feb 2016 12:38:59 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 09 Feb 2016 12:38:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,422,1449561600"; d="scan'208";a="880702075" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.136]) by orsmga001.jf.intel.com with ESMTP; 09 Feb 2016 12:38:32 -0800 Subject: [ndctl PATCH] ndctl: rework release collateral From: Dan Williams To: linux-nvdimm@lists.01.org Date: Tue, 09 Feb 2016 12:38:08 -0800 Message-ID: <20160209203808.3440.45296.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Dan Williams --- Documentation/Makefile.am | 2 ++ Makefile.am | 17 +++++++++++++ contrib/Makefile | 39 ------------------------------- contrib/genspec.c | 53 ------------------------------------------ contrib/rpmbuild.sh | 4 --- git-version | 16 ++++--------- git-version-gen | 35 ++-------------------------- make-git-snapshot.sh | 16 +++---------- ndctl.spec.in | 35 ++++++++++++---------------- rpmbuild.sh | 5 ++++ sles/header | 0 11 files changed, 51 insertions(+), 171 deletions(-) delete mode 100644 contrib/Makefile delete mode 100644 contrib/genspec.c delete mode 100755 contrib/rpmbuild.sh copy git-version-gen => git-version (73%) rename contrib/make-git-snapshot.sh => make-git-snapshot.sh (55%) rename contrib/ndctl.spec.in => ndctl.spec.in (74%) create mode 100755 rpmbuild.sh rename contrib/sles/header => sles/header (100%) diff --git a/contrib/sles/header b/sles/header similarity index 100% rename from contrib/sles/header rename to sles/header diff --git a/Documentation/Makefile.am b/Documentation/Makefile.am index a168cec100c8..3b3336918516 100644 --- a/Documentation/Makefile.am +++ b/Documentation/Makefile.am @@ -8,6 +8,8 @@ man1_MANS = \ ndctl-create-namespace.1 \ ndctl-list.1 +CLEANFILES = $(man1_MANS) + XML_DEPS = \ $(top_srcdir)/version.m4 \ Makefile \ diff --git a/Makefile.am b/Makefile.am index 1c6a4b07f8f1..61dce040131c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,6 +49,23 @@ LIBNDCTL_CURRENT=6 LIBNDCTL_REVISION=0 LIBNDCTL_AGE=0 +noinst_SCRIPTS = rhel/ndctl.spec sles/ndctl.spec +CLEANFILES += $(noinst_SCRIPTS) + +do_rhel_subst = sed -e 's,VERSION,$(VERSION),g' \ + -e 's,DNAME,ndctl-devel,g' \ + -e 's,LNAME,libndctl,g' + +do_sles_subst = sed -e 's,VERSION,$(VERSION),g' \ + -e 's,DNAME,libndctl-devel,g' \ + -e 's,LNAME,libndctl$(LIBNDCTL_CURRENT),g' + +rhel/ndctl.spec: ndctl.spec.in Makefile.am + $(AM_V_GEN)$(MKDIR_P) rhel; $(do_rhel_subst) < $< > $@ + +sles/ndctl.spec: ndctl.spec.in Makefile.am + $(AM_V_GEN)$(MKDIR_P) sles; cat sles/header $< | $(do_sles_subst) > $@ + pkginclude_HEADERS = lib/ndctl/libndctl.h lib_LTLIBRARIES = lib/libndctl.la diff --git a/contrib/Makefile b/contrib/Makefile deleted file mode 100644 index 766e186d0389..000000000000 --- a/contrib/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -CC=gcc -CFLAGS=-c -Wall -LDFLAGS= -SRCS=genspec.c -OBJS=$(SRCS:.c=.o) -PROG=genspec -SPEC_IN=ndctl.spec.in -RHEL_SPEC=rhel/$(SPEC_IN:.in=) -SLES_SPEC=sles/$(SPEC_IN:.in=) -SLES_IN=sles/header -COMMIT_ID=git log --pretty=format:"%h" -n 1 - -all: $(RHEL_SPEC) $(SLES_SPEC) - -$(RHEL_SPEC) : $(SPEC_IN) $(PROG) - @mkdir -p rhel - cat $(SPEC_IN) | $(dir $(PROG))$(PROG) `$(COMMIT_ID)` rhel > $@ - -$(SLES_SPEC) : $(SLES_IN) $(SPEC_IN) $(PROG) - @mkdir -p sles - cat $(SLES_IN) $(SPEC_IN) | $(dir $(PROG))$(PROG) `$(COMMIT_ID)` sles > $@ - -$(PROG) : $(OBJS) Makefile - $(CC) $(LDFLAGS) $(OBJS) -o $@ - -.c.o: - $(CC) $(CFLAGS) $< -o $@ - -clean: - rm $(OBJS) $(PROG) $(RHEL_SPEC) $(SLES_SPEC) - @rmdir rhel sles - -depend: .depend - -.depend: $(SRCS) - rm -f $@ > /dev/null 2>&1 - $(CC) $(CFLAGS) -MM $^ -MF $@ - -include .depend diff --git a/contrib/genspec.c b/contrib/genspec.c deleted file mode 100644 index 829f648f0a2f..000000000000 --- a/contrib/genspec.c +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include -#include "../config.h" - -static char *lname[] = { - "ndctl-libs", "libndctl3", -}; - -static char *dname[] = { - "ndctl-devel", "libndctl-devel", -}; - -static int license[] = { - 1, 0, -}; - -int main(int argc, char **argv) -{ - const char *commit = argv[1]; - char buf[1024]; - int os; - - if (argc != 3) { - fprintf(stderr, "commit id and OS must be specified\n"); - return 1; - } - - if (strcmp(argv[2], "rhel") == 0) - os = 0; - else if (strcmp(argv[2], "sles") == 0) - os = 1; - else - return 1; - - while (fgets(buf, sizeof(buf), stdin)) { - if (strncmp("Version:", buf, 8) == 0) - fprintf(stdout, "Version: %s\n", &VERSION[1]); - else if (strncmp("%global gitcommit", buf, 17) == 0) - fprintf(stdout, "%%global gitcommit %s\n", commit); - else if (strncmp("%define lname", buf, 12) == 0) - fprintf(stdout, "%%define lname %s\n", lname[os]); - else if (strncmp("%define dname", buf, 12) == 0) - fprintf(stdout, "%%define dname %s\n", dname[os]); - else if (strncmp("%license", buf, 8) == 0 && !license[os]) - fprintf(stdout, "%%doc %s", &buf[8]); - else if (strncmp("echo \"\" > version", buf, 17) == 0) - fprintf(stdout, "echo \"%s\" > version\n", VERSION); - else - fprintf(stdout, "%s", buf); - } - - return 0; -} diff --git a/contrib/rpmbuild.sh b/contrib/rpmbuild.sh deleted file mode 100755 index 97def14bd965..000000000000 --- a/contrib/rpmbuild.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -$(dirname $0)/make-git-snapshot.sh -make -C $(dirname $0) -rpmbuild -bb $(dirname $0)/rhel/ndctl.spec diff --git a/git-version-gen b/git-version similarity index 73% copy from git-version-gen copy to git-version index 9cd2ebf1407a..3b5217752924 100755 --- a/git-version-gen +++ b/git-version @@ -9,7 +9,6 @@ dirty() { fi } -GVF=version.m4 DEF_VER=v50 LF=' @@ -34,14 +33,9 @@ EOF VN="$(dirty ${DEF_VER}.git$COMMIT)" fi -if test -r $GVF; then - VC=$(sed -e 's/m4_define(\[GIT_VERSION], \[//' <$GVF) - VC=$(echo $VC | sed -e 's/\])//') -else - VC=unset +#drop leading 'v' out of the version so its a pure number +if [ ${VN:0:1} = v ]; then + VN=${VN:1} fi -test "$VN" = "$VC" || { - echo >&2 "GIT_VERSION = $VN" - echo "m4_define([GIT_VERSION], [$VN])" >$GVF - exit 0 -} + +echo $VN diff --git a/git-version-gen b/git-version-gen index 9cd2ebf1407a..e913a3674eef 100755 --- a/git-version-gen +++ b/git-version-gen @@ -1,38 +1,6 @@ #!/bin/sh -dirty() { - git update-index -q --refresh - if test -z "$(git diff-index --name-only HEAD --)"; then - echo "$1" - else - echo "${1}.dirty" - fi -} - GVF=version.m4 -DEF_VER=v50 - -LF=' -' - -# First see if there is a version file (included in release tarballs), -# then try git-describe, then default. -if test -f version; then - VN=$(cat version) || VN="$DEF_VER" -elif test -d ${GIT_DIR:-.git} -o -f .git && - VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null) && - case "$VN" in - *$LF*) (exit 1) ;; - v[0-9]*) - VN="$(dirty $VN)" - esac; then - VN=$(echo "$VN" | sed -e 's/-/./g'); -else - read COMMIT COMMIT_SUBJECT <&2 "GIT_VERSION = $VN" echo "m4_define([GIT_VERSION], [$VN])" >$GVF diff --git a/contrib/make-git-snapshot.sh b/make-git-snapshot.sh similarity index 55% rename from contrib/make-git-snapshot.sh rename to make-git-snapshot.sh index e031223c740f..2825ac4321cd 100755 --- a/contrib/make-git-snapshot.sh +++ b/make-git-snapshot.sh @@ -14,16 +14,8 @@ trap 'rm -rf $WORKDIR' exit [ -d "$REFDIR" ] && REFERENCE="--reference $REFDIR" git clone $REFERENCE "$UPSTREAM" "$WORKDIR" -pushd "$WORKDIR" > /dev/null -git branch to-archive $HEAD -read COMMIT_SHORTID COMMIT_TITLE < /dev/null +VERSION=$(./git-version) +DIRNAME="ndctl-${VERSION}" +git archive --remote="$WORKDIR" --format=tar --prefix="$DIRNAME/" HEAD | gzip > $OUTDIR/"v${VERSION}.tar.gz" -echo "Making git snapshot using commit: $COMMIT_SHORTID $COMMIT_TITLE" - -DIRNAME="$NAME-git$COMMIT_SHORTID" -git archive --remote="$WORKDIR" --format=tar --prefix="$DIRNAME/" to-archive | xz -9 > $OUTDIR/"$DIRNAME.tar.xz" - -echo "Written $OUTDIR/$DIRNAME.tar.xz" +echo "Written $OUTDIR/v${VERSION}.tar.gz" diff --git a/contrib/ndctl.spec.in b/ndctl.spec.in similarity index 74% rename from contrib/ndctl.spec.in rename to ndctl.spec.in index da0c9cee947a..e24b31cc54f0 100644 --- a/contrib/ndctl.spec.in +++ b/ndctl.spec.in @@ -1,16 +1,11 @@ -%global gitcommit -%define lname -%define dname - Name: ndctl -Version: +Version: VERSION Release: 1%{?dist} Summary: Manage "libnvdimm" subsystem devices (Non-volatile Memory) License: GPLv2 Group: Hardware/Other Url: https://github.com/pmem/ndctl -# Snapshot tarball can be created using: ./make-git-shapshot.sh [gitcommit] -Source0: %{name}-git%{gitcommit}.tar.xz +Source0: https://github.com/pmem/ndctl/archive/v%{version}.tar.gz BuildRequires: autoconf BuildRequires: asciidoc @@ -26,36 +21,36 @@ BuildRequires: pkgconfig(json-c) %description Utility library for managing the "libnvdimm" subsystem. The "libnvdimm" subsystem defines a kernel device model and control message interface for -platform NVDIMM resources like those defined by the ACPI 6.0 NFIT (NVDIMM +platform NVDIMM resources like those defined by the ACPI 6+ NFIT (NVDIMM Firmware Interface Table). -%package -n %dname +%package -n DNAME Summary: Development files for libndctl License: LGPLv2 Group: Development/Libraries/Other -Requires: %{lname}%{?_isa} = %{version}-%{release} +Requires: LNAME%{?_isa} = %{version}-%{release} -%description -n %dname +%description -n DNAME The %{name}-devel package contains libraries and header files for developing applications that use %{name}. -%package -n %lname +%package -n LNAME Summary: Management library for "libnvdimm" subsystem devices (Non-volatile Memory) License: LGPLv2 Group: System/Libraries -%description -n %lname +%description -n LNAME Libraries for %{name}. %prep -%setup -q %{?gitcommit:-n %{name}-git%{gitcommit}} +%setup -q v%{version} %build -echo "" > version +echo "VERSION" > version ./autogen.sh -%configure --disable-static --enable-local +%configure --disable-static --enable-local --disable-silent-rules make %{?_smp_mflags} %install @@ -65,9 +60,9 @@ find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';' %check make check -%post -n %lname -p /sbin/ldconfig +%post -n LNAME -p /sbin/ldconfig -%postun -n %lname -p /sbin/ldconfig +%postun -n LNAME -p /sbin/ldconfig %files %defattr(-,root,root) @@ -75,13 +70,13 @@ make check %{_bindir}/ndctl %{_mandir}/man1/* -%files -n %lname +%files -n LNAME %defattr(-,root,root) %doc README.md %license COPYING licenses/BSD-MIT licenses/CC0 %{_libdir}/libndctl.so.* -%files -n %dname +%files -n DNAME %defattr(-,root,root) %license COPYING %{_includedir}/ndctl/ diff --git a/rpmbuild.sh b/rpmbuild.sh new file mode 100755 index 000000000000..4535b4654409 --- /dev/null +++ b/rpmbuild.sh @@ -0,0 +1,5 @@ +#!/bin/bash +pushd $(dirname $0) >/dev/null +./make-git-snapshot.sh +popd > /dev/null +rpmbuild -ba $(dirname $0)/rhel/ndctl.spec