Commit Graph

123 Commits

Author SHA1 Message Date
Paul Eggleton
eeffb2d675 Send people an email when another user adds them as a maintainer
If someone adds you as a maintainer of a layer as a matter of courtesy
it would be nice if you get an email.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-12-06 08:18:49 +13:00
Paul Eggleton
b767d709ff Return to previous page after Edit profile
Use a parameter to pass the current page to the Edit Profile URL so that
saving or cancelling returns you to that same page.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-11-19 16:44:42 +13:00
Paul Eggleton
3c25eda61e Exclude "Distro-specific" from "unknown/not available" in other distro search
If you're searching for items that are of status "unknown/not available"
in the other distro packages, you're usually doing so to find things
that haven't been dispositioned. Originally I had included them here
because the "available" status correctly excludes items with the
"distro-specific" status and "unknown/not available" seemed like it
should be the inverse, but usage seems to require that it not be.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-11-19 16:44:42 +13:00
Paul Eggleton
e7e43ce03b Require re-registration if user changes email address
If a user goes to Edit Profile and changes their email address,
deactivate their account temporarily and make them go through the
registration process to confirm that the new email address is in fact
valid and theirs.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-11-19 16:44:39 +13:00
Paul Eggleton
091f5e4ef8 Allow user to edit their username in the Edit Profile form
Users may want to change their usernames for a number of different
reasons, but at the moment we require them to contact an admin to do
that. Provided we validate the new username correctly and add a CAPTCHA
to make automated enumeration difficult, we can add username to the Edit
Profile form and then users can do that any time they wish.

While we're doing this, show a message when the profile is successfully
updated.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-11-06 11:38:21 +13:00
Paul Eggleton
5d7cf9e5ae views: fix incorrect class usage in ClassSearchView
This was copy-pasted from the DistroSearchView and I clearly forgot to
replace the reference here.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-11-06 10:37:31 +13:00
Paul Eggleton
631116a1c4 Replace nvd3 with Chart.js
nvd3 and its python/django wrappers appear to be no longer actively
maintained, and at least the wrappers were a bit clunky to use. Looking
around for a suitable replacement, Chart.js seems capable, has no
additional dependencies and is fairly simple to use. As a bonus we get
to drop a few Python dependencies from our list.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-11-06 10:33:39 +13:00
Paul Eggleton
e591d1820a Track and enable reporting on duplicate inc files
It's not too common but there are instances where people have copied
.inc files into their own layer and modified them, and if you are using
such a layer that could result in unexpected behaviour. In order to get
a handle on when this is being done, collect data about all .inc files
and show duplicates in the Duplicates screen.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-11-06 10:33:39 +13:00
Paul Eggleton
accbf15a8b views: split out recipe search query to its own function
Split out the code used in the recipe search views to its own function
and use that same function in three different places rather than having
a copy of largely the same code. Also take the opportunity to add some
comments.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-10-04 09:18:51 +13:00
Paul Eggleton
f76e811403 Improve handling of invalid branch in layer CSV export view
On layers.openembedded.org we're seeing requests from some search engine
crawlers requesting the CSV export URL with an invalid branch for the
layer. I couldn't see the referer anywhere in the logs but I suspect it
has to do with some recent cleanup work I did in the database where I
deleted some invalid LayerBranch records - they were probably following
links in a cached version of the webpage. In any event we want to return
404 in this situation rather than an internal server error.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-10-04 08:43:02 +13:00
Paul Eggleton
a7820077b0 Fix broken regex for recipes with names containing + signs
In order to show bbappends on the recipe detail page we are doing a
regex query to find any whose names match up with the recipe. In the
layer index instance at layers.openembedded.org viewing the recipe
detail page for any recipe whose name contains ++ (e.g. libsigc++-2.0 in
meta-oe) results in an invalid regex and causes a database error. Escape
any + signs in the name used within the regex in order to fix this.

(I wasn't actually able to reproduce this on my own setup despite also
using MariaDB, but I did find that the unescaped query was not correctly
matching records so it needed to be fixed anyway.)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-10-02 11:39:57 +13:00
Paul Eggleton
d3bd81dc3b Add an email test function
When you make changes to the infrastructure it can be useful to test
that email sending is working, since for that to work that involves the
code, Celery, RabbitMQ and SMTP being functional. However, up until now
to run a test you needed to submit a fake layer which is a bit annoying.
Add an explicit "Test email" option to the Tools drop-down for staff
users to allow them to send an email to themselves.

