Re: [git-buildpackage] [PATCH] Add --git-packaging-exclude to gbp buildpackage-rpm

2016-02-07 Thread Tzafrir Cohen
On Thu, Feb 04, 2016 at 07:25:02PM +0100, Guido Günther wrote:
> Hi,
> On Thu, Feb 04, 2016 at 06:34:31PM +0100, Tzafrir Cohen wrote:
> > Add an option to exclude copying some of the files from the source tree
> > to the packaging directory (a single regular expression).
> > 
> > This can be handy when running gbp buildpackage-rpm from a complete
> > source tree in a non-native mode and and some files in the top-level
> > directory can't or should not be copies to the packaging directory.
> 
> Thanks for the patch! Can you describe the concrete use case a bit so we
> can check if "gbp buildpackage" needs this as well or if we need it at
> all?

Looking at this again, I see that the patch is not needed as I have
failed to notice --git-native. My bad.

I tried to see which versions did not include it, but it seems the
package I was building now works fine with --git-native=auto (the
default).

So I guess this patch is not needed.

-- 
Tzafrir Cohen | tzaf...@jabber.org | VIM is
http://tzafrir.org.il || a Mutt's
tzaf...@cohens.org.il ||  best
tzaf...@debian.org|| friend
___
git-buildpackage mailing list
git-buildpackage@lists.sigxcpu.org
http://lists.sigxcpu.org/mailman/listinfo/git-buildpackage


Re: [git-buildpackage] [PATCH] Add --git-packaging-exclude to gbp buildpackage-rpm

2016-02-04 Thread Markus Lehtonen
Hi,



On 04/02/16 20:25, "git-buildpackage on behalf of Guido Günther" 
 
wrote:

>Hi,
>On Thu, Feb 04, 2016 at 06:34:31PM +0100, Tzafrir Cohen wrote:
>> Add an option to exclude copying some of the files from the source tree
>> to the packaging directory (a single regular expression).
>> 
>> This can be handy when running gbp buildpackage-rpm from a complete
>> source tree in a non-native mode and and some files in the top-level
>> directory can't or should not be copies to the packaging directory.
>
>Thanks for the patch! Can you describe the concrete use case a bit so we
>can check if "gbp buildpackage" needs this as well or if we need it at
>all?
>Markus do you have comments on this or maybe a similar patch in your queue?

I'm also wondering what would be the real use case for this? Why wouldn't you 
want to use all files from the packaging directory? If there are unneeded 
unwanted files in the packaging directory the correct thing to do (IMO) is just 
to remove those files (or move them somewhere else so that they won't be 
copied).


Thanks,
   Markus

___
git-buildpackage mailing list
git-buildpackage@lists.sigxcpu.org
http://lists.sigxcpu.org/mailman/listinfo/git-buildpackage


Re: [git-buildpackage] [PATCH] Add --git-packaging-exclude to gbp buildpackage-rpm

2016-02-04 Thread Guido Günther
Hi,
On Thu, Feb 04, 2016 at 06:34:31PM +0100, Tzafrir Cohen wrote:
> Add an option to exclude copying some of the files from the source tree
> to the packaging directory (a single regular expression).
> 
> This can be handy when running gbp buildpackage-rpm from a complete
> source tree in a non-native mode and and some files in the top-level
> directory can't or should not be copies to the packaging directory.

Thanks for the patch! Can you describe the concrete use case a bit so we
can check if "gbp buildpackage" needs this as well or if we need it at
all?
Markus do you have comments on this or maybe a similar patch in your queue?

The patch is lacking the manpage update btw.

Cheers
 -- Guido
___
git-buildpackage mailing list
git-buildpackage@lists.sigxcpu.org
http://lists.sigxcpu.org/mailman/listinfo/git-buildpackage


[git-buildpackage] [PATCH] Add --git-packaging-exclude to gbp buildpackage-rpm

2016-02-04 Thread Tzafrir Cohen
Add an option to exclude copying some of the files from the source tree
to the packaging directory (a single regular expression).

