Gene Czarcinski
2013-Jan-22 17:22 UTC
[PATCH 0/3] Btrfs-progs Add spec file template and script to create tarball
This series of patches adds an rpm spec file template for btrfs-progs and a script to create an archive/tarball which includes an updated spec file. The "optional" second patch adds make archive which executes do-archve.sh. The "optional" third patch changes version.sh and btrfs-progs.spec.in to handle future updates when the version changes. Gene Czarcinski (3): Btrfs-progs Add rpm spec template and create tarball Btrfs-progs Add make archive Btrfs-progs Change rpm spec file to be handle version This "optional" patch changes version.sh and the rpm spec file to handle changes in the version and still work properly. The "default" version in version.sh is changed to VERSION and v="$VERSION". The rpm spec file now update \$VERSION which will not change. Signed-off-by: Gene Czarcinski <gene@czarc.net> Makefile | 6 +++++- btrfs-progs.spec.in | 46 +++++++++++++++++++++++++++++++++++++++ do-archive.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ version.sh | 3 ++- 4 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 btrfs-progs.spec.in create mode 100644 do-archive.sh -- 1.8.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Gene Czarcinski
2013-Jan-22 17:22 UTC
[PATCH 1/3] Btrfs-progs Add rpm spec template and create tarball
This patch adds a rpm spec file template for btrfs-progs. The do-archive.sh script creates/updates the rpm spec file and creates an archive of the current branch if the btrfs-progs git repository does not have uncommitted changes. The created archive/tarball is of the form: btrfs-progs-git20130122.tar.gz where the "version" is "git" appended with the date. The "version" is also plugged into the rpm spec file. Additionally, the result of git describe --tags is plugged into the rpm spec file so that version.sh will be updated with the "current" version just like it would be if created in the git repository. See the comments in the do-archive.sh file for additional information. Signed-off-by: Gene Czarcinski <gene@czarc.net> --- btrfs-progs.spec.in | 46 +++++++++++++++++++++++++++++++++++++++ do-archive.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 btrfs-progs.spec.in create mode 100644 do-archive.sh diff --git a/btrfs-progs.spec.in b/btrfs-progs.spec.in new file mode 100644 index 0000000..b64e404 --- /dev/null +++ b/btrfs-progs.spec.in @@ -0,0 +1,46 @@ +Name: btrfs-progs +Version: @VERSION@ +Release: 0 +Epoch: 1 +# Use epoch to override distribution packages +%define real_version @REALVERSION@ +URL: http://btrfs.wiki.kernel.org/index.php/Main_Page +Summary: Btrfs File System Utilities: %{real_version} +License: GPL v2 or later +Group: System Environment/Base + +Source0: %{name}-%{version}.tar.gz + +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: e2fsprogs-devel, libuuid-devel, zlib-devel, libacl-devel, libblkid-devel + +%define _root_sbindir /sbin + +%description +The btrfs-progs package provides all the userpsace programs needed to create, +check, modify and correct any inconsistencies in the btrfs filesystem. + +%prep +%setup -q -c +sed -i s/v0.20-rc1/%{real_version}/g $RPM_BUILD_DIR/%{name}-%{version}/version.sh + +%build +make CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags} + +%install +rm -rf $RPM_BUILD_ROOT +make mandir=%{_mandir} bindir=%{_sbindir} install DESTDIR=$RPM_BUILD_ROOT + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root) +%doc COPYING INSTALL +%{_sbindir}/* +%{_mandir}/man8/* + +%changelog +* Mon Jan 22 2013 Gene Czarcinski <gene@czarc.net> +- Initial generic rpm spec file. +- note that much of this is from the Fedora 18 spec file. diff --git a/do-archive.sh b/do-archive.sh new file mode 100644 index 0000000..640c824 --- /dev/null +++ b/do-archive.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# +# update btrfs-progs.spec and create archive +# +# Released under the GNU GPLv2 +# Tue 22 Jan 2013 10:21:07 EST GC +# +# The purpose of the script is to update a btrfs rpm spec file +# and create an archive (tarball) with the spec file included. +# +# This tarball can be used as any other btrfs-progs tarball +# would be used as well as to be used to create a binary +# rpm with the following with the following examples: +# +# $ rpmbuild -ts btrfs-progs-git20130121.tar.gz +# $ rpm -ivh SRPMS/btrfs-progs-git20130121.src.rpm +# $ rpmbuild -ba --clean btrfs-progs-git20130121/btrfs-progs.spec +# or +# $ rpmbuild -ts btrfs-progs-git20130121.tar.gz +# $ mock SRPMS/btrfs-progs-git20130121.src.rpm +# +# Portions of version.h are included (duplicated) here. +# Spec file creation and archive creation are kept together +# to ensure consistency as possible. + +VERSION=`date "+%Y%m%d"` +VERSION="git$VERSION" + +which git &> /dev/null +if [ $? == 0 -a -d .git ]; then + if ! tag=`git describe --tags 2>/dev/null`; then + echo "error getting tags, exiting do-archive-sh" + exit 1 + fi + + # Are there uncommitted changes? + unmerged=`git update-index --refresh --unmerged` + if [ -n "$unmerged" ]; then + echo "$unmerged" + echo "uncommitted changes exist, exiting do-archive-sh" + exit 1 + fi +else + echo "no git or not git repository, exiting do-archive-sh" + exit 1 +fi + +if [ -e "btrfs-progs.spec.in" ]; then + sed -e s/@VERSION@/$VERSION/g \ + -e s/@REALVERSION@/$tag/g \ + <btrfs-progs.spec.in >btrfs-progs.spec +fi + +git archive --format=tar -o btrfs-progs-$VERSION.tar HEAD +if [ -e "btrfs-progs.spec" ]; then + tar --owner=root --group=root -rf \ + btrfs-progs-$VERSION.tar btrfs-progs.spec +fi +rm -f btrfs-progs-$VERSION.tar.gz +gzip -9 btrfs-progs-$VERSION.tar +echo "btrfs-progs-$VERSION.tar.gz created" +exit 0 -- 1.8.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
This adds the archive target to the Makefile which simply executes do-archive.sh. It also adds the remove of btrfs-progs.spec.in to make clean. Signed-off-by: Gene Czarcinski <gene@czarc.net> --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d524f69..6812258 100644 --- a/Makefile +++ b/Makefile @@ -111,9 +111,13 @@ manpages: install-man: cd man; $(MAKE) install +archive: + bash do-archive.sh + clean : rm -f $(progs) cscope.out *.o .*.d btrfs-convert btrfs-image btrfs-select-super \ - btrfs-zero-log btrfstune dir-test ioctl-test quick-test version.h + btrfs-zero-log btrfstune dir-test ioctl-test quick-test version.h \ + btrfs-progs.spec cd man; $(MAKE) clean install: $(progs) install-man -- 1.8.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Gene Czarcinski
2013-Jan-22 17:22 UTC
[PATCH 3/3] Btrfs-progs Change rpm spec file to be handle version This "optional" patch changes version.sh and the rpm spec file to handle changes in the version and still work properly. The "default" version in version.sh is changed to VERSION and v="$VERSION". The rpm spec file now update \$VERSION which will not change. Signed-off-by: Gene Czarcinski <gene@czarc.net>
--- btrfs-progs.spec.in | 2 +- version.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/btrfs-progs.spec.in b/btrfs-progs.spec.in index b64e404..882efc7 100644 --- a/btrfs-progs.spec.in +++ b/btrfs-progs.spec.in @@ -22,7 +22,7 @@ check, modify and correct any inconsistencies in the btrfs filesystem. %prep %setup -q -c -sed -i s/v0.20-rc1/%{real_version}/g $RPM_BUILD_DIR/%{name}-%{version}/version.sh +sed -i s/\$VERSION/%{real_version}/g $RPM_BUILD_DIR/%{name}-%{version}/version.sh %build make CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags} diff --git a/version.sh b/version.sh index b81040e..84513a3 100644 --- a/version.sh +++ b/version.sh @@ -6,7 +6,8 @@ # Copyright 2008, Oracle # Released under the GNU GPLv2 -v="v0.20-rc1" +VERSION="v0.20-rc1" +v="$VERSION" which git &> /dev/null if [ $? == 0 -a -d .git ]; then -- 1.8.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 22 January 2013 17:22, Gene Czarcinski <gene@czarc.net> wrote:> This adds the archive target to the Makefile which simply executes > do-archive.sh. It also adds the remove of btrfs-progs.spec.in toI think you mean btrfs-progs.spec without the .in as that''s the generated file.> make clean. > Signed-off-by: Gene Czarcinski <gene@czarc.net> > --- > Makefile | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index d524f69..6812258 100644 > --- a/Makefile > +++ b/Makefile > @@ -111,9 +111,13 @@ manpages: > install-man: > cd man; $(MAKE) install > > +archive: > + bash do-archive.sh > + > clean : > rm -f $(progs) cscope.out *.o .*.d btrfs-convert btrfs-image btrfs-select-super \ > - btrfs-zero-log btrfstune dir-test ioctl-test quick-test version.h > + btrfs-zero-log btrfstune dir-test ioctl-test quick-test version.h \ > + btrfs-progs.spec > cd man; $(MAKE) clean > > install: $(progs) install-man > -- > 1.8.1Mike -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 01/22/2013 04:52 PM, Mike Fleetwood wrote:> On 22 January 2013 17:22, Gene Czarcinski<gene@czarc.net> wrote: >> >This adds the archive target to the Makefile which simply executes >> >do-archive.sh. It also adds the remove of btrfs-progs.spec.in to > I think you mean btrfs-progs.spec without the .in as that''s the generated file. >You are correct. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html