114 Commits
Author SHA1 Message Date
Matthew Johnson 02c63d802c Record imported public key in commit message
When the user chooses to import a public key during the autospec run
display information on that key in the commit message.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-01-18 15:20:30 -08:00
William Douglas 4befc85602 Fixups for rust/cargo building
Improve rust/cargo support by:
1) Better handling only toplevel Cargo configuration files for dependency
lookup.
2) Adding runtime requirements for buildreq packages in order to get
dependencies from non directly dependent packages resolved.
3) Add cargo as a buildreq for rust packages to handle the rustc/cargo
split.
4) Add cargo detection from failed_commands.
5) Fix rust source directory destination to not append version in case
the package name already had version information in it.
6) Get name and version information from crates.io package files.
2018-01-16 14:17:09 -08:00
Matthew Johnson e7b1302768 Check for ConfigParser regressions in all source files
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-01-11 17:31:49 -08:00
Matthew Johnson 9739ab703a Turn off ConfigParser string interpolation
configparser.ConfigParser attempts to interpolate "%" characters in the
values of the key-value pairs when parsing. This is absolutely unwanted
behavior, especially when parsing URLs such as

<sourceforge url>/joe-editor/files/JOE%20sources/<joe tar>

which cause an uncaught exception.

Turn off interpolation by passing the interpolation=None argument to
ConfigParser.

Add a unit tests to report when ConfigParser(...) is called in the
codebase without setting interpolation to None.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-01-11 17:24:39 -08:00
Matthew Johnson eb4ba41d37 Remove no-longer-used functional test suite
This test suite is extremely hard to keep up-to-date and is no longer as
valuable now that unit tests have been written for much of the code
base. Actual functional testing can be done against package repos
without requiring them to be included in the autospec repository.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-01-11 14:47:39 -08:00
Leandro Dorileo af19c7e567 add new url pattern
Consider package names with an underscore separator.

Signed-off-by: Leandro Dorileo <leandro.maciel.dorileo@intel.com>
2017-12-14 14:50:03 -08:00
Matthew Johnson 4897e3974e Follow redirects from license server
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-12-13 14:24:01 -08:00
Gabi Beyer 0ef4314c4d scrape src url from bb and inc file
Get the source url to set the url if one is not passed into
autospec. This allows a user to use an infile file as the
source for the tarball, and prevents them having to manually
find the url. It also requires that the variable PV and ROS_SPN
are replaced with their correct strings (version and name,
respectively).

Changed the name of the infile_parsers.py file to infile_bb_parser
since it is specific to recipe files.

Have string read into lists and joined to fix spacing issues.

Signed-off-by: Gabi Beyer <gabib@live.com>
2017-11-30 09:07:19 -08:00
Gabi Beyer aef3399d10 Refactor to use multiple files and change inputs
Create 3 separate infile files, the infile_handler reads in the
inputs and determnes how to parse them. The --infile argument now
allows a url, file, or directory of files to be passed as the
input. The infile_handler determines that type of input, calls the
correct parser depending on the filetype, and calls the update to
the specfile.

The infile parsers contains the scraping and parsing for all file
types. Currently it scrapes both .bb and .inc files and stores the
data into one dictionary. Because these files are both for recipes
their data corresponds and the .inc file takes presedence.

The infile update spec file udpates aspects of the specfile that
have been scraped and stored into a dict from the infile parsers
file. If there exists a value for ROS_SPN in the .bb file, use that
when replace the ROS_SNP value in the replace PV function.

Signed-off-by: Gabi Beyer <gabib@live.com>
2017-11-30 09:07:19 -08:00
Gabi Beyer 07d0d53470 Add update license function and fix comments
Add comments to the update functions (summary, license, build
deps) within the funcion.

Add an update_license function that appends any licenses scraped
from the bb file to the autospec licenses list if they don't
already exist.

Also added unittests for functionality

Signed-off-by: Gabi Beyer <gabib@live.com>
2017-11-30 09:07:19 -08:00
Gabi Beyer 8b0c5439e5 Initial commit for infile parser
Add --infile argument that takes a url, path, or directory
to a bitbake/recipe file. It scrapes the .bb/.inc file for
configuration data and stores it in a dictionary. This
architecture can be used for multiple file formats.

Also adds some initial unit tests for scraping functionality.

Signed-off-by: Gabi Beyer <gabib@live.com>
2017-11-30 09:07:19 -08:00
Caio Marcelo de Oliveira Filho 25724b09a1 Extra case for name/version extraction with GitHub
In this case, the project uses one GitHub repo to distribute different
packages. The existing extraction rules are not enough

Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
2017-11-29 17:55:47 -08:00
Matthew Johnson bbaade01c7 Add test for build.log missing file parsing
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-16 13:19:11 -08:00
Matthew Johnson ad2fa386a4 license: Add tests for complete coverage of license module
The additional test uncovered a syntax error in the print_fatal call in
license_from_copying_hash, which was fixed as well. An unnecessary mock
was removed from another test.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-16 13:11:53 -08:00
Matthew Johnson 07622d5770 Increase count.py test coverage
Also remove some never-hit regular expressions from count.py

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-16 13:11:07 -08:00
Matthew Johnson 79246f925a Deprecate Makefile writing
The package metadata is now written to options.conf so the Makefile
writing is no longer needed.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-14 10:17:07 -08:00
Matthew Johnson 7c4e0e9fd6 Do not clean any files with a directive
Use a regular expression in order to exclude all directives at the
beginning of the filename, including %doc.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-07 13:54:50 -08:00
Matthew Johnson a2b467e6b0 Do not attempt to clean "%dir" files
When cleaning directories from the package file lists do not attempt to
clean "%dir" prefixed files. Although autospec does not currently
support empty directories, it could in the future.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-07 13:54:50 -08:00
Matthew Johnson 7d7263d684 Remove directories from file list
Clean directories from package file lists. If directories are
encountered, print a warning, add the directory to the blacklist, and
re-run.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-07 13:54:50 -08:00
Gabi Beyer e13d3edb03 Remove network dependencies for pkg_integrity test
Create a mock function that copies files from the testfiles
directory to a tmp directory, when attempting to download
files from the network.

Create a mock function for head_request that returns 404 for
a few specified urls, and 200 for the rest.

The mock calls will allow the functionality of the pkg_integrity
program to be tested and not dependent on networking. Tests will
no longer need to be skipped in travis with the removal of
network dependency.

Removed a few tests that were not specific to pkg_integrity, but
instead were testing the importing and exporting abilities
of the gpg key server.

Added mock as a requirement to the requirements.txt file.

Signed-off-by: Gabi Beyer <gabib@live.com>
2017-11-01 16:58:58 -07:00
Brett T. Warden 7fa9e21b83 Add/enhance test cases for giturl
Add test cases for empty/null giturl. Add message to case when regex
fails to match.

Signed-off-by: Brett T. Warden <brett.t.warden@intel.com>
2017-10-26 14:34:08 -07:00
Brett T. Warden 0eb744f788 tarball: de-conflate github repo and package name
For github URLs, capture and identify repo name separately from package
name. This is a building block for resolving cases where the package
name is actually different than the github repo name.

Signed-off-by: Brett T. Warden <brett.t.warden@intel.com>
2017-10-26 14:34:08 -07:00
Brett T. Warden 5132520108 Add test for giturl generation
For github URLs in tests/packageurls, check that we produce a giturl
that looks reasonably correct.

Signed-off-by: Brett T. Warden <brett.t.warden@intel.com>
2017-10-26 14:34:08 -07:00
Matthew Johnson d4e78abc6c Remove unused "output" directory
Since moving output to a temporary directory, the "output" directory has
fallen out of use. Remove the output directory from autospec.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-10-23 15:33:19 -07:00
Brett T. Warden a3589e1a70 tests: add leading slash to test filenames
Tests for the %files section use bare file names. Since rpmbuild
requires leading slashes anyway, adding slashes to some of the tests.

Adding new tests for filenames with white space and/or rpm directives.

Signed-off-by: Brett T. Warden <brett.t.warden@intel.com>
2017-10-19 14:05:39 -07:00
Matthew Johnson 7acd27bea2 Add the world to tests/packageurls
Test almost 2000 URLs for proper version and name detection. This list
is sorted by the second column (expected name).

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-10-18 12:39:12 -07:00
Caio Marcelo de Oliveira Filho cc57b39872 Remove use of global variable for mock_cmd
Rename set_mock to get_mock_cmd, and return the value instead of
setting a global variable.

This patch should not change any behavior.

Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
2017-10-18 12:33:15 -07:00
Caio Marcelo de Oliveira Filho 1574477167 Change how to decide whether use sudo or not with mock
Use 'sudo' unless /usr/bin/mock points to consolehelper. This is a
simpler heuristic than checking for the group membership and will let
us use the group membership in Clear Linux to give sudo permissions.

Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
2017-10-18 12:33:15 -07:00
Matthew Johnson 1f0545ccaa Add regex to handle font packages
Adobe font packages have -nndpi as part of the name. Add tests and a
regular expression to capture these.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-10-16 15:26:34 -07:00
Matthew Johnson 673ba4fd4c Skip debian pkg_integrity tests in Travis
Debian is down again, and we've seen them go down in the past. We
shouldn't be running these tests in Travis.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-10-16 14:54:34 -07:00
Matthew Johnson 8b56c225b1 Create mock chroot with a unique uniqueext
This prevents collisions when two instances are trying to build the same
package in parallel. Unit tests added as well.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-10-11 15:38:14 -07:00
Matthew Johnson a09ea7005e Skip two more trouble tests in Travis
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-26 15:38:23 -07:00
Matthew Johnson adaea4202a Skip problem tests on Travis CI only
These tests regularly fail in Travis for unknown reasons. Skip them
until the tests can be rewritten.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-26 15:30:45 -07:00
Matthew Johnson 2552c9786f Move test generators out of name guard
This allows python3 unittest to properly generate the tests when running
all the tests in the tests directory.

Also adds a fix to test_test.py to reset buildpattern.default_pattern
every test. This was a bug introduced by running all tests at once -
this was not being cleared correctly.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-26 15:30:34 -07:00
Gabi Beyer c68e877bd2 Fix unittests that use mock_open
with the imlpementation of the write_out functionality,
some unittests need to be changed to use that fuction.

Signed-off-by: Gabi Beyer <gabrielle.n.beyer@intel.com>
2017-08-31 12:44:04 -07:00
Matthew Johnson 37021b8505 Remove architecture string from version string 2017-07-31 13:56:11 -07:00
Matthew Johnson 7a648c8e66 Add another version pattern for stack 2017-07-17 16:01:42 -07:00
Matthew Johnson a6c82dc940 Clean up buildreq module
Minor clean up of buildreq module, including the following changes:

- Remove unused import "tarball"
- Add function docstrings
- Convert to list-driven pattern checks instead of a long list of
  conditionals.
- Rename variable names that were overriding keywords (file, buffer,
  etc.)
- Remove unused setup_py_python3 function
- Remove unused arguments and variables from scan_for_configure function
  (and corresponding function calls in test_buildreq.py and autospec.py)

Most changes made at pylint and pycodestyle suggestions.
2017-07-13 10:55:41 -07:00
Matthew Johnson d200c719d7 Add simple unit tests for the util module 2017-07-13 09:14:45 -07:00
Matthew Johnson ddf7927c3c Update and add to tarball unit tests
Updates include generating an individual test for each url to be tested
instead of doing it all in one test and appending to an error list where
appropriate. This has the benefit of showing failures for each
individual test case in a recognizable manner.

Tests are also added for most of the remaining functions.

These tests do not pass without the accompanying tarball module cleanup
and restructure.
2017-07-13 09:14:45 -07:00
Matthew Johnson f8eb22b8f1 Update unit tests for latest changes
Some changes have recently been pushed to autospec sources without
updating the unit tests. This patch brings the unit tests up-to-date
again.

test_build.py: Remove go buildtool bits (was deprecated)
test_specdescription.py: Newline added to post-scripts
test_specfile.py: Reset license_translations dict
files.py: Check dict with get() in case of missing key
2017-07-12 08:46:47 -07:00
Matthew Johnson 99b9ed6dd5 Add unit tests for the test module
This patch adds unit tests for the test module.
2017-07-12 08:46:47 -07:00
Matthew Johnson 9f023f87eb Add unit tests for count.py
Add unit tests for the very large count.py module/script. These unit
tests attempt to test every regular expression present in the parse_log
function and helped catch several bugs in the original regexes ported
from perl.
2017-07-11 14:16:55 -07:00
Matthew Johnson c3231eaed5 Remove unchangeable default_grp from specfiles
Since default_group in specdescription is never modified, remove it as a
class member from the Specfiles class and just write the default.
2017-07-07 15:10:48 -07:00
Matthew Johnson a1f13af7ab Clean up specdescription module
Clean up the specdescription module, including resolving two bugs and
making the code more readable and more robust.

BUGS:

- description_from_pkginfo

  A string was checked for a substring using the string.find() method
  but was treated as a boolean, assuming that find() returned 0 when the
  substring was not found. This was causing a section end to be
  immediately detected and the section was not parsed. The call was
  replaced with the `in` keyword.

- description_from_spec

  The default description was overwritten regardless of whether the
  detected description had any content. A check was added to only
  overwrite the default if there was a detected description.

Other general cleanup:

- Remove unused default_group global
- Remove unused argument in summary_from_R
- Add assign_summary/description methods to reduce global usage and
  reduce code repetition
- Add function docstrings
- Convert to `with open()` blocks when working with files instead of
  explicitly handling closing the files
- Wrap open() calls in try...catch blocks
2017-07-07 14:54:42 -07:00
Matthew Johnson e8efee61dc Add unit tests for the specdescription module
Unit tests added for the specdescription module. At the time of this
commit, there are two failing tests due to bugs in the module.

Failures:

- test_description_from_pkginfo

  This test fails because a string.find() method is checked as a boolean
  as if find returned 0 if the substring was not present. find()
  actually returns -1 in this case. Because find() was being used as a
  guard to find the end of a section, the end was found immediately and
  the section was not parsed.

- test_description_from_spec_no_info

  This test fails due to the default description being overridden, even
  when the override is just an empty string.
2017-07-07 12:34:30 -07:00
Matthew Johnson ccc278e657 Add more tests for setup.py buildreq parsing
Shortcomings were identified in setup.py parsing for python build
requirements. These tests more exhaustively test the cases we have been
seeing in the wild.
2017-07-06 16:26:48 -07:00
Arjan van de Ven 193efe132e Revert "Simplify the buildreq module"
This reverts commit 52e986c07d.

it breaks quite a few packages, including gtk+
2017-05-03 02:41:30 +00:00
Matthew Johnson 52e986c07d Simplify the buildreq module
This patch makes some simplifications to the buildreq module and related
modules (autospec and config). These are mostly readability changes and
code cleanup.
2017-05-01 11:47:00 -07:00
Matthew Johnson d5b6abc9d2 Add unittests for the buildreq module
Unit tests can be run from the root of the autospec directory by
invoking `make test_buildreq` or `make unittests`.
2017-05-01 11:47:00 -07:00