Skip to content

Commit

Permalink
Extend buildorder output
Browse files Browse the repository at this point in the history
This should help to address a few user requests:

1) buildorder shouldn't consider what's installed and omit these
packages. Instead, we tag output to describe what steps (if any) need to
be taken. Output is either REPOS (available for install via pacman), or
AUR (can be built from the AUR). Either of these can be prefixed with
SAITSFIED to denote that the dependency is already installed locally. As
a last resort, a depedency might be UNKNOWN when the package isn't found
anywhere (#4).

2) buildorder should include the target package(s) in the output. (#32)

3) For packages which come from the AUR, the pkgbase will be emitted as
a third column, e.g.

  AUR systemd-libs-git systemd-git

This allows for deduping and also knowing the directory the
cloned/downloaded package will be found in (#9)

I'll no doubt gain a few new bug reports with this change...
  • Loading branch information
falconindy committed Apr 27, 2019
1 parent 7a13f32 commit 16d2b99
Show file tree
Hide file tree
Showing 11 changed files with 152 additions and 43 deletions.
11 changes: 9 additions & 2 deletions man/auracle.1.pod
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,23 @@ Change directory to I<DIR> before downloading and extracting tarballs.

Pass one to many arguments to print a build order for the given packages. The
resulting output will be the total ordering to build all packages. Each line is
two columns delimited by a single whitespace. The first column contains an
at least two columns delimited by a single whitespace. The first column contains an
identifier and the second column names the dependency. Possible identifiers
are:

=over 4

B<BUILD> The package is foreign and needs to be built from the AUR.
B<AUR> The dependency was found in the AUR and needs to be built and installed.

B<REPOS> The dependency was found in a binary repo and can be installed via pacman.

B<UNKNOWN> The dependency was unable to be found anywhere. This might indicate a broken dependency chain.

=back

Additionally, both of B<AUR> and B<REPOS> can be prefixed with B<SATISFIED> to
indicate that the dependency is already installed.

=item B<clone> I<PACKAGES>...

Pass one to many arguments to clone package git repositories. Use the
Expand Down
33 changes: 26 additions & 7 deletions src/auracle/auracle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ int Auracle::Show(const std::vector<std::string>& args,
}

int Auracle::BuildOrder(const std::vector<std::string>& args,
const CommandOptions&) {
const CommandOptions& options) {
if (args.empty()) {
return ErrorNotEnoughArgs();
}
Expand All @@ -554,24 +554,43 @@ int Auracle::BuildOrder(const std::vector<std::string>& args,
return -ENOENT;
}

std::vector<const aur::Package*> total_ordering;
std::vector<std::pair<std::string, const aur::Package*>> total_ordering;
std::unordered_set<std::string> seen;
for (const auto& arg : args) {
iter.package_cache.WalkDependencies(
arg, [&total_ordering, &seen](const std::string& pkgname,
const aur::Package* package) {
if (seen.emplace(pkgname).second && package != nullptr) {
total_ordering.push_back(package);
if (seen.emplace(pkgname).second) {
total_ordering.emplace_back(pkgname, package);
}
});
}

for (const auto& p : total_ordering) {
if (pacman_->DependencyIsSatisfied(p->name)) {
continue;
const bool satisfied = pacman_->DependencyIsSatisfied(p.first);
const bool from_aur = p.second != nullptr;
const bool unknown = !from_aur && !pacman_->HasPackage(p.first);

if (unknown) {
std::cout << "UNKNOWN";
} else {
if (satisfied) {
std::cout << "SATISFIED";
}

if (from_aur) {
std::cout << "AUR";
} else {
std::cout << "REPOS";
}
}

std::cout << " " << p.first;
if (from_aur) {
std::cout << " " << p.second->pkgbase;
}

std::cout << "BUILD " << p->name << "\n";
std::cout << "\n";
}

return 0;
Expand Down
12 changes: 10 additions & 2 deletions tests/auracle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,16 @@ def _ProcessDebugOutput(self):

def _WritePacmanConf(self):
with open(os.path.join(self.tempdir, 'pacman.conf'), 'w') as f:
f.write('[options]\nDBPath = {}/fakepacman'.format(
os.path.dirname(os.path.realpath(__file__))))
f.write('''
[options]
DBPath = {}/fakepacman
[extra]
Server = file:///dev/null
[community]
Server = file:///dev/null
'''.format(os.path.dirname(os.path.realpath(__file__))))


def Auracle(self, args):
Expand Down
90 changes: 59 additions & 31 deletions tests/buildorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ def testSinglePackage(self):
p = self.Auracle(['buildorder', 'ocaml-configurator'])
self.assertEqual(p.returncode, 0)
self.assertListEqual(p.stdout.decode().strip().splitlines(), [
'BUILD ocaml-sexplib0',
'BUILD ocaml-base',
'BUILD ocaml-stdio',
'BUILD ocaml-configurator',
'SATISFIEDREPOS ocaml',
'REPOS dune',
'AUR ocaml-sexplib0 ocaml-sexplib0',
'AUR ocaml-base ocaml-base',
'AUR ocaml-stdio ocaml-stdio',
'AUR ocaml-configurator ocaml-configurator',
])


Expand All @@ -21,23 +23,31 @@ def testMultiplePackage(self):
'buildorder', 'ocaml-configurator', 'ocaml-cryptokit'])
self.assertEqual(p.returncode, 0)
self.assertListEqual(p.stdout.decode().strip().splitlines(), [
'BUILD ocaml-sexplib0',
'BUILD ocaml-base',
'BUILD ocaml-stdio',
'BUILD ocaml-configurator',
'BUILD ocaml-zarith',
'BUILD ocaml-cryptokit',
'SATISFIEDREPOS ocaml',
'REPOS dune',
'AUR ocaml-sexplib0 ocaml-sexplib0',
'AUR ocaml-base ocaml-base',
'AUR ocaml-stdio ocaml-stdio',
'AUR ocaml-configurator ocaml-configurator',
'REPOS zlib',
'REPOS gmp',
'REPOS ocaml-findlib',
'AUR ocaml-zarith ocaml-zarith',
'REPOS ocamlbuild',
'AUR ocaml-cryptokit ocaml-cryptokit',
])


def testDuplicatePackage(self):
p = self.Auracle(['buildorder'] + 2 * ['ocaml-configurator'])
self.assertEqual(p.returncode, 0)
self.assertListEqual(p.stdout.decode().strip().splitlines(), [
'BUILD ocaml-sexplib0',
'BUILD ocaml-base',
'BUILD ocaml-stdio',
'BUILD ocaml-configurator',
'SATISFIEDREPOS ocaml',
'REPOS dune',
'AUR ocaml-sexplib0 ocaml-sexplib0',
'AUR ocaml-base ocaml-base',
'AUR ocaml-stdio ocaml-stdio',
'AUR ocaml-configurator ocaml-configurator',
])


Expand All @@ -46,23 +56,41 @@ def testOverlappingSubtrees(self):
'buildorder', 'google-drive-ocamlfuse', 'ocaml-configurator'])
self.assertEqual(p.returncode, 0)
self.assertListEqual(p.stdout.decode().strip().splitlines(), [
'BUILD camlidl',
'BUILD ocamlfuse',
'BUILD ocaml-sexplib0',
'BUILD ocaml-base',
'BUILD ocaml-stdio',
'BUILD ocaml-configurator',
'BUILD ocaml-pcre',
'BUILD ocamlnet',
'BUILD ocaml-curl',
'BUILD ocaml-zarith',
'BUILD ocaml-cryptokit',
'BUILD ocaml-extlib',
'BUILD ocaml-xmlm',
'BUILD gapi-ocaml',
'BUILD ocaml-sqlite3',
'BUILD ocaml-ounit',
'BUILD google-drive-ocamlfuse',
'SATISFIEDREPOS ocaml',
'REPOS ocaml-findlib',
'AUR camlidl camlidl',
'REPOS fuse',
'AUR ocamlfuse ocamlfuse',
'REPOS ncurses',
'REPOS gnutls',
'REPOS krb5',
'REPOS pcre',
'REPOS dune',
'AUR ocaml-sexplib0 ocaml-sexplib0',
'AUR ocaml-base ocaml-base',
'AUR ocaml-stdio ocaml-stdio',
'AUR ocaml-configurator ocaml-configurator',
'AUR ocaml-pcre ocaml-pcre',
'AUR ocamlnet ocamlnet',
'REPOS curl',
'AUR ocaml-curl ocaml-curl',
'REPOS zlib',
'REPOS gmp',
'AUR ocaml-zarith ocaml-zarith',
'REPOS ocamlbuild',
'AUR ocaml-cryptokit ocaml-cryptokit',
'REPOS cppo',
'AUR ocaml-extlib ocaml-extlib',
'REPOS ocaml-yojson',
'REPOS ocaml-topkg',
'REPOS opam',
'AUR ocaml-xmlm ocaml-xmlm',
'AUR gapi-ocaml gapi-ocaml',
'REPOS sqlite3',
'REPOS jbuilder',
'AUR ocaml-sqlite3 ocaml-sqlite3',
'AUR ocaml-ounit ocaml-ounit',
'AUR google-drive-ocamlfuse google-drive-ocamlfuse',
])