Note: the page will come back when the Celery job has been created, it
does not check and report on the job status - you need to look on the
server side to see that.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-10-01 17:04:44 +13:00
Paul Eggleton
d84bfd710d Allow stopping update task
For situations where the user launches a distro comparison update
process and then shortly afterwards realises it is operating with the
wrong configuration (or is otherwise broken) and is going to take a long
time to finish, add a button to the task page to stop the task. This was
tricky to get working, since the default behaviour of Celery's revoke()
would either terminate both the Celery task process along with the update
process (leaving us with no log saved to the database) or worse not even
kill the update process, depending on the signal sent. To avoid this,
send SIGUSR2, trap it in the task process and kill the child process,
returning gracefully. To make that possible I had to rewrite runcmd() to
use subprocess.Popen() instead of subprocess.check_call() as otherwise
we can't get the child's PID.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-09-20 16:04:49 +12:00
Paul Eggleton
ac73780bd9 Properly show update task success/failure
If a distro comparison update task fails (returning a non-zero value to
indicate as such) we were not able to see this easily from the frontend.
Show success/failure in the form of a label on the task page and general
update list/detail, and if the task fails while we're watching then make
the progress bar go red as well. Also make a distinction between the
process failing (retcode > 0) and being terminated (retcode < 0, e.g.
process was killed).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-09-20 16:04:49 +12:00
Paul Eggleton
d063aab917 Show progress when running comparison update tasks
Provide a mechanism for distro comparison update tasks to display
progress. In practice this means the update command needs to write the
progress percentage to a file and then the log view (which is polled by
the frontend) reads this file. Originally I was going to use a FIFO for
this but that turned out to be a but unreliable; I also tried to use
Celery's state mechanism to pass it back but I simply could not get it
to work. The file-based mechanism is good enough though.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-09-20 16:04:49 +12:00
Paul Eggleton
74b1b9c895 Show update task output more smoothly
We were refreshing the page constantly in order to show output while
a task was running, which basically worked but is horrible. Instead,
write the task output to a file and then use AJAX calls to request
whatever output has been written to the file since the last call
and call this roughly every second. Put the output in a scrollable <pre>
element instead of making it the length of the page, and auto-scroll
to the end (unless the user grabs the scrollbar and pulls it upwards -
it may not be immediately obvious that you can do this if there is a lot
of output since you have to pull it up when the scrolling animation is
not running, but it is possible).

An alternative would be to have used some kind of long-lived HTTP
session or a websocket, but those come with their own set of problems
so I elected to use this much simpler method.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-09-20 16:04:49 +12:00
Paul Eggleton
f259f0c36f Limit selection of "Base" layer type
If a user doesn't have publish rights and the type of the layer isn't
already "Base" then disallow selecting the Base layer type. Some
submitters are selecting this type for their own layers, but it's pretty
much reserved for openembedded-core and meta-oe (so that they appear at
the top of the layer list).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-09-06 11:08:43 +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
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
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
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
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
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
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
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
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
Paul Eggleton
15d1253f79 Drop old raw recipe export code
We're about to replace this with a proper CSV export function, so we
don't need this dead code hanging around anymore.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-05-07 12:01:12 +12:00
Paul Eggleton
b2a67d718c Add link to maintenance plan in layer detail
If the RRS is enabled, then add a way to get from the layer detail page
to any maintenance plans in which the layer is included.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-05-04 23:57:53 +12:00
Paul Eggleton
aad000734c utils: decode command output in runcmd() as UTF-8
Sometimes we get back UTF-8 characters (particularly when picking up
names from git commits), and the ascii codec will error out if that
happens, so switch over to utf-8.

We can as a result remove the decode() calls from the bulk change view.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-05-04 23:57:52 +12:00
Paul Eggleton
61b32b483d views: fix regression in publish email sending code
In e902b67bcc I missed a couple of Context
usages in the layer publish view and the result was that it broke
publishing a layer (and apparently I didn't run a final test on that,
shame on me).

Thanks to Yi Zhao <yi.zhao@windriver.com> for pointing this out.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-05-04 23:52:11 +12:00
Paul Eggleton
e902b67bcc views: Adapt to template rendering API change
With Django 1.10+, if you use get_template() to retrieve a template,
then you can't pass a context when calling .render() on it, you need to
pass a dict instead.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-04-24 10:15:47 +12:00
Paul Eggleton
375e7587d1 views: fix history tracking to work with current django-reversion
We use django-reversion to track history of admin/maintainer changes to
the site, and part of our extension on top of django-reversion involves
annotating each "revision" with a description of the changes that were
made. In django-reversion 2.0.0+ the pre_revision_commit signal that we
were using to do this annotation is gone in favour of just using
Django's standard pre-save signal. This was a little challenging to
adapt to for our purposes but not impossible.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-04-24 10:15:47 +12:00
Paul Eggleton
a918098981 Stop using string name for publish view in urls.py
Rename publish() to publish_view() and call it directly from the view
rather than using a string name (which is not possible in Django 1.10+).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-04-24 10:15:47 +12:00
Paul Eggleton
705ee26cac views: replace mimetype with content_type
This change happened sometime in Django 1.7 and we missed it until now.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-04-24 10:15:47 +12:00
Paul Eggleton
bed43a9be5 Add statistics page
Add a page with basic statistics for the index - number of layers,
recipes, classes, machines and distros on an overall basis (distinct
names) and per branch, since I've been asked a few times for this kind
of information. It's currently only linked from the Tools menu for
logged-in users, but the URL will work for anyone.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-02-20 16:00:13 +13:00
Paul Eggleton
11e5010b13 views: fix classic recipe search redirecting to recipe page with single result
If your classic recipe search returned a single result, then since
commit c8c25fb641 you got a standard
recipe page instead of the proper page with fields you can edit. To fix
it, just drop the redirection functionality from the classic recipe
search, since we don't really want it here.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-01-09 17:15:52 +13:00
Paul Eggleton
21f343201d views: fix "layer:" keyword on recipe search page
We were using the layerbranch id to search for the specified layer,
which is most likely to return either no results or results for the
wrong layer. We can also avoid specifying the id field at all here as
the filter() function can handle real objects.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-01-09 17:15:52 +13:00
Paul Eggleton
d728f56311 Fix error on publish if no non-root superuser/staff accounts exist
We need to set a default for this variable or you get an
UnboundLocalError if no non-root superuser/staff accounts are set up in
the database.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-01-09 17:15:35 +13:00
Amanda Brindle
51e83c8d31 update_layer.py: Save and show recipe dependencies
Added a model for the PACKAGECONFIG variable, which has a one to
many relationship with the Recipe model.

Added models for static build dependencies and dynamic build
dependencies, both of which have a many to many relationship with
the Recipe model.

These objects are created in update_layer.py and are displayed on the
Recipe detail page.

Added a depends search option for recipes, allowing users to search for
recipes that depend on any particular recipe. Use "depends:recipename"
in the recipe search to activate this.

Fixes [YOCTO #12129]
Fixes [YOCTO #11415]

Signed-off-by: Amanda Brindle <amanda.r.brindle@intel.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2017-12-18 09:01:29 +13:00
Amanda Brindle
a64bfed81b recipes.html: Require keyword for recipe search
Use JavaScript to check if the search box for recipe search is
empty before querying the database. This will prevent the "502
Bad Gateway" error that occurs when the query takes too long due
to the large list of recipes. Since there are so many recipes
spread across the layers in the OE index, there's no point in
allowing a user to search without a keyword in order to browse
the list; it simply isn't digestible as a whole.

For the Machines, Classes, and Distros pages, the search behaviour is
unaffected, however to make it more obvious that you can browse the list
add an explicit "browse" button.

Fixes [YOCTO #11930]

Signed-off-by: Amanda Brindle <amanda.r.brindle@intel.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2017-12-05 10:01:10 +13:00
Amanda Brindle
78c2561181 templates/layerindex/classes.html: Add bbclass search
Add another tab to search for classes.

Fixes [YOCTO #11207]

Signed-off by: Amanda Brindle <amanda.r.brindle@intel.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2017-11-07 16:54:46 +13:00