else:
raise GbsError('failed to create %s: %s' % (path, exc.strerror))
+def config_is_true(config_value):
+ """Return if a config value is true"""
+ if isinstance(config_value, bool):
+ return config_value
+ if config_value.lower() in ['yes', 'on', '1', 'true', 'enabled']:
+ return True
+ return False
+
def is_native_pkg(repo, args):
"""
Determine if the package is "native"
try:
ret = gbp_build(gbp_args)
if ret == 2 and not is_native_pkg(repo, args):
- # Try falling back to old logic of one monolithic tarball
- log.error("Generating upstream tarball and/or generating patches "
+ errmsg = ("Generating upstream tarball and/or generating patches "
"failed. GBS tried this as you have upstream branch in "
"you git tree. Fix the problem by either:\n"
" 1. Update your upstream branch and/or fix the spec "
"package to native)\n"
"See https://source.tizen.org/documentation/reference/"
"git-build-system/upstream-package for more details.")
+ fallback = configmgr.get_arg_conf(args, 'fallback_to_native')
+ if config_is_true(fallback):
+ # Try falling back to old logic of one monolithic tarball
+ log.warn(errmsg)
+ log.info("Falling back to native, i.e. creating source archive "
+ "directly from exported commit, without any patches.")
+ gbp_args = create_gbp_export_args(repo, commit, export_dir,
+ tmp.path, spec, args,
+ force_native=True,
+ create_tarball=create_tarball)
+ ret = gbp_build(gbp_args)
+ else:
+ log.error(errmsg)
if ret:
raise GbsError("Failed to export packaging files from git tree")
except GitRepositoryError, excobj:
parser.add_argument('--include-all', action='store_true',
help='uncommitted changes and untracked files '
'would be included while generating tar ball')
+ parser.add_argument('--fallback-to-native', action='store_true',
+ default=None,
+ help='Fall back to native packaging mode (i.e. create '
+ 'tarball directly from exported commit, not from '
+ 'upstream tag, and without patches) in case patch '
+ 'or upstream tarball generation fails.')
parser.add_argument('--source-rpm', action='store_true',
help='generate source rpm')
parser.add_argument('--no-patch-export', action='store_true',
help="upstream tag format, '${upstreamversion}' is "
"expanded to the version in the spec file. "
"E.g. 'v${upstreamversion}'")
+ group.add_argument('--fallback-to-native', action='store_true',
+ default=None,
+ help='Fall back to native packaging mode (i.e. create '
+ 'tarball directly from exported commit, not from '
+ 'upstream tag, and without patches) in case patch '
+ 'or upstream tarball generation fails.')
group.add_argument('--squash-patches-until',
help='when generating patches, squash patches up '
'to given commit-ish into one monolithic diff file. '
parser.add_argument('--include-all', action='store_true',
help='uncommitted changes and untracked files will be '
'included while generating tar ball')
+ parser.add_argument('--fallback-to-native', action='store_true',
+ default=None,
+ help='Fall back to native packaging mode (i.e. create '
+ 'tarball directly from exported commit, not from '
+ 'upstream tag, and without patches) in case patch '
+ 'or upstream tarball generation fails.')
parser.add_argument('--upstream-branch', help='upstream branch')
parser.add_argument('--upstream-tag',
help="upstream tag format, '${upstreamversion}' is "