Commit Graph

372 Commits

Author SHA1 Message Date
Paul Eggleton
f82f5f2754 update: add option to stop immediately on parse errors
During debugging a parsing issue, we don't really want to continue if a
parsing error occurs, and in that situation I usually end up using
Ctrl+C to exit early. Add an option to exit immediately upon error to
avoid having to do that.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-24 16:41:59 +12:00
Paul Eggleton
b3e9cb05d2 Include errors/warnings in main log in error/warning counts for updates
When showing the error/warning counts for update records we need to
include any errors/warnings that are shown only in the main update log,
so we need to adjust how these are collected. Use a function rather than
pure aggregation to give a bit more control, and a {% with ... %} block
in the template to avoid the functions being called more than necessary.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-14 15:09:36 +02:00
Paul Eggleton
dafa4dc129 update: ensure that exceptions during the update process are logged
If an exception occurred during the update then we were managing to save
the update record, but we did not include the exception traceback in the
log for the update. Catch the exception and log it which ensures it gets
captured in the update record and still gets printed as well.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-14 15:09:36 +02:00
Paul Eggleton
db08df4a86 Improve collection/display of LayerUpdate records
Make layerupdate collection slightly more reliable and make it easier
to see when updates have actually been captured:

* Split layerbranch into separate layer and branch fields, since there
  may not be a layerbranch in existence but we might want to log an
  error relating to the branch and layer.
* Show all layerupdates on the update detail page, not just those with
  log messages
* Record before and after revisions and show these in the update detail
  and layerupdate detail (with links)
* Record return code of update_layer process
* Highlight layer updates with a non-zero return code, errors or
  warnings in the output on the update detail page
* Show duration on the layerupdate detail page

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-14 15:07:34 +02:00
Paul Eggleton
74ea84f696 update_layer: improve exception handling
When an exception occurs during the main part of update_layer, we were
catching and printing it but that's not enough - we need to do the
following as well:

* Use logger.error() to print the exception information, so that it gets
  logged and highlighted as an error in the layer update
* Exit with a non-zero return code so that update.py knows it has failed

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-14 15:07:34 +02:00
Paul Eggleton
143c8c25a9 update: avoid errors if values could not be found in initial output
If for some reason update_layer.py does not print out the values we
expect then we shouldn't be throwing a traceback, we should be handling
it gracefully - i.e., print an error and then move on to the next layer.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-14 08:46:36 +02:00
Paul Eggleton
d17080d325 Show links to include files on recipe detail
On the recipe detail page we provide a link to the actual recipe file
for reference purposes. However, for recipes that include a common .inc
file, many of the definitions of variable values will be inside the
.inc, therefore if you just look at the recipe you won't see the full
picture. Of course you can just go up to the parent directory in the
repository web interface, but for convenience's sake add links to any
files that are included/required by the recipe that are adjacent to
the recipe itself. (We already have the data in the form of the
RecipeFileDependency records that are intended to ensure we know when
the recipe needs to be updated if one of the files it includes changes).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:04:16 +02:00
Paul Eggleton
f38bae1dd9 Add side-by-side comparison detail and enhanced selection
Specifying the covering recipe in the comparison recipe detail page was
always a bit awkward - you could only type the name, if you wanted to
actually find a recipe or look up the currently selected one's details
then you had to open another browser tab/window. To fix this, replace
the form on the comparison recipe detail page with a side-by-side
display of the covering recipe's information, along with a button that
lets you search and then select the covering recipe and at the same time
enter comments or set any of the other cover fields.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:04:16 +02:00
Paul Eggleton
bc1757abf3 Show source URLs on recipe detail page
If we're collecting this useful info we should really display it. Try to
make the link clickable if possible.

