Commit 0904be3b authored by guinux's avatar guinux

dependency-checker preview

parent 18dd4fe2
/*
* Copyright (C) 2019 Guillaume Benoit <guillaume@manjaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a get of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
int main (string[] args) {
if (args.length != 2) {
stdout.printf ("Error: one dependecy argument needed\n");
return 1;
}
var alpm_config = new AlpmConfig ("/etc/pacman.conf");
Alpm.Handle? alpm_handle = alpm_config.get_handle ();
if (alpm_handle == null) {
critical ("Failed to initialize alpm library");
return 1;
}
unowned string depend = args[1];
unowned Alpm.List<unowned Alpm.DB> syncdbs = alpm_handle.syncdbs;
while (syncdbs != null) {
unowned Alpm.DB db = syncdbs.data;
unowned Alpm.List<unowned Alpm.Package> cache = db.pkgcache;
while (cache != null) {
unowned Alpm.Package pkg = cache.data;
unowned Alpm.List<unowned Alpm.Depend> depends = pkg.depends;
while (depends != null) {
unowned Alpm.Depend dep = depends.data;
if (dep.name == depend) {
stdout.printf ("%s/%s depends on %s (built by %s)\n", db.name, pkg.name, dep.compute_string (), pkg.packager);
}
depends.next ();
}
cache.next ();
}
syncdbs.next ();
}
return 0;
}
......@@ -133,3 +133,10 @@ executable('pamac-installer',
vala_args: common_vala_args,
c_args: common_c_args,
install: true)
executable('dependency-checker',
sources: ['alpm_config.vala', 'dependency_checker.vala'],
dependencies: [vala_deps, alpm_deps],
vala_args: common_vala_args,
c_args: [common_c_args, alpm_c_args],
install : true)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment