Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # Development tool - upgrade command plugin |
| 2 | # |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 3 | # Copyright (C) 2014-2017 Intel Corporation |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4 | # |
| 5 | # This program is free software; you can redistribute it and/or modify |
| 6 | # it under the terms of the GNU General Public License version 2 as |
| 7 | # published by the Free Software Foundation. |
| 8 | # |
| 9 | # This program is distributed in the hope that it will be useful, |
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | # GNU General Public License for more details. |
| 13 | # |
| 14 | # You should have received a copy of the GNU General Public License along |
| 15 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | # |
| 18 | """Devtool upgrade plugin""" |
| 19 | |
| 20 | import os |
| 21 | import sys |
| 22 | import re |
| 23 | import shutil |
| 24 | import tempfile |
| 25 | import logging |
| 26 | import argparse |
| 27 | import scriptutils |
| 28 | import errno |
| 29 | import bb |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 30 | |
| 31 | devtool_path = os.path.dirname(os.path.realpath(__file__)) + '/../../../meta/lib' |
| 32 | sys.path = sys.path + [devtool_path] |
| 33 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | import oe.recipeutils |
| 35 | from devtool import standard |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 36 | from devtool import exec_build_env_command, setup_tinfoil, DevtoolError, parse_recipe, use_external_build, update_unlockedsigs, check_prerelease_version |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 37 | |
| 38 | logger = logging.getLogger('devtool') |
| 39 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | def _run(cmd, cwd=''): |
| 41 | logger.debug("Running command %s> %s" % (cwd,cmd)) |
| 42 | return bb.process.run('%s' % cmd, cwd=cwd) |
| 43 | |
| 44 | def _get_srctree(tmpdir): |
| 45 | srctree = tmpdir |
| 46 | dirs = os.listdir(tmpdir) |
| 47 | if len(dirs) == 1: |
| 48 | srctree = os.path.join(tmpdir, dirs[0]) |
| 49 | return srctree |
| 50 | |
| 51 | def _copy_source_code(orig, dest): |
| 52 | for path in standard._ls_tree(orig): |
| 53 | dest_dir = os.path.join(dest, os.path.dirname(path)) |
| 54 | bb.utils.mkdirhier(dest_dir) |
| 55 | dest_path = os.path.join(dest, path) |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 56 | shutil.move(os.path.join(orig, path), dest_path) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 57 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 58 | def _remove_patch_dirs(recipefolder): |
| 59 | for root, dirs, files in os.walk(recipefolder): |
| 60 | for d in dirs: |
| 61 | shutil.rmtree(os.path.join(root,d)) |
| 62 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 63 | def _recipe_contains(rd, var): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 64 | rf = rd.getVar('FILE') |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 65 | varfiles = oe.recipeutils.get_var_files(rf, [var], rd) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 66 | for var, fn in varfiles.items(): |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 67 | if fn and fn.startswith(os.path.dirname(rf) + os.sep): |
| 68 | return True |
| 69 | return False |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 70 | |
| 71 | def _rename_recipe_dirs(oldpv, newpv, path): |
| 72 | for root, dirs, files in os.walk(path): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 73 | # Rename directories with the version in their name |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 74 | for olddir in dirs: |
| 75 | if olddir.find(oldpv) != -1: |
| 76 | newdir = olddir.replace(oldpv, newpv) |
| 77 | if olddir != newdir: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 78 | shutil.move(os.path.join(path, olddir), os.path.join(path, newdir)) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 79 | # Rename any inc files with the version in their name (unusual, but possible) |
| 80 | for oldfile in files: |
| 81 | if oldfile.endswith('.inc'): |
| 82 | if oldfile.find(oldpv) != -1: |
| 83 | newfile = oldfile.replace(oldpv, newpv) |
| 84 | if oldfile != newfile: |
| 85 | os.rename(os.path.join(path, oldfile), os.path.join(path, newfile)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 87 | def _rename_recipe_file(oldrecipe, bpn, oldpv, newpv, path): |
| 88 | oldrecipe = os.path.basename(oldrecipe) |
| 89 | if oldrecipe.endswith('_%s.bb' % oldpv): |
| 90 | newrecipe = '%s_%s.bb' % (bpn, newpv) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 91 | if oldrecipe != newrecipe: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 92 | shutil.move(os.path.join(path, oldrecipe), os.path.join(path, newrecipe)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 93 | else: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 94 | newrecipe = oldrecipe |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | return os.path.join(path, newrecipe) |
| 96 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 97 | def _rename_recipe_files(oldrecipe, bpn, oldpv, newpv, path): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 98 | _rename_recipe_dirs(oldpv, newpv, path) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 99 | return _rename_recipe_file(oldrecipe, bpn, oldpv, newpv, path) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 100 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 101 | def _write_append(rc, srctree, same_dir, no_same_dir, rev, copied, workspace, d): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 102 | """Writes an append file""" |
| 103 | if not os.path.exists(rc): |
| 104 | raise DevtoolError("bbappend not created because %s does not exist" % rc) |
| 105 | |
| 106 | appendpath = os.path.join(workspace, 'appends') |
| 107 | if not os.path.exists(appendpath): |
| 108 | bb.utils.mkdirhier(appendpath) |
| 109 | |
| 110 | brf = os.path.basename(os.path.splitext(rc)[0]) # rc basename |
| 111 | |
| 112 | srctree = os.path.abspath(srctree) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 113 | pn = d.getVar('PN') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 114 | af = os.path.join(appendpath, '%s.bbappend' % brf) |
| 115 | with open(af, 'w') as f: |
| 116 | f.write('FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n\n') |
| 117 | f.write('inherit externalsrc\n') |
| 118 | f.write(('# NOTE: We use pn- overrides here to avoid affecting' |
| 119 | 'multiple variants in the case where the recipe uses BBCLASSEXTEND\n')) |
| 120 | f.write('EXTERNALSRC_pn-%s = "%s"\n' % (pn, srctree)) |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 121 | b_is_s = use_external_build(same_dir, no_same_dir, d) |
| 122 | if b_is_s: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 123 | f.write('EXTERNALSRC_BUILD_pn-%s = "%s"\n' % (pn, srctree)) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 124 | f.write('\n') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 125 | if rev: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 126 | f.write('# initial_rev: %s\n' % rev) |
| 127 | if copied: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 128 | f.write('# original_path: %s\n' % os.path.dirname(d.getVar('FILE'))) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 129 | f.write('# original_files: %s\n' % ' '.join(copied)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 130 | return af |
| 131 | |
| 132 | def _cleanup_on_error(rf, srctree): |
| 133 | rfp = os.path.split(rf)[0] # recipe folder |
| 134 | rfpp = os.path.split(rfp)[0] # recipes folder |
| 135 | if os.path.exists(rfp): |
| 136 | shutil.rmtree(b) |
| 137 | if not len(os.listdir(rfpp)): |
| 138 | os.rmdir(rfpp) |
| 139 | srctree = os.path.abspath(srctree) |
| 140 | if os.path.exists(srctree): |
| 141 | shutil.rmtree(srctree) |
| 142 | |
| 143 | def _upgrade_error(e, rf, srctree): |
| 144 | if rf: |
| 145 | cleanup_on_error(rf, srctree) |
| 146 | logger.error(e) |
| 147 | raise DevtoolError(e) |
| 148 | |
| 149 | def _get_uri(rd): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 150 | srcuris = rd.getVar('SRC_URI').split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 151 | if not len(srcuris): |
| 152 | raise DevtoolError('SRC_URI not found on recipe') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 153 | # Get first non-local entry in SRC_URI - usually by convention it's |
| 154 | # the first entry, but not always! |
| 155 | srcuri = None |
| 156 | for entry in srcuris: |
| 157 | if not entry.startswith('file://'): |
| 158 | srcuri = entry |
| 159 | break |
| 160 | if not srcuri: |
| 161 | raise DevtoolError('Unable to find non-local entry in SRC_URI') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 162 | srcrev = '${AUTOREV}' |
| 163 | if '://' in srcuri: |
| 164 | # Fetch a URL |
| 165 | rev_re = re.compile(';rev=([^;]+)') |
| 166 | res = rev_re.search(srcuri) |
| 167 | if res: |
| 168 | srcrev = res.group(1) |
| 169 | srcuri = rev_re.sub('', srcuri) |
| 170 | return srcuri, srcrev |
| 171 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 172 | def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, keep_temp, tinfoil, rd): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 173 | """Extract sources of a recipe with a new version""" |
| 174 | |
| 175 | def __run(cmd): |
| 176 | """Simple wrapper which calls _run with srctree as cwd""" |
| 177 | return _run(cmd, srctree) |
| 178 | |
| 179 | crd = rd.createCopy() |
| 180 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 181 | pv = crd.getVar('PV') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 182 | crd.setVar('PV', newpv) |
| 183 | |
| 184 | tmpsrctree = None |
| 185 | uri, rev = _get_uri(crd) |
| 186 | if srcrev: |
| 187 | rev = srcrev |
| 188 | if uri.startswith('git://'): |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 189 | __run('git fetch') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 190 | __run('git checkout %s' % rev) |
| 191 | __run('git tag -f devtool-base-new') |
| 192 | md5 = None |
| 193 | sha256 = None |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 194 | _, _, _, _, _, params = bb.fetch2.decodeurl(uri) |
| 195 | srcsubdir_rel = params.get('destsuffix', 'git') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 196 | if not srcbranch: |
| 197 | check_branch, check_branch_err = __run('git branch -r --contains %s' % srcrev) |
| 198 | get_branch = [x.strip() for x in check_branch.splitlines()] |
| 199 | # Remove HEAD reference point and drop remote prefix |
| 200 | get_branch = [x.split('/', 1)[1] for x in get_branch if not x.startswith('origin/HEAD')] |
| 201 | if 'master' in get_branch: |
| 202 | # If it is master, we do not need to append 'branch=master' as this is default. |
| 203 | # Even with the case where get_branch has multiple objects, if 'master' is one |
| 204 | # of them, we should default take from 'master' |
| 205 | srcbranch = '' |
| 206 | elif len(get_branch) == 1: |
| 207 | # If 'master' isn't in get_branch and get_branch contains only ONE object, then store result into 'srcbranch' |
| 208 | srcbranch = get_branch[0] |
| 209 | else: |
| 210 | # If get_branch contains more than one objects, then display error and exit. |
| 211 | mbrch = '\n ' + '\n '.join(get_branch) |
| 212 | raise DevtoolError('Revision %s was found on multiple branches: %s\nPlease provide the correct branch in the devtool command with "--srcbranch" or "-B" option.' % (srcrev, mbrch)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 213 | else: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 214 | __run('git checkout devtool-base -b devtool-%s' % newpv) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 215 | |
| 216 | tmpdir = tempfile.mkdtemp(prefix='devtool') |
| 217 | try: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 218 | checksums, ftmpdir = scriptutils.fetch_url(tinfoil, uri, rev, tmpdir, logger, preserve_tmp=keep_temp) |
| 219 | except scriptutils.FetchUrlFailure as e: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 220 | raise DevtoolError(e) |
| 221 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 222 | if ftmpdir and keep_temp: |
| 223 | logger.info('Fetch temp directory is %s' % ftmpdir) |
| 224 | |
| 225 | md5 = checksums['md5sum'] |
| 226 | sha256 = checksums['sha256sum'] |
| 227 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 228 | tmpsrctree = _get_srctree(tmpdir) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 229 | srctree = os.path.abspath(srctree) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 230 | srcsubdir_rel = os.path.relpath(tmpsrctree, tmpdir) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 231 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 232 | # Delete all sources so we ensure no stray files are left over |
| 233 | for item in os.listdir(srctree): |
| 234 | if item in ['.git', 'oe-local-files']: |
| 235 | continue |
| 236 | itempath = os.path.join(srctree, item) |
| 237 | if os.path.isdir(itempath): |
| 238 | shutil.rmtree(itempath) |
| 239 | else: |
| 240 | os.remove(itempath) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 241 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 242 | # Copy in new ones |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 243 | _copy_source_code(tmpsrctree, srctree) |
| 244 | |
| 245 | (stdout,_) = __run('git ls-files --modified --others --exclude-standard') |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 246 | filelist = stdout.splitlines() |
| 247 | pbar = bb.ui.knotty.BBProgress('Adding changed files', len(filelist)) |
| 248 | pbar.start() |
| 249 | batchsize = 100 |
| 250 | for i in range(0, len(filelist), batchsize): |
| 251 | batch = filelist[i:i+batchsize] |
| 252 | __run('git add -A %s' % ' '.join(['"%s"' % item for item in batch])) |
| 253 | pbar.update(i) |
| 254 | pbar.finish() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 255 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 256 | useroptions = [] |
| 257 | oe.patch.GitApplyTree.gitCommandUserOptions(useroptions, d=rd) |
| 258 | __run('git %s commit -q -m "Commit of upstream changes at version %s" --allow-empty' % (' '.join(useroptions), newpv)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 259 | __run('git tag -f devtool-base-%s' % newpv) |
| 260 | |
| 261 | (stdout, _) = __run('git rev-parse HEAD') |
| 262 | rev = stdout.rstrip() |
| 263 | |
| 264 | if no_patch: |
| 265 | patches = oe.recipeutils.get_recipe_patches(crd) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 266 | if patches: |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 267 | logger.warning('By user choice, the following patches will NOT be applied to the new source tree:\n %s' % '\n '.join([os.path.basename(patch) for patch in patches])) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 268 | else: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 269 | __run('git checkout devtool-patched -b %s' % branch) |
| 270 | skiptag = False |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 271 | try: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 272 | __run('git rebase %s' % rev) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 273 | except bb.process.ExecutionError as e: |
| 274 | skiptag = True |
| 275 | if 'conflict' in e.stdout: |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 276 | logger.warning('Command \'%s\' failed:\n%s\n\nYou will need to resolve conflicts in order to complete the upgrade.' % (e.command, e.stdout.rstrip())) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 277 | else: |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 278 | logger.warning('Command \'%s\' failed:\n%s' % (e.command, e.stdout)) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 279 | if not skiptag: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 280 | if uri.startswith('git://'): |
| 281 | suffix = 'new' |
| 282 | else: |
| 283 | suffix = newpv |
| 284 | __run('git tag -f devtool-patched-%s' % suffix) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 285 | |
| 286 | if tmpsrctree: |
| 287 | if keep_temp: |
| 288 | logger.info('Preserving temporary directory %s' % tmpsrctree) |
| 289 | else: |
| 290 | shutil.rmtree(tmpsrctree) |
| 291 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 292 | return (rev, md5, sha256, srcbranch, srcsubdir_rel) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 293 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 294 | def _add_license_diff_to_recipe(path, diff): |
| 295 | notice_text = """# FIXME: the LIC_FILES_CHKSUM values have been updated by 'devtool upgrade'. |
| 296 | # The following is the difference between the old and the new license text. |
| 297 | # Please update the LICENSE value if needed, and summarize the changes in |
| 298 | # the commit message via 'License-Update:' tag. |
| 299 | # (example: 'License-Update: copyright years updated.') |
| 300 | # |
| 301 | # The changes: |
| 302 | # |
| 303 | """ |
| 304 | commented_diff = "\n".join(["# {}".format(l) for l in diff.split('\n')]) |
| 305 | with open(path, 'rb') as f: |
| 306 | orig_content = f.read() |
| 307 | with open(path, 'wb') as f: |
| 308 | f.write(notice_text.encode()) |
| 309 | f.write(commented_diff.encode()) |
| 310 | f.write("\n#\n\n".encode()) |
| 311 | f.write(orig_content) |
| 312 | |
| 313 | def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, srcsubdir_new, workspace, tinfoil, rd, license_diff, new_licenses): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 314 | """Creates the new recipe under workspace""" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 315 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 316 | bpn = rd.getVar('BPN') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 317 | path = os.path.join(workspace, 'recipes', bpn) |
| 318 | bb.utils.mkdirhier(path) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 319 | copied, _ = oe.recipeutils.copy_recipe_files(rd, path, all_variants=True) |
| 320 | if not copied: |
| 321 | raise DevtoolError('Internal error - no files were copied for recipe %s' % bpn) |
| 322 | logger.debug('Copied %s to %s' % (copied, path)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 323 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 324 | oldpv = rd.getVar('PV') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 325 | if not newpv: |
| 326 | newpv = oldpv |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 327 | origpath = rd.getVar('FILE') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 328 | fullpath = _rename_recipe_files(origpath, bpn, oldpv, newpv, path) |
| 329 | logger.debug('Upgraded %s => %s' % (origpath, fullpath)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 330 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 331 | newvalues = {} |
| 332 | if _recipe_contains(rd, 'PV') and newpv != oldpv: |
| 333 | newvalues['PV'] = newpv |
| 334 | |
| 335 | if srcrev: |
| 336 | newvalues['SRCREV'] = srcrev |
| 337 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 338 | if srcbranch: |
| 339 | src_uri = oe.recipeutils.split_var_value(rd.getVar('SRC_URI', False) or '') |
| 340 | changed = False |
| 341 | replacing = True |
| 342 | new_src_uri = [] |
| 343 | for entry in src_uri: |
| 344 | scheme, network, path, user, passwd, params = bb.fetch2.decodeurl(entry) |
| 345 | if replacing and scheme in ['git', 'gitsm']: |
| 346 | branch = params.get('branch', 'master') |
| 347 | if rd.expand(branch) != srcbranch: |
| 348 | # Handle case where branch is set through a variable |
| 349 | res = re.match(r'\$\{([^}@]+)\}', branch) |
| 350 | if res: |
| 351 | newvalues[res.group(1)] = srcbranch |
| 352 | # We know we won't change SRC_URI now, so break out |
| 353 | break |
| 354 | else: |
| 355 | params['branch'] = srcbranch |
| 356 | entry = bb.fetch2.encodeurl((scheme, network, path, user, passwd, params)) |
| 357 | changed = True |
| 358 | replacing = False |
| 359 | new_src_uri.append(entry) |
| 360 | if changed: |
| 361 | newvalues['SRC_URI'] = ' '.join(new_src_uri) |
| 362 | |
| 363 | newvalues['PR'] = None |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 364 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 365 | # Work out which SRC_URI entries have changed in case the entry uses a name |
| 366 | crd = rd.createCopy() |
| 367 | crd.setVar('PV', newpv) |
| 368 | for var, value in newvalues.items(): |
| 369 | crd.setVar(var, value) |
| 370 | old_src_uri = (rd.getVar('SRC_URI') or '').split() |
| 371 | new_src_uri = (crd.getVar('SRC_URI') or '').split() |
| 372 | newnames = [] |
| 373 | addnames = [] |
| 374 | for newentry in new_src_uri: |
| 375 | _, _, _, _, _, params = bb.fetch2.decodeurl(newentry) |
| 376 | if 'name' in params: |
| 377 | newnames.append(params['name']) |
| 378 | if newentry not in old_src_uri: |
| 379 | addnames.append(params['name']) |
| 380 | # Find what's been set in the original recipe |
| 381 | oldnames = [] |
| 382 | noname = False |
| 383 | for varflag in rd.getVarFlags('SRC_URI'): |
| 384 | if varflag.endswith(('.md5sum', '.sha256sum')): |
| 385 | name = varflag.rsplit('.', 1)[0] |
| 386 | if name not in oldnames: |
| 387 | oldnames.append(name) |
| 388 | elif varflag in ['md5sum', 'sha256sum']: |
| 389 | noname = True |
| 390 | # Even if SRC_URI has named entries it doesn't have to actually use the name |
| 391 | if noname and addnames and addnames[0] not in oldnames: |
| 392 | addnames = [] |
| 393 | # Drop any old names (the name actually might include ${PV}) |
| 394 | for name in oldnames: |
| 395 | if name not in newnames: |
| 396 | newvalues['SRC_URI[%s.md5sum]' % name] = None |
| 397 | newvalues['SRC_URI[%s.sha256sum]' % name] = None |
| 398 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 399 | if md5 and sha256: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 400 | if addnames: |
| 401 | nameprefix = '%s.' % addnames[0] |
| 402 | else: |
| 403 | nameprefix = '' |
| 404 | newvalues['SRC_URI[%smd5sum]' % nameprefix] = md5 |
| 405 | newvalues['SRC_URI[%ssha256sum]' % nameprefix] = sha256 |
| 406 | |
| 407 | if srcsubdir_new != srcsubdir_old: |
| 408 | s_subdir_old = os.path.relpath(os.path.abspath(rd.getVar('S')), rd.getVar('WORKDIR')) |
| 409 | s_subdir_new = os.path.relpath(os.path.abspath(crd.getVar('S')), crd.getVar('WORKDIR')) |
| 410 | if srcsubdir_old == s_subdir_old and srcsubdir_new != s_subdir_new: |
| 411 | # Subdir for old extracted source matches what S points to (it should!) |
| 412 | # but subdir for new extracted source doesn't match what S will be |
| 413 | newvalues['S'] = '${WORKDIR}/%s' % srcsubdir_new.replace(newpv, '${PV}') |
| 414 | if crd.expand(newvalues['S']) == crd.expand('${WORKDIR}/${BP}'): |
| 415 | # It's the default, drop it |
| 416 | # FIXME what if S is being set in a .inc? |
| 417 | newvalues['S'] = None |
| 418 | logger.info('Source subdirectory has changed, dropping S value since it now matches the default ("${WORKDIR}/${BP}")') |
| 419 | else: |
| 420 | logger.info('Source subdirectory has changed, updating S value') |
| 421 | |
| 422 | if license_diff: |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 423 | newlicchksum = " ".join(["file://{}".format(l['path']) + |
| 424 | (";beginline={}".format(l['beginline']) if l['beginline'] else "") + |
| 425 | (";endline={}".format(l['endline']) if l['endline'] else "") + |
| 426 | (";md5={}".format(l['actual_md5'])) for l in new_licenses]) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 427 | newvalues["LIC_FILES_CHKSUM"] = newlicchksum |
| 428 | _add_license_diff_to_recipe(fullpath, license_diff) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 429 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 430 | rd = tinfoil.parse_recipe_file(fullpath, False) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 431 | oe.recipeutils.patch_recipe(rd, fullpath, newvalues) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 432 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 433 | return fullpath, copied |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 434 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 435 | |
| 436 | def _check_git_config(): |
| 437 | def getconfig(name): |
| 438 | try: |
| 439 | value = bb.process.run('git config --global %s' % name)[0].strip() |
| 440 | except bb.process.ExecutionError as e: |
| 441 | if e.exitcode == 1: |
| 442 | value = None |
| 443 | else: |
| 444 | raise |
| 445 | return value |
| 446 | |
| 447 | username = getconfig('user.name') |
| 448 | useremail = getconfig('user.email') |
| 449 | configerr = [] |
| 450 | if not username: |
| 451 | configerr.append('Please set your name using:\n git config --global user.name') |
| 452 | if not useremail: |
| 453 | configerr.append('Please set your email using:\n git config --global user.email') |
| 454 | if configerr: |
| 455 | raise DevtoolError('Your git configuration is incomplete which will prevent rebases from working:\n' + '\n'.join(configerr)) |
| 456 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 457 | def _extract_licenses(srcpath, recipe_licenses): |
| 458 | licenses = [] |
| 459 | for url in recipe_licenses.split(): |
| 460 | license = {} |
| 461 | (type, host, path, user, pswd, parm) = bb.fetch.decodeurl(url) |
| 462 | license['path'] = path |
| 463 | license['md5'] = parm.get('md5', '') |
| 464 | license['beginline'], license['endline'] = 0, 0 |
| 465 | if 'beginline' in parm: |
| 466 | license['beginline'] = int(parm['beginline']) |
| 467 | if 'endline' in parm: |
| 468 | license['endline'] = int(parm['endline']) |
| 469 | license['text'] = [] |
| 470 | with open(os.path.join(srcpath, path), 'rb') as f: |
| 471 | import hashlib |
| 472 | actual_md5 = hashlib.md5() |
| 473 | lineno = 0 |
| 474 | for line in f: |
| 475 | lineno += 1 |
| 476 | if (lineno >= license['beginline']) and ((lineno <= license['endline']) or not license['endline']): |
| 477 | license['text'].append(line.decode(errors='ignore')) |
| 478 | actual_md5.update(line) |
| 479 | license['actual_md5'] = actual_md5.hexdigest() |
| 480 | licenses.append(license) |
| 481 | return licenses |
| 482 | |
| 483 | def _generate_license_diff(old_licenses, new_licenses): |
| 484 | need_diff = False |
| 485 | for l in new_licenses: |
| 486 | if l['md5'] != l['actual_md5']: |
| 487 | need_diff = True |
| 488 | break |
| 489 | if need_diff == False: |
| 490 | return None |
| 491 | |
| 492 | import difflib |
| 493 | diff = '' |
| 494 | for old, new in zip(old_licenses, new_licenses): |
| 495 | for line in difflib.unified_diff(old['text'], new['text'], old['path'], new['path']): |
| 496 | diff = diff + line |
| 497 | return diff |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 498 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 499 | def upgrade(args, config, basepath, workspace): |
| 500 | """Entry point for the devtool 'upgrade' subcommand""" |
| 501 | |
| 502 | if args.recipename in workspace: |
| 503 | raise DevtoolError("recipe %s is already in your workspace" % args.recipename) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 504 | if args.srcbranch and not args.srcrev: |
| 505 | raise DevtoolError("If you specify --srcbranch/-B then you must use --srcrev/-S to specify the revision" % args.recipename) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 506 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 507 | _check_git_config() |
| 508 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 509 | tinfoil = setup_tinfoil(basepath=basepath, tracking=True) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 510 | try: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 511 | rd = parse_recipe(config, tinfoil, args.recipename, True) |
| 512 | if not rd: |
| 513 | return 1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 514 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 515 | pn = rd.getVar('PN') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 516 | if pn != args.recipename: |
| 517 | logger.info('Mapping %s to %s' % (args.recipename, pn)) |
| 518 | if pn in workspace: |
| 519 | raise DevtoolError("recipe %s is already in your workspace" % pn) |
| 520 | |
| 521 | if args.srctree: |
| 522 | srctree = os.path.abspath(args.srctree) |
| 523 | else: |
| 524 | srctree = standard.get_default_srctree(config, pn) |
| 525 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 526 | # try to automatically discover latest version and revision if not provided on command line |
| 527 | if not args.version and not args.srcrev: |
| 528 | version_info = oe.recipeutils.get_recipe_upstream_version(rd) |
| 529 | if version_info['version'] and not version_info['version'].endswith("new-commits-available"): |
| 530 | args.version = version_info['version'] |
| 531 | if version_info['revision']: |
| 532 | args.srcrev = version_info['revision'] |
| 533 | if not args.version and not args.srcrev: |
| 534 | raise DevtoolError("Automatic discovery of latest version/revision failed - you must provide a version using the --version/-V option, or for recipes that fetch from an SCM such as git, the --srcrev/-S option.") |
| 535 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 536 | standard._check_compatible_recipe(pn, rd) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 537 | old_srcrev = rd.getVar('SRCREV') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 538 | if old_srcrev == 'INVALID': |
| 539 | old_srcrev = None |
| 540 | if old_srcrev and not args.srcrev: |
| 541 | raise DevtoolError("Recipe specifies a SRCREV value; you must specify a new one when upgrading") |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 542 | old_ver = rd.getVar('PV') |
| 543 | if old_ver == args.version and old_srcrev == args.srcrev: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 544 | raise DevtoolError("Current and upgrade versions are the same version") |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 545 | if args.version: |
| 546 | if bb.utils.vercmp_string(args.version, old_ver) < 0: |
| 547 | logger.warning('Upgrade version %s compares as less than the current version %s. If you are using a package feed for on-target upgrades or providing this recipe for general consumption, then you should increment PE in the recipe (or if there is no current PE value set, set it to "1")' % (args.version, old_ver)) |
| 548 | check_prerelease_version(args.version, 'devtool upgrade') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 549 | |
| 550 | rf = None |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 551 | license_diff = None |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 552 | try: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 553 | logger.info('Extracting current version source...') |
| 554 | rev1, srcsubdir1 = standard._extract_source(srctree, False, 'devtool-orig', False, config, basepath, workspace, args.fixed_setup, rd, tinfoil, no_overrides=args.no_overrides) |
| 555 | old_licenses = _extract_licenses(srctree, rd.getVar('LIC_FILES_CHKSUM')) |
| 556 | logger.info('Extracting upgraded version source...') |
| 557 | rev2, md5, sha256, srcbranch, srcsubdir2 = _extract_new_source(args.version, srctree, args.no_patch, |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 558 | args.srcrev, args.srcbranch, args.branch, args.keep_temp, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 559 | tinfoil, rd) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 560 | new_licenses = _extract_licenses(srctree, rd.getVar('LIC_FILES_CHKSUM')) |
| 561 | license_diff = _generate_license_diff(old_licenses, new_licenses) |
| 562 | rf, copied = _create_new_recipe(args.version, md5, sha256, args.srcrev, srcbranch, srcsubdir1, srcsubdir2, config.workspace_path, tinfoil, rd, license_diff, new_licenses) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 563 | except bb.process.CmdError as e: |
| 564 | _upgrade_error(e, rf, srctree) |
| 565 | except DevtoolError as e: |
| 566 | _upgrade_error(e, rf, srctree) |
| 567 | standard._add_md5(config, pn, os.path.dirname(rf)) |
| 568 | |
| 569 | af = _write_append(rf, srctree, args.same_dir, args.no_same_dir, rev2, |
| 570 | copied, config.workspace_path, rd) |
| 571 | standard._add_md5(config, pn, af) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 572 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 573 | update_unlockedsigs(basepath, workspace, args.fixed_setup, [pn]) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 574 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 575 | logger.info('Upgraded source extracted to %s' % srctree) |
| 576 | logger.info('New recipe is %s' % rf) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 577 | if license_diff: |
| 578 | logger.info('License checksums have been updated in the new recipe; please refer to it for the difference between the old and the new license texts.') |
| 579 | finally: |
| 580 | tinfoil.shutdown() |
| 581 | return 0 |
| 582 | |
| 583 | def latest_version(args, config, basepath, workspace): |
| 584 | """Entry point for the devtool 'latest_version' subcommand""" |
| 585 | tinfoil = setup_tinfoil(basepath=basepath, tracking=True) |
| 586 | try: |
| 587 | rd = parse_recipe(config, tinfoil, args.recipename, True) |
| 588 | if not rd: |
| 589 | return 1 |
| 590 | version_info = oe.recipeutils.get_recipe_upstream_version(rd) |
| 591 | # "new-commits-available" is an indication that upstream never issues version tags |
| 592 | if not version_info['version'].endswith("new-commits-available"): |
| 593 | logger.info("Current version: {}".format(version_info['current_version'])) |
| 594 | logger.info("Latest version: {}".format(version_info['version'])) |
| 595 | if version_info['revision']: |
| 596 | logger.info("Latest version's commit: {}".format(version_info['revision'])) |
| 597 | else: |
| 598 | logger.info("Latest commit: {}".format(version_info['revision'])) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 599 | finally: |
| 600 | tinfoil.shutdown() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 601 | return 0 |
| 602 | |
| 603 | def register_commands(subparsers, context): |
| 604 | """Register devtool subcommands from this plugin""" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 605 | |
| 606 | defsrctree = standard.get_default_srctree(context.config) |
| 607 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 608 | parser_upgrade = subparsers.add_parser('upgrade', help='Upgrade an existing recipe', |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 609 | description='Upgrades an existing recipe to a new upstream version. Puts the upgraded recipe file into the workspace along with any associated files, and extracts the source tree to a specified location (in case patches need rebasing or adding to as a result of the upgrade).', |
| 610 | group='starting') |
| 611 | parser_upgrade.add_argument('recipename', help='Name of recipe to upgrade (just name - no version, path or extension)') |
| 612 | parser_upgrade.add_argument('srctree', nargs='?', help='Path to where to extract the source tree. If not specified, a subdirectory of %s will be used.' % defsrctree) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 613 | parser_upgrade.add_argument('--version', '-V', help='Version to upgrade to (PV). If omitted, latest upstream version will be determined and used, if possible.') |
| 614 | parser_upgrade.add_argument('--srcrev', '-S', help='Source revision to upgrade to (useful when fetching from an SCM such as git)') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 615 | parser_upgrade.add_argument('--srcbranch', '-B', help='Branch in source repository containing the revision to use (if fetching from an SCM such as git)') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 616 | parser_upgrade.add_argument('--branch', '-b', default="devtool", help='Name for new development branch to checkout (default "%(default)s")') |
| 617 | parser_upgrade.add_argument('--no-patch', action="store_true", help='Do not apply patches from the recipe to the new source code') |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 618 | parser_upgrade.add_argument('--no-overrides', '-O', action="store_true", help='Do not create branches for other override configurations') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 619 | group = parser_upgrade.add_mutually_exclusive_group() |
| 620 | group.add_argument('--same-dir', '-s', help='Build in same directory as source', action="store_true") |
| 621 | group.add_argument('--no-same-dir', help='Force build in a separate build directory', action="store_true") |
| 622 | parser_upgrade.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 623 | parser_upgrade.set_defaults(func=upgrade, fixed_setup=context.fixed_setup) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 624 | |
| 625 | parser_latest_version = subparsers.add_parser('latest-version', help='Report the latest version of an existing recipe', |
| 626 | description='Queries the upstream server for what the latest upstream release is (for git, tags are checked, for tarballs, a list of them is obtained, and one with the highest version number is reported)', |
| 627 | group='info') |
| 628 | parser_latest_version.add_argument('recipename', help='Name of recipe to query (just name - no version, path or extension)') |
| 629 | parser_latest_version.set_defaults(func=latest_version) |