This can be handy when running gbp buildpackage-rpm from a complete
source tree in a non-native mode and and some files in the top-level
directory can't or should not be copies to the packaging directory.

Signed-off-by: Tzafrir Cohen 
---
 gbp/config.py|  1 +
 gbp/scripts/buildpackage_rpm.py  |  7 +++
 tests/component/rpm/test_buildpackage_rpm.py | 14 ++
 3 files changed, 22 insertions(+)

diff --git a/gbp/config.py b/gbp/config.py
index 3d254ee..bc43485 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -651,6 +651,7 @@ class GbpOptionParserRpm(GbpOptionParser):
 'vendor': 'Downstream',
 'packaging-branch'  : 'master',
 'packaging-dir' : '',
+'packaging-exclude' : '',
 'packaging-tag-msg' : ('%(pkg)s (vendor)s release '
  '%(version)s'),
 'packaging-tag' : 'packaging/%(version)s',
diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py
index 00582df..340f130 100644
--- a/gbp/scripts/buildpackage_rpm.py
+++ b/gbp/scripts/buildpackage_rpm.py
@@ -21,6 +21,7 @@
 from six.moves import configparser
 import os
 import shutil
+import re
 import sys
 
 import gbp.log
@@ -438,6 +439,10 @@ def build_parser(name, prefix=None, git_treeish=None):
  "'%(export)s'")
 export_group.add_config_file_option(option_name="packaging-dir",
 dest="packaging_dir")
+export_group.add_config_file_option(option_name="packaging-exclude",
+dest="packaging_exclude",
+help="pattern of files to exclude from exporting from " +
+"top-level source directory to packaging directory")
 export_group.add_config_file_option(option_name="spec-file",
 dest="spec_file")
 return parser
@@ -548,6 +553,8 @@ def main(argv):
 src = os.path.join(dump_dir, fname)
 if fname == spec.specfile:
 dst = os.path.join(spec_dir, fname)
+elif re.match(options.packaging_exclude, fname):
+continue
 else:
 dst = os.path.join(source_dir, fname)
 try:
diff --git a/tests/component/rpm/test_buildpackage_rpm.py 
b/tests/component/rpm/test_buildpackage_rpm.py
index 4f0c290..6dd5317 100644
--- a/tests/component/rpm/test_buildpackage_rpm.py
+++ b/tests/component/rpm/test_buildpackage_rpm.py
@@ -24,6 +24,7 @@ import re
 import shutil
 import stat
 import subprocess
+import tempfile
 
 from nose import SkipTest
 from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611
@@ -369,6 +370,19 @@ class TestGbpRpm(RpmRepoTestBase):
 eq_(mock_gbp(['--git-builder=true']), 1)
 eq_(mock_gbp(['--git-ignore-branch', '--git-builder=true']), 0)
 
+def test_packaging_exclude_option(self):
+"""Test the --packaging-exclude option"""
+repo = self.init_test_repo('gbp-test')
+
+packaging_dir = tempfile.mkdtemp(prefix='gbp_packaging-')
+eq_(mock_gbp(['--git-no-build', '--git-packaging-exclude=\.patch',
+  '--git-packaging-dir=' + packaging_dir]), 0)
+
+# Test building when not on any branch
+repo.set_branch(repo.rev_parse('HEAD'))
+eq_(glob.glob("../rpmbuild/SOURCES/*.patch"), [])
+shutil.rmtree(packaging_dir)
+
 def test_option_submodules(self):
 """Test the --git-submodules option"""
 repo = self.init_test_repo('gbp-test')
-- 
2.7.0


-- 
Tzafrir Cohen | tzaf...@jabber.org | VIM is
http://tzafrir.org.il || a Mutt's
tzaf...@cohens.org.il ||  best
tzaf...@debian.org|| friend
___
git-buildpackage mailing list
git-buildpackage@lists.sigxcpu.org
http://lists.sigxcpu.org/mailman/listinfo/git-buildpackage