Commit Graph

115 Commits

Author SHA1 Message Date
Zuul 5785d21908 Merge "Fix spelling of "unknown"" 2023-01-26 03:45:30 +00:00
Clark Boylan b10c2f4003 Fix bindep on Arch with packaging>=22.0
packaging 22.0 removed the LegacyVersion object which was the fallback
when an invalid version was found. Now when an invalid version is found
packaging raises and exception. This appears to be a problem for rolling
release distros like Arch and Manjaro as they don't have versions.

To fix this we catch the exception and set our object value to None.
This will cause us to error later should we actually need the version
for some reason. When we don't need it as with Arch/Manjaro we continue
along just fine.

Change-Id: Ic9ec6a3a492a7f95cf9d2865f88d79c6c5de796c
2023-01-25 16:10:13 -08:00
Lars Kellogg-Stedman 48bcd405dd
Fix spelling of "unknown"
This jumped out at me while running bindep recently.

Change-Id: Iebc33fa396940e1064205241f00136376b71bb57
2023-01-25 13:24:25 -05:00
Sean Mooney 3427c34728 Add support for popos
This change simply adds pop os to the list of debian derived
distros.

Change-Id: I7cfb3743b21de49a9a6152c4e9dff45d6dac148c
2022-05-26 13:25:35 +01:00
Erik Berg 5d6a6c58b0 Add AlmaLinux support
Depends-On: I6cc3bedaa9753dc86d6560d32961b5a22cf3a36e
Change-Id: I037e1b0306315f7d12af0a4b6cba4226c24e6748
2022-04-11 12:21:18 -07:00
Erik Berg 186f6e4035 Fix bindep testing with distro 1.7.0 and greater
The 1.7.0 release of distro moves the source code around [0] which
requires us to update our monkey patching of distro to make tests work.
Because distro 1.7.0 does not support python < 3.6 we update bindep's
testing to accomodate both old and new distro to enable python 2.7 and
3.5 testing.

[0] 4d76bd160f

Change-Id: I6cc3bedaa9753dc86d6560d32961b5a22cf3a36e
2022-04-11 12:19:56 -07:00
Clark Boylan c4c2bf1afe Handle no newline at the end of bindep.txt
We've seen people whose editors don't add newlines to files for whatever
reason. Make bindep handle this case since users are running into it.

Note that we could theoretically modify the existing parsley grammar to
accept a missing newline and instead find EOF but adding rules like that
seems to interact with whitespace processing in ways that I don't
understand. Rather than spend a ton of time learning parsley internals I
figure the fix here is simple and easy to understand and limits
potential fallout from changes to the grammar.

Change-Id: I960e579a603d1a4612d859451df1f559e950ac31
2021-10-20 17:28:12 -07:00
Cody Lee Cochran 314b303b6e feat: Add test support for Manjaro Linux
If applied, this commit will add test support for Manjaro Linux. The
test suite for Manjaro is based on the test suite for Arch Linux since
these two distros share a package manager. In addition to a package
manager, Manjaro also shares a vast majority of its packages with Arch
Linux and does not offer any that override package names in the base
Arch Linux repositories. Like Arch, Manjaro is a rolling release, so the
test fixture, (a copy of /etc/os-release), should remain consistent over
time, as it lacks any version information.

Change-Id: I07195f9300459339ebe62c7871fae9a770bd97f2
2021-10-15 21:34:13 -05:00
Cody Lee Cochran 80d82a4456 feat: Add support for Manjaro Linux
If applied, this commit adds support for Manjaro Linux, an Arch Linux
downstream variant. Both use pacman as their package manager.

Change-Id: Ib95834bf919b045a871e919973871f5303a4c6c9
2021-10-15 08:54:45 -05:00
Jeremy Stanley d0fba55d50 Require packaging
Apparently distutils.version.LooseVersion does not supply a version
attribute in newer Python stdlib. The code we have already prefers
packaging.version.parse over it anyway if packaging is installed, so
declare it as an actual requirement. Clean up the old distutils
alternative now that it should no longer be called.