At the same time, add the layerbranch to the list display for Source
objects in the admin site.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:04:16 +02:00
Paul Eggleton
4ee5c21c37 Add script to fetch Fedora package sources
Add a script to fetch package sources from Fedora's Pagure
infrastructure site at https://src.fedoraproject.org/, based upon
github-fetch.py (I broke out the internal fetch function with the intent
to share it with that other script, however I didn't in the end as I
wanted the scripts to remain independent).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:04:16 +02:00
Paul Eggleton
4266d8aec1 Add script to fetch all repos under a github organisation
Add a script to fetch/update all repositories within a GitHub
organisation. Note that to run this you will need an access token, which
you can create by going to GitHub and then
Settings -> Developer Settings -> Personal access tokens.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:04:16 +02:00
Paul Eggleton
9970028055 Add ability to trigger comparison updates manually from UI
Comparison updates might involve some custom fetch process, so provide a
mechanism to register these via settings.py on a per-branch basis. If
an update command is defined for a branch and the logged-in user has the
new "update_comparison_branch" permission, an "Update" button will show
up on the recipes page for the comparison branch for authenticated
users that will trigger the command in the background (as a celery job)
and then show a page that displays the status. The status isn't shown in
real-time since that requires quite a lot of plumbing, but the page at
least auto-refreshes.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:04:14 +02:00
Paul Eggleton
ca64ab7a51 Fix comparison layers showing up in dependencies list in edit layer page
We weren't filtering on the right flag here when editing (but we were
when submitting).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
66f8b43958 Rename LayerItem classic field to comparison
Make it clearer what this field is for (it should be set for every
comparison layer, so that they don't show up in places they shouldn't).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
99c7f0b916 rrs: show link to other distro comparison pages
If other distro comparison package(s) exist for a recipe being shown in
the RRS recipe detail page, link to the page for each package as well as
any extra URLs.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
383d043f1e Add ability to store extra URLs to be displayed for comparison recipes
Add a structure that lets you define a template URL per layer to be
shown per comparison recipe. For example, you could use this to define a
URL template to link to the upstream summary page for the package (e.g.
Fedora's page for the acl package is at
https://apps.fedoraproject.org/packages/acl, so you would use
https://apps.fedoraproject.org/packages/%pn% as the template and then
this would be shown for every package).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
fb2907a5d8 Add basic CSV export for other distro comparisons
Add the ability to export the comparison search results to CSV format in
order to allow importing the data into external tools.

Note: I implemented this in a different way than the earlier recipe CSV
export, i.e. it uses a template to render the CSV instead of a
function-based view with the Python csv module - the reason for this is
we can reuse the same view as we use for producing the search, with all
of the flexibility that gives us.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
09ef043f3f Support excluding inherited classes from other distro comparison reversed query
When doing the reversed query it's often desirable to exclude recipes
by inherited class, for example those that inherit the packagegroup,
image and meta classes as they don't actually build anything and thus
aren't going to match up with anything in the other distribution.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
26d2bd2f36 Support selecting more than one layer in other distro comparison search form
Provide a lazy-loaded popup for selecting layers to include in the query
instead of having it as a simple drop-down, so you can select more than
one layer.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
8ef315c6bf Support reversed other distro recipe list / filtering
Enable "reversing" the comparison, so you can see which recipes on the
OE side match up (or don't) with the other distro. The filtering for
this is a bit awkward, since we don't have an actual foreign key for the
link, hence the hairiness of the code.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
5c56e16a49 Add support for importing Debian package info
Add support for importing package information extracted from a running
Debian system (i.e. from the output of apt-cache show "*").

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
fcb44571fd Add "needs attention" flag for comparison recipes
Add a flag that can be set and searched for to indicate that we need to
take care of importing a package or a patch applied by a package.
Ideally the comments would elaborate on what's needed (if it's not
obvious from the cover status).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
ea8b656711 views: fix unknown categories comparison stats graph to include "Not available"
Packages with the "Not available" status were inexplicably excluded from
the graph, include them.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
ea77e75ddd Enhance filtering comparisons
Allow searching on:
* Any "available" status (i.e. other than "Unknown" or "Not available")
* Whether the package has patches or not
* What the covering layer is (assuming there is one).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
ca9c4ffa66 Allow searching for uncategorised recipes in the comparison search
It's a bit crude, but accept '' or "" as meaning search for entries
with an empty category.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
c98417f891 update_classic_status: add skip option
Add an option to skip certain recipes by name (a crude workaround for
when we would otherwise get an erroneous match).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
dd01e13519 update_classic_status: look for certain prefixes in order to match
Some typical package name prefixes can be recognised and used to match.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
7f9bd20e62 update_classic_status: use source URLs to match python/perl recipes
If the source URL is fetching from pypi then we know it's python;
similarly cpan means perl.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
dd64112a75 update_classic_status: set cover_pn from pn for direct match
If we always set cover_pn if there is a match rather than only setting
it if it's different from pn then it simplifies the code elsewhere.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
cbdd7771dd update_classic_status: update for other distro comparisons
* Only apply OE-Classic-specific logic after checking that it's actually
  OE-Classic