Expand Down
44 changes: 44 additions & 0 deletions tests/fakepacman/local/ocaml-4.07.0-1/desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
%NAME%
ocaml

%VERSION%
4.07.0-1

%BASE%
ocaml

%DESC%
A functional language with OO extensions

%URL%
http://caml.inria.fr/

%ARCH%
x86_64

%BUILDDATE%
1534229348

%INSTALLDATE%
1542637336

%PACKAGER%
Juergen Hoetzel <juergen@archlinux.org>

%SIZE%
177992704

%LICENSE%
LGPL2.1
custom: QPL-1.0

%VALIDATION%
pgp

%DEPENDS%
gdbm

%OPTDEPENDS%
ncurses: advanced ncurses features
tk: advanced tk features

Binary file added tests/fakepacman/local/ocaml-4.07.0-1/mtree
Binary file not shown.
1 change: 1 addition & 0 deletions tests/fakepacman/sync/community.db
Binary file added tests/fakepacman/sync/community.db.tar.gz
Binary file not shown.
1 change: 1 addition & 0 deletions tests/fakepacman/sync/extra.db
Binary file added tests/fakepacman/sync/extra.db.tar.gz
Binary file not shown.
3 changes: 2 additions & 1 deletion tests/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ def testSyncFindsPackagesNeedingUpgrade(self):
self.assertEqual(p.returncode, 0)
self.assertEqual(p.stdout.decode().strip(), 'auracle-git')

# TODO: build this dynamically from the filesystem?
self.assertCountEqual(self.request_uris, [
'/rpc?v=5&type=info&arg[]=auracle-git&arg[]=pkgfile-git'])
'/rpc?v=5&type=info&arg[]=auracle-git&arg[]=ocaml&arg[]=pkgfile-git'])


def testSyncFiltersUpdatesToArgs(self):
Expand Down

0 comments on commit 16d2b99

Please sign in to comment.