Change-Id: I9409f2b0e076e5def3fffb1149665df71c0c5508
2021-10-02 12:46:56 +00:00
Michał Nasiadka 53bf817ffc Add Rocky Linux support
Change-Id: Id5b6b02736ff368698dde33336c2570de2a2834f
2021-09-16 12:11:10 +02:00
Sorin Sbarnea 6deb027936 Assure bindep can be called as a module
- assure we can all bindep as a module (python -m bindep)
- add test the assures output is the same regardless how is called
- include argparse fix which needs to know executable name when
  called as modules.
- enables use of bindep without needing to have it in PATH

Change-Id: Ib2aac359e2f23cb0ac7857835905e0a02e90888d
2021-01-27 17:18:05 +00:00
Zuul a1f30f40ab Merge "Tolerate missing bindep.txt when using --profiles" 2021-01-22 20:58:06 +00:00
Jeremy Stanley 7c7ea77e8b ArchLinux: ignore unrelated warnings from pacman
It seems that `pacman -Q` may output warning lines if you have a
file with the same name as the package, like so:

    $ mkdir cmake
    $ pacman -Q cmake
    error: package 'cmake' was not found
    warning: 'cmake' is a file, you might want to use -p/--file.

This confuses bindep's output parsing when looking simply for lines
ending in "was not found" so match more strictly instead on lines
containing something like:

    error: package 'cmake' was not found

See the original patch supplied by Jakob Lykke Andersen in this
mailing list post:

http://lists.openstack.org/pipermail/openstack-discuss/2020-December/019404.html

Change-Id: I70287418ce034690a7fd34f4127a24fe8d7a33d2
Co-Authored-By: Jakob Lykke Andersen <jlandersen@imada.sdu.dk>
2021-01-16 16:23:05 +00:00
Zuul 5e75b1b99b Merge "Add OracleLinux support" 2020-09-21 15:32:38 +00:00
Sorin Sbarnea 509d18edae Fixed pep8 job
Upgraded hacking and fixed issues with code. This fixes pep8 job
which was failing on py38 as dependencies were too old.

Change-Id: I1b1a980eb1cb7ad0a6754b3aebfb3e3e1617c3be
2020-09-11 16:37:47 +01:00
Ian Wienand 2083b8b1a3 Cull the test bindep file
When added with 2152331ebf this was a
copy of the externally hosted bindep fallback file which was
deprecated.

So this now represents a big collection of things that we're not
maintaining.  When we add new python3 only distros to testing it all
breaks.

I think the point of this test is to ensure the callouts to the tools
for installation are working; there's no need to install the whole
world.  Cull this to a simlified list that exercises a few common
paths with packages that should be stable for the forseeable future.

Change-Id: Ib87425a5010e6cc781731512473e3db2461c1faf
2020-06-23 08:38:23 +10:00
Tim Burke d5ee0cbb58 Tolerate missing bindep.txt when using --profiles
When just trying to determine the list of possible platform profiles, it
seems silly to need to `touch bindep.txt`.

Note that we'll still log the error about how neither bindep.txt nor
other-requirements.txt exists

Change-Id: I6ab187cdfb7d8fc5638880bcffea6800f5227c79
2020-06-10 21:00:03 -07:00
Paul Bourke 32e890e844 Add OracleLinux support
Story: 2001492
Change-Id: I72da98d95a6fecff682236887fd06931066063fe
2020-04-30 09:29:22 +00:00
Zuul 8c489f141d Merge "Fix test execution failure on Darwin" 2019-09-11 18:21:39 +00:00
Zuul 11a69845ac Merge "Fix apk handling of warnings/output problems" 2019-09-09 20:50:21 +00:00
Zuul a3924539e2 Merge "Fix emerge testcases" 2019-09-09 20:12:39 +00:00
Sorin Sbarnea 975e057647 Fix test execution failure on Darwin
Because we forgot to mock platform.system() it was impossible to run
unittests on Darwin.

This also introduces a minimal unittest for Darwin itself, checking
that it recognizes brew.

