from gitbuildsys import msger, utils, runner, errors
from gitbuildsys.conf import configmgr
from gitbuildsys.safe_url import SafeURL
-from gitbuildsys.cmd_export import transform_var_format_from_shell_to_python
+from gitbuildsys.cmd_export import transform_var_format_from_shell_to_python, \
+ get_packaging_dir
from gbp.rpm.git import GitRepositoryError, RpmGitRepository
args.binary_list)
cmd_opts += ['--binary=%s' % args.binary_list]
cmd_opts += ['--threads=%s' % args.threads]
+ cmd_opts += ['--packaging-dir=%s' % get_packaging_dir(args)]
return cmd_opts
from gitbuildsys import msger, utils
from gitbuildsys.conf import configmgr
+from gitbuildsys.cmd_export import get_packaging_dir
from gbp.rpm.git import GitRepositoryError, RpmGitRepository
project_root_dir = repo.path
- changes_file_list = glob.glob("%s/packaging/*.changes" % project_root_dir)
+ packaging_dir = get_packaging_dir(args)
+ changes_file_list = glob.glob("%s/%s/*.changes" % (project_root_dir,
+ packaging_dir))
if changes_file_list:
fn_changes = changes_file_list[0]
% (changes_file_list[0]))
else:
# Create .changes file with the same name as a spec
- specfile = utils.guess_spec(project_root_dir, args.spec)
+ specfile = utils.guess_spec(project_root_dir, packaging_dir, args.spec)
fn_changes = os.path.splitext(specfile)[0] + ".changes"
# get the commit start from the args.since
upstream_branch = configmgr.get('upstream_branch', 'general')
return not repo.has_branch(upstream_branch)
+def get_packaging_dir(args):
+ """
+ Determine the packaging dir to be used
+ """
+ if args.packaging_dir:
+ return args.packaging_dir
+ return configmgr.get('packaging_dir', 'general')
+
def transform_var_format_from_shell_to_python(whole):
'''replace string like ${xxx} with %(xxx)s'''
return re.sub(r'\$\{([^}]+)\}', r'%(\1)s', whole)
"--git-upstream-branch=upstream",
"--git-export-dir=%s" % export_dir,
"--git-tmp-dir=%s" % tmp_dir,
- "--git-packaging-dir=packaging",
+ "--git-packaging-dir=%s" % get_packaging_dir(args),
"--git-spec-file=%s" % spec,
"--git-export=%s" % commit,
"--git-upstream-branch=%s" % upstream_branch,
utils.git_status_checker(repo, args)
workdir = repo.path
- if not os.path.exists("%s/packaging" % workdir):
- msger.error('No packaging directory, so there is nothing to export.')
+ packaging_dir = get_packaging_dir(args)
+ if not os.path.exists(os.path.join(workdir, packaging_dir)):
+ msger.error("No packaging directory '%s/', so there is nothing to "
+ "export." % packaging_dir)
# Only guess spec filename here, parse later when we have the correct
# spec file at hand
- specfile = utils.guess_spec(workdir, args.spec)
+ specfile = utils.guess_spec(workdir, packaging_dir, args.spec)
outdir = "%s/packaging" % workdir
if args.outdir:
import os
from gitbuildsys import msger
+from gitbuildsys.cmd_export import get_packaging_dir
from gbp.scripts.import_srpm import main as gbp_import_srpm
from gbp.scripts.import_orig_rpm import main as gbp_import_orig
path = args.path
- params = ["argv[0] placeholder", "--packaging-dir=packaging",
+ params = ["argv[0] placeholder",
+ "--packaging-dir=%s" % get_packaging_dir(args),
"--upstream-branch=%s" % args.upstream_branch, path]
if path.endswith('.src.rpm') or path.endswith('.spec'):
from gitbuildsys.conf import configmgr, encode_passwd
from gitbuildsys.oscapi import OSC, OSCError
-from gitbuildsys.cmd_export import export_sources
+from gitbuildsys.cmd_export import export_sources, get_packaging_dir
from gitbuildsys.cmd_build import get_profile
import gbp.rpm
utils.git_status_checker(repo, args)
# TODO: check ./packaging dir at first
- specs = glob.glob('%s/packaging/*.spec' % workdir)
+ packaging_dir = get_packaging_dir(args)
+ specs = glob.glob('%s/%s/*.spec' % (workdir, packaging_dir))
if not specs:
- msger.error('no spec file found under /packaging sub-directory')
+ msger.error("no spec file found under './%s'" % packaging_dir)
- specfile = utils.guess_spec(workdir, args.spec)
+ specfile = utils.guess_spec(workdir, packaging_dir, args.spec)
# get 'name' and 'version' from spec file
try:
spec = gbp.rpm.parse_spec(specfile)
'upstream_tag': 'upstream/${upstreamversion}',
'squash_patches_until': '',
'buildroot': '~/GBS-ROOT/',
+ 'packaging_dir': 'packaging',
},
}
def __exit__(self, _type, _value, _tb):
os.chdir(self._cwd)
-def guess_spec(workdir, default_spec):
+def guess_spec(workdir, packaging_dir, default_spec):
workdir = os.path.abspath(workdir)
git_project = os.path.basename(workdir)
msger.error('%s does not exit' % default_spec)
return default_spec
- specfile = os.path.join(workdir, 'packaging', '%s.spec' % git_project)
+ specfile = os.path.join(workdir, packaging_dir, '%s.spec' % git_project)
if not os.path.exists(specfile):
- specs = glob.glob(os.path.join(workdir, 'packaging', '*.spec'))
+ specs = glob.glob(os.path.join(workdir, packaging_dir, '*.spec'))
if not specs:
- msger.error('no spec file found under %s/packaging' % workdir)
+ msger.error('no spec file found under %s/%s' % (workdir,
+ packaging_dir))
if len(specs) > 1:
msger.error("Can't decide which spec file to use.")
help='specify upstream branch for new package version')
parser.add_argument('--no-merge', action='store_true',
help='don\'t merge new upstream branch to master')
+ parser.add_argument('--packaging-dir',
+ help='directory containing packaging files')
parser.set_defaults(alias="im")
return parser
'to given commit-ish into one monolithic diff file. '
'Format is the commit-ish optionally followed by a '
'colon and diff filename base.')
+ parser.add_argument('--packaging-dir',
+ help='directory containing packaging files')
parser.set_defaults(alias="ex")
return parser
'to given commit-ish into one monolithic diff file. '
'Format is the commit-ish optionally followed by a '
'colon and diff filename base.')
+ parser.add_argument('--packaging-dir',
+ help='directory containing packaging files')
# depanneur special options
parser.add_argument('--clean-once', action='store_true',
'given commit-ish into one monolithic diff file. '
'Format is the commit-ish optionally followed by a '
'colon and diff filename base.')
+ parser.add_argument('--packaging-dir',
+ help='directory containing packaging files')
parser.set_defaults(alias="rb")
return parser
help='commit to start from')
parser.add_argument('-m', '--message',
help='use given message as the changelog entry')
+ parser.add_argument('--packaging-dir',
+ help='directory containing packaging files')
parser.set_defaults(alias='ch')
return parser