* Ignore recipes marked deleted

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:59 +02:00
Paul Eggleton
87e27a26d5 Add script to import from other distros
Add a script to import "recipe" information from other distro metadata,
based on the import_classic.py script. At the moment, this assumes a
directory where each subdirectory is a package directory containing a
spec file; this would be suitable for distributions such as Fedora
assuming you have all of the package repos checked out locally. Since
you can add additional information to these records (the cover fields
pointing to matching recipes), existing records are updated rather than
deleting everything and re-importing, and we only mark records as
deleted rather than actually deleting them (in case you accidentally
point the script at an empty directory or similar).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-13 16:02:53 +02:00
Paul Eggleton
72d67231ec Add support for other distro comparisons
Turn the existing OE-Classic support into something a bit more
generic so we can import data from other distributions and compare it to
what we have in layers.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-07 14:44:27 +02:00
Paul Eggleton
8ab9c15085 Add partial path macro for vcs URL fields
Add a %pathelement[]% macro that lets you extract just the nth element
or a slice and substitute it into the URL. This will be used so we can
treat multiple repos that appear under the same base URL as belonging to
the same comparison layer, e.g.
https://github.com/somedistro/<packagename>/... would be handled
using the file URL
https://github.com/somedistro/%pathelement[0]%/blob/master/%pathelement[1:]%
so that the path /abc/fix.patch would generate the URL
https://github.com/somedistro/abc/blob/master/fix.patch

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-07 14:44:27 +02:00
Paul Eggleton
7b9cea66a4 update_classic_status: fix matching on wrong layer
We were sorting the layers in the wrong order when trying to choose
which layer to pick a matching recipe from - it needs to be descending
priority order, not ascending.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-06 14:38:40 +02:00
Paul Eggleton
98be24336b Add a script to import layers from an existing layer index
Add a script that uses the REST API to gather information from another
running layer index instance (e.g. layers.openembedded.org) and import
that into the local index. Only information for branches that are
already set up is imported, and only manually entered information -
no recipes, machines, etc.

Partially implements [YOCTO #9760].

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-06 14:38:40 +02:00
Paul Eggleton
a40a5350e4 forms: clear out comparison recipe/layerbranch if status doesn't accept them
If the cover status for a comparison recipe is Unknown, Not available,
or Distro-specific, then we disable the recipe and layerbranch fields in
the form (using Javascript), however the form could still be saved and
any existing values would persist. Clear out the fields upon saving if
they are set under these circumstances.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-06 14:38:40 +02:00
Paul Eggleton
a5474811e1 admin: improve layer maintainer handling
* Allow searching in name and email fields
* Show branch name in item text

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-06 12:36:31 +02:00
Paul Eggleton
f0fa06d2c0 bulkchange: make script more robust
* Check if bitbake directory can be found before trying to do anything
  with the repo
* Split try..finally into two so we don't try to shut down a nonexistent
  tinfoil when we failed to gain a lock.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-08-06 12:36:31 +02:00
Paul Eggleton
3fa8a75a2f update: fix handling of moves outside of a layer
If a file is moved (renamed) to a path outside of the layer, e.g.
another layer within a multi-layer repository, then we need to treat it
as a delete. Up until now we were updating the path and continuing, and
then the recipe was also picked up as an add in the other layer, leading
to duplicate recipe entries. I'd noticed these duplicates before but up
until now I'd thought that they were due to another bug we already
fixed, apparently not.

In order to remove these erroneous duplicate entries in existing
databases I have also added a layerindex/tools/fixup_duplicates.py
script. I've also made the -r/--reload option delete them as well.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-07-19 15:12:45 +02:00
Paul Eggleton
49981aebf6 Add site-wide notice support
Add the ability to show a notice at the top of every page; this provides
the ability for admins to display a message to visitors in the case of
infrastructure or index data issues. Notices can have an expiry date and
can be disabled and re-enabled if needed. A subset of HTML can be used
for formatting the text, URLs will be made into clickable links, and
four "levels" are supported (info, success, warning and error).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-07-09 13:50:15 +02:00
Paul Eggleton
2f02ddf16d utils: fix missing dependency logic in _add_dependency()
* If a missing dependency is not required, show a warning instead of an
  error
* If logger isn't specified we still need to skip to the next item, so
  move the continue statement out of the conditional block. (In practice
  I don't think this function is currently called anywhere in the code
  without a logger specified, but let's fix it anyway).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-07-09 13:50:15 +02:00
Paul Eggleton
44a500e121 recipeparse: don't error out on missing layer recommends
If a LAYERRECOMMENDS relationship is not satisfied, we shouldn't be
erroring out - it's a recommendation, not a hard dependency. Just show a
warning and allow processing to continue.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-07-09 13:50:15 +02:00
Paul Eggleton
7effcc8cfb update_layer: avoid errors on modified & renamed files
If a file is modified and renamed it will show up in both
iter_change_type('M') and iter_change_type('R'), however naturally the
file that will exist will be the b path and not the a one, so we should
be looking at the b path or we will get errors.

FYI you can reproduce this with OE-Core (in a scratch database) using
the following procedure:
1) (in the OE-Core layer directory):
   git checkout 59285b324f6d9ed270b0bef209ef5da22a620a83
2) update.py -l openembedded-core -b master -x --nofetch -r --fullreload
3) (in the OE-Core layer directory):
   git checkout 086308aa2a5e332de6f00ed397c4a55d132f158f
4) update.py -l openembedded-core -b master -x --nofetch

Without this change you'll see the following error:

ERROR: Unable to read /opt/layerindex/layers/git___git_openembedded_org_openembedded-core/meta/recipes-devtools/python-numpy/python-numpy_1.13.1.bb: Traceback (most recent call last):
  File "/opt/layerindex/layers/bitbake/lib/bb/command.py", line 84, in runCommand
    result = command_method(self, commandline)
  File "/opt/layerindex/layers/bitbake/lib/bb/command.py", line 568, in parseRecipeFile
    envdata = bb.cache.parse_recipe(config_data, fn, appendfiles)['']
  File "/opt/layerindex/layers/bitbake/lib/bb/cache.py", line 315, in parse_recipe
    bb_data = bb.parse.handle(bbfile, bb_data)
  File "/opt/layerindex/layers/bitbake/lib/bb/parse/__init__.py", line 117, in handle
    return h['handle'](fn, data, include)
  File "/opt/layerindex/layers/bitbake/lib/bb/parse/parse_py/BBHandler.py", line 132, in handle
    abs_fn = resolve_file(fn, d)
  File "/opt/layerindex/layers/bitbake/lib/bb/parse/__init__.py", line 141, in resolve_file
    raise IOError(errno.ENOENT, "file %s not found" % fn)
FileNotFoundError: [Errno 2] file /opt/layerindex/layers/git___git_openembedded_org_openembedded-core/meta/recipes-devtools/python-numpy/python-numpy_1.13.1.bb not found

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-07-09 13:50:15 +02:00
Paul Eggleton
28e2a6b4b9 update_layer: drop debug message for deleting recipe file dependencies
This was too noisy and not particularly useful.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-07-09 13:50:15 +02:00
Paul Eggleton
350d6fc8d9 settings: allow disabling layer publishing emails
If you're running a testing / internal instance then you really don't
want to be emailing maintainers on publish, so provide a setting you can
use to disable that.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-07-09 13:50:15 +02:00
Robert Yang
7728c0f84f update.py: check whether branch existed when nocheckout
Fixed:
Assume there is no master branch in hello layer:
$ update.py -l hello -b master
INFO: Skipping update of layer hello - branch master doesn't exist

This is correct since hello layer doesn't have master branch, but when --nocheckout:
$ update.py -l hello -b master  --nocheckout
[snip]
INFO: Sorting layers for branch mater:
WARNING: Cannot find required collections on branch master:
WARNING: hello: LAYERDEPENDS: <snip>

This is incorrect, this patch fixed the problem, now it skips it since the
branch doesn't exists when --nocheckout.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-07-09 13:46:08 +02:00
Robert Yang
f5e2751034 update.py: add layers when RECOMMENDS isn't satisfied
When layer_a RECOMMENDS layer_b, try to add layer_b before layer_a, but if
layer_b is not found, still add layer_a.

And print summary error mesage:

$ update.py -b master

ERROR: Issues found on branch master:
    openembedded-core: Added without LAYERRECOMMENDS
    meta-secure-env: Failed to add since LAYERDEPENDS is not satisfied

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-07-09 13:46:08 +02:00
Robert Yang
a661ebe6ac utils.py: fix checkout_repo when no HEAD
Fixed:
$ git clone <url>
warning: remote HEAD refers to nonexistent ref, unable to checkout.
$ git rev-parse HEAD
HEAD
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Catch the error and avoid that.

And use "git reset --hard" to replace of "git reset --hard HEAD", HEAD is
default for git reset, so they are the same, but the later one reports error
when remote HEAD doesn't exist:
$ git reset --hard HEAD
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
[snip]

$ git reset --hard
No errors.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-07-09 13:46:08 +02:00
Robert Yang
635187b594 update_layer.py: avoid calling setup_core_layer_sys_path() when --initial
Fixed:
$ update.py -b <new_branch>
[snip]
NOTE: Starting bitbake server...
Traceback (most recent call last):
  File "update_layer.py", line 471, in main
    utils.setup_core_layer_sys_path(settings, branch.name)
  File "/buildarea1/lyang1/layerindex-web/layerindex/utils.py", line 376, in setup_core_layer_sys_path
    core_layerdir = os.path.join(core_repodir, core_layerbranch.vcs_subdir)
AttributeError: 'NoneType' object has no attribute 'vcs_subdir'
[snip]

This is because core_layerbranch is not in database yet for completely new
branch, so it is None and we will get the error. Avoid calling
setup_core_layer_sys_path() when "update_layer.py --initial" will fix the
problem.

And also only add core layer's sys path when it is present, since core layer
may not be added yet for completely new branch.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-07-09 13:46:08 +02:00
Paul Eggleton
09f629b997 Add CSV export for layer recipes
Add the ability to export the recipe listing for a layer to a CSV file
for importing into external tools. At the moment we include name,
version and license, but there is a parameter that lets you specify the
fields to include in the URL if desired.

Implements [YOCTO #12722].

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-05-07 15:30:04 +12:00