Change-Id: Iff77e46b8b550d13e825712567266532edb03fa6
2019-09-09 15:24:51 +01:00
Sorin Sbarnea 5ff2102297 Expose base python version as an atom
Adds two new atoms `base-py2` and `base-py3` that can be used to
identify the primary python version supported by the current operating
system.

This allows bindep file authors to mention correct python package names
without having to hardcode each operating system version, which is
not future proof, as it would break when new versions are released.

New way to use bindep:

python3-lxml [platform:base-py3]
python-lxml [platform:base-py2]

Before this users had to rely on hacks like including the operating
system name and version [platform:centos-7] and negative variants,
something that would being broken as soon a new release is made.

Initial implementation covers RedHat flavored, Ubuntu, Debian and MacOS
which do come with an official Python version but is made in such way
that we could enable it for any other platforms.

Change-Id: I506699fb0c80f8d9ca84e20154d1c282a08708bb
Task: https://tree.taiga.io/project/tripleo-ci-board/task/809
2019-08-21 20:39:27 +01:00
Andreas Florath 92bb971784 Fix emerge testcases
During the refactoring of the depends module
I74ebd432d8e1ab8b3433f0f55d5dfe3535019911
it was found that two test cases for emerge
used the wrong type as a return type in the
CalledProcessError (str instead of bytes).

This patch fixes this and also adds a check that the
appropriate operations can be executed also for emerge.

Change-Id: I127e72cbcefaef12f28f5eb986cdcc769d033bf7
Signed-off-by: Andreas Florath <andreas@florath.net>
2019-08-19 16:26:15 +00:00
Dirk Mueller 09218a7621 Use Python 3.x by default for testing
This requires updating newer hacking which requires
some small fixes for pep8 to pass. Also adjust sphinx
dependencies so that py2.7 environment continues to work.

Change-Id: I576a6c42867a3fed7cc7090bd4a6219de3bced66
2019-06-26 16:17:16 +02:00
Zuul e498e1261a Merge "Replace deprecated bindep-fallback testing" 2019-02-27 20:04:53 +00:00
Jean-Philippe Evrard 9377cdc14d Fix bindep --brief for arch linux
Pacman output has changed and, as of v5.1.2, has a newline after
showing package x was not found.

Without this patch, the bindep --brief would throw an exception
because the stdout is not properly matched.

Change-Id: Ibe2ca0d426d6d8fa69b5c4ee9ccf0f6a07c862a7
2019-02-17 11:21:36 +01:00
Sorin Sbarnea 2152331ebf Replace deprecated bindep-fallback testing
Adopts testing using in-repo bindep.txt testing file instead of
using the deprecated externally hosted bindep-fallback.txt file.

Initial file is the same but in the future we may want to simplify it.

Change-Id: I570fe8686068478a163e4fe597514460b6a69fef
2019-02-14 18:09:04 +00:00
Sorin Sbarnea 0bc70eee07 Allow mentioning tools paths in bindep
yum/dnf package managers do allow mentioning full path to executable
instead of rpm name for installing it.

This allows users to install needed tool regardless what package name
may provide it (which may depend on what repos they have installed or
enabled).

This allows 'package' names to start with slash as this is a requirement
for triggering this feature in yum/rpm.

Practice use-case scenario: user wants docker to be installed but docker
could be installed from docker rpm or from docker-ce rpm if user added
upstream repositories. Both of them provide the same executable, but
the package manager will pick one based on its priorities.

Command line example: yum install -y /usr/bin/docker

Change-Id: I7e47ee956e9496d9f47a98f9595790797c8d1789
2019-02-07 18:01:24 +00:00
Clint Byrum be328a624d Fix apk handling of warnings/output problems
The parsing is still weak, but we do get around warnings or anything
else on stderr that would trip it up. This required refactoring the
tests which were mocking subprocess.check_output instead of
Popen/communicate which is what we use now.

Change-Id: Ie2d2fdfd27c728508213b4d23d3b58ad81a68ad2
2018-11-15 11:48:38 -08:00
Andreas Jaeger c112ea2053 Update docs building
* Use openstackdocstheme instead of obsolete oslosphinx
* Update requirements to current versions
* Use sphinx-build instead of pbr specific commands
* Fix wrong indend to avoid sphinx warning

Change-Id: I5aff91ec45466f25b825b1729561976db69eb188
2018-09-24 20:16:02 +02:00
Zuul 632d57449b Merge "Fix user profile display" 2018-08-07 13:03:32 +00:00
Jean-Philippe Evrard 94dd535faa Fix user profile display
Without this patch, issuing 'bindep --profiles' would fail
on groups that aren't a 2-tuple, because we assume
always two elements and unpack these two [1].

This is a problem, because in the case of loci [2], it prevents
a user from predicting the list of packages to be installed
on the system in a read only fashion.

Additionally, the current --profile function is showing
platform details under "Configuration profiles" AND
"Platform Profiles", as platforms are not filtered by the
profiles() function.

This patch solves the two linked problems by:
- ensuring the lists of profiles are flattened
- ensure the profiles are following the _partition function.

[1]: cec3a7576b/bindep/depends.py (L276)
[2]: 8982c3ae71/bindep.txt (L13)

Change-Id: Ied4ac178e20daf35f105e2acae0a2b3e11219a56
2018-08-02 13:26:00 +02:00
Jean-Philippe Evrard 7e87972b90 Add opensuse-leap support
Docker images coming from the dockerhub for opensuse leap 15
(opensuse/leap:15) have the following content in their lsb
release:

NAME="openSUSE Leap"
VERSION="15.0"
ID="opensuse-leap"
<redacted>

Without this patch, opensuse-leap images are not recognised
by bindep, as "opensuse-leap" != "opensuse"

This is a problem, as it prevents subprojects using bindep
(like loci) to use those images, unless some hackery of
release file is done.

This patch solves the problem by ensuring opensuse-leap
systems are strictly listed like any other  "opensuse.*" system.

Change-Id: I937812b7219ec38f9335dbb85600f294fff40902
2018-07-26 15:21:28 +02:00
Zuul cec3a7576b Merge "Move to argparse" 2018-07-12 16:05:40 +00:00
Ehud Kaldor 8c9ada45ff Add support for Alpine Linux
This change implements support for Alpine Linux and it's package manager
apk.

Task: 22622
Task: 22623
Story: 2002765

Change-Id: I4027e50e33a512fd75a6d6be49c2f7665c4cbc7a
2018-07-03 07:08:11 +00:00
Clark Boylan c373280025 Clearer unsupported platform error message
If we don't know how to support a detected platform the old code gave a
cryptic error message. Make this more clear by setting a specific
"unknown" platform value that raises if you attempt to get package
manager info with an error message that explains this situation.

Change-Id: I125dad3a3aa8f67ad5e96430e51022f5aa461b23
2018-06-28 16:11:30 -07:00
Clark Boylan 313cccff27 Use the distro package to determine distro
Some distros don't have lsb_release and some aren't even linuxes. Lets
work to support them by using the python distro package which has a
consistent api to getting the distro id, codename, and version info that
we need.

This does its best to be backward compatible by adding atoms for the
os-release reported name and the lsb_release reported name when they
differ on distros; however, it is likely that my survey was incomplete
and there may be other non matching distros. (For some reason it seems
like this is super common with rpm based distros...).

Note that the test for a missing lsb_release has been removed since that
is not the distro package's responsibility and it has multiple
fallbacks.

Change-Id: I891f5d21accb3fbf6d56bd6b0c2ebc2601682442
2018-06-22 13:52:09 -07:00
Ian Wienand 5d1c055052 Move to argparse
I presume optparse was a python2.6 compat thing; but since it's stated
in the NEWS file that it's not supported for several years, I think we
can switch.  Even if someone *was* running on centos6 era, the odds
they won't/can't have python-argparse installed anyway are minimal, so
it's not like this is a completely hard break.

Some minor refactoring is included to reduce a level of nesting.

Change-Id: Ib933db547a811d533bdc95b4836354e959c0a6f5
2018-05-28 18:36:11 +10:00
Markos Chandras 52eb3db1ce SUSE: Update openSUSE Tumbleweed references for lsb-release-3.X.X
lsb-release-3.X.X doesn't report 'openSUSE Tumbleweed' anymore but it
simply returns 'openSUSE' so update the references for Tumbleweed.

Change-Id: I3e99948167655a8a94c76a1a90d7ddefa6d5bb5b
Link: http://bugzilla.suse.com/show_bug.cgi?id=1059374
2018-03-20 13:09:40 +00:00
Sorin Sbarnea f58e5af965 add detection of darwin (MacOS/OSX)
Change-Id: I02a7e78f4392811dfbf8389bfa8a9fa4fa1ba987
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2018-02-21 12:26:36 +00:00
Sorin Sbarnea 752f1b56d7 add support for rhel workstation
Change-Id: I4e9d858ab2bf1ba24b167035ea9fdcbcc3c5254b
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2018-02-20 19:00:39 +00:00
Sam Yaple 0a7215b81e Fix logic for groups
This adjusts the logic to be in keeping with the original spirit of the
patch. We want to treat a group as a profile, so if a group exists and
does not match, and no other groups or profiles were specified, the
package should not be installed.

Change-Id: If76bbb408837b14e79a659348edbdb840be7b9ba
2017-12-01 14:38:05 -05:00
Sam Yaple 24427065c5 Add new syntax to allow matching multiple profile
Given the following:
package1 [foo bar]
package2 [foo (bar baz)]
package3 [baz]
package4 [(bar baz)]

Profile 'foo' will match package1 and package2
Profile 'bar' will match package1
Profile 'baz' will match package3
package4 cannot be match when only declaring a single profile

Specifing profiles 'bar baz' will match all four packages

Additionally, this relaxes the whitespace around the profiles and
groups. Previously while space was allowed after but not before braces.

Change-Id: I077943ff52cc8dc2eb6437925f8ca653b3534508
2017-10-06 18:42:09 -04:00
rybridges 71c58d24c0 Add ability to list all deps
These changes add a new feature which allows users
to list all dependencies for their platform in csv
format or one dep per line. This is really useful
if people want to take the deps found in bindeps.txt
and use them in an RPM spec file to build an RPM.

USAGE:
bindep -l newline
* lists all dependencies one per line
bindep -l csv
* lists all dependencies in csv format

Change-Id: I0277689ba727737e11b0adcddf6300b58614ac18
2017-08-15 11:41:35 -07:00
Jenkins 125de90c2a Merge "bindep: Query for RPM capabilities as well" 2017-07-13 13:27:39 +00:00
Jenkins 62a229abff Merge "Handle dotted versions in platform selectors" 2017-07-11 17:02:03 +00:00
Markos Chandras de6726520b bindep: Query for RPM capabilities as well
It's possible for a bindep file to list capabilities instead of actual
package names so it can cover different packages that provide the same
functionality. It's also possible to use capabilities to 'capture'
multiple releases of the same distribution that may have different
rpm package names for the same application. RPMs normally provide at
least one capability named after their actual package name so this
change actual extends the behavior of bindep without alterning it.

For example, here are some results on the openSUSE Leap 42.2
distribution where the package name is 'mariadb'

> rpm -q mariadb
mariadb-10.0.30-20.4.1.x86_64
> rpm --whatprovides -q mariadb
mariadb-10.0.30-20.4.1.x86_64
> rpm -q mariadb-server
package mariadb-server is not installed
> rpm --whatprovides -q mariadb-server
mariadb-10.0.30-20.4.1.x86_64

As we can see, using '--whatprovides' results in bindep picking up
the correct package name based on the capabilities of that package.

Change-Id: I36945d3528013250f3a8617ea63ba1883733f91c
2017-06-23 10:26:54 +01:00
Dan Smith 1743da873c Log an error when lsb_release cannot be executed
Right now, if lsb_release is not on the system, bindep just dumps stack
and indicates "No such file or directory". This gives no indication of
what the problem is or what to do to resolve it. This change logs an
error message about lsb_release being missing in that case.

Change-Id: I501647770478fe154d66cdb2c6adff48973dd23c
2017-05-31 09:35:45 -07:00