Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ste74/pamac
  • codesardine/pamac
  • LordTermor/pamac
  • matthias-vogt/pamac
4 results
Show changes
Showing
with 2 additions and 9318 deletions
[Unit]
Description=Pamac Daemon
[Service]
Type=dbus
BusName=org.manjaro.pamac.daemon
ExecStart=/usr/bin/pamac-daemon
[Unit]
Description=Generate mirrorlist
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/pacman-mirrors -f8
[Unit]
Description=Generate mirrorlist weekly
[Timer]
OnCalendar=Thu *-*-* 7:00:00
RandomizedDelaySec=15h
Persistent=true
[Install]
WantedBy=timers.target
[Unit]
Description=Pamac System Session
[Service]
Type=dbus
BusName=org.manjaro.pamac.system
ExecStart=/usr/bin/pamac-system-daemon
/*
* pactree.vala - a simple dependency tree viewer translated in Vala
*
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (c) 2010-2011 Pacman Development Team <pacman-dev@archlinux.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 2 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 copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Compile with: valac --pkg=libalpm --vapidir=../../vapi pactree.vala
using Alpm;
/* output */
string provides;
string unresolvable;
string branch_tip1;
string branch_tip2;
int indent_size;
/* color */
string branch1_color;
string branch2_color;
string leaf1_color;
string leaf2_color;
string color_off;
/* globals */
Handle handle;
unowned DB localdb;
Alpm.List<string> walked;
Alpm.List<string> provisions;
/* options */
bool color;
bool graphviz;
bool linear;
int max_depth;
bool reverse;
bool unique;
string dbpath;
const OptionEntry[] options = {
{ "dbpath", 'b', 0, OptionArg.STRING, ref dbpath, "set an alternate database location", "path" },
{ "color", 'c', 0, OptionArg.NONE, ref color, "colorize output", null },
{ "depth", 'd', 0, OptionArg.INT, ref max_depth, "limit the depth of recursion", "number" },
{ "graph", 'g', 0, OptionArg.NONE, ref graphviz, "generate output for graphviz", null },
{ "linear", 'l', 0, OptionArg.NONE, ref linear, "enable linear output", null },
{ "reverse", 'r', 0, OptionArg.NONE, ref reverse, "show reverse dependencies", null },
{ "unique", 'u', 0, OptionArg.NONE, ref unique, "show dependencies with no duplicates (implies -l)", null },
{ null }
};
static void init_options() {
/* initialize options */
color = false;
graphviz = false;
linear = false;
max_depth = -1;
reverse = false;
unique = false;
dbpath = "/var/lib/pacman";
/* output */
provides = " provides";
unresolvable = " [unresolvable]";
branch_tip1 = "|--";
branch_tip2 = "+--";
indent_size = 3;
/* color */
branch1_color = "\033[0;33m"; /* yellow */
branch2_color = "\033[0;37m"; /* white */
leaf1_color = "\033[1;32m"; /* bold green */
leaf2_color = "\033[0;32m"; /* green */
color_off = "\033[0m";
}
static int parse_options(ref unowned string[] args) {
var opts = new OptionContext("");
opts.set_help_enabled(true);
opts.add_main_entries(options, null);
try {
bool b = opts.parse(ref args);
if (!b) {
stderr.puts(opts.get_help(false, null));
return 1;
}
}
catch (OptionError e)
{
stderr.puts("Unable to parse options : " + e.message + "\n");
return 1;
}
/* there must be (at least) one argument left */
if (args.length == 1) return 1;
/* unique implies linear */
if (unique) linear = true;
/* no color */
if (!color) {
branch1_color = branch2_color = "";
leaf1_color = leaf2_color = "";
color_off = "";
}
/* linear */
if (linear) {
provides = "";
branch_tip1 = branch_tip2 = "";
indent_size = 0;
}
return 0;
}
static void local_init() {
Alpm.Errno error;
handle = new Handle ("/", dbpath, out error);
assert (error == 0);
localdb = handle.localdb;
assert (localdb != null);
}
static int main (string[] args) {
init_options();
int ret = parse_options(ref args);
if (ret != 0) return ret;
local_init();
string? target_name = args[1];
unowned Package? pkg = find_satisfier(localdb.pkgcache, target_name);
if (pkg == null) {
stderr.printf("Error: package '%s' not found\n", target_name);
return 1;
}
/* begin writing */
print_start(pkg.name, target_name);
if(reverse)
walk_reverse_deps(pkg, 1);
else
walk_deps(pkg, 1);
print_end();
return 0;
}
static void print_text(string? pkg, string? provision, int depth)
{
int indent_sz = (depth + 1) * indent_size;
if ((pkg == null) && (provision == null)) return;
if (pkg == null) {
/* we failed to resolve provision */
stdout.printf("%s%*s%s%s%s%s%s\n", branch1_color, indent_sz, branch_tip1,
leaf1_color, provision, branch1_color, unresolvable, color_off);
} else if ((provision != null) && (provision != pkg)) {
/* pkg provides provision */
stdout.printf("%s%*s%s%s%s%s %s%s%s\n", branch2_color, indent_sz, branch_tip2,
leaf1_color, pkg, leaf2_color, provides, leaf1_color, provision,
color_off);
} else {
/* pkg is a normal package */
stdout.printf("%s%*s%s%s%s\n", branch1_color, indent_sz, branch_tip1, leaf1_color,
pkg, color_off);
}
}
/**
* walk dependencies in reverse, showing packages which require the target
*/
static void walk_reverse_deps(Package pkg, int depth) {
if((max_depth >= 0) && (depth > max_depth)) return;
walked.add(pkg.name);
Alpm.List<string> required_by = pkg.compute_requiredby();
unowned Alpm.List<string> list = required_by;
while (list != null) {
unowned string pkgname = list.data;
if (walked.find_str(pkgname) != null) {
/* if we've already seen this package, don't print in "unique" output
* and don't recurse */
if (!unique) {
print(pkg.name, pkgname, null, depth);
}
} else {
print(pkg.name, pkgname, null, depth);
walk_reverse_deps(localdb.get_pkg(pkgname), depth + 1);
}
list.next ();
}
required_by.free_inner(GLib.free);
}
/**
* walk dependencies, showing dependencies of the target
*/
static void walk_deps(Package pkg, int depth)
{
if((max_depth >= 0) && (depth > max_depth)) return;
walked.add(pkg.name);
unowned Alpm.List<unowned Depend> depends = pkg.depends;
while (depends != null) {
unowned Alpm.Depend depend = depends.data;
unowned string depname = depend.name;
unowned Package? provider = find_satisfier (localdb.pkgcache, depname);
if (provider != null) {
string provname = provider.name;
if (walked.find_str (provname) != null) {
/* if we've already seen this package, don't print in "unique" output
* and don't recurse */
if (!unique) {
print (pkg.name, provname, depname, depth);
}
} else {
print (pkg.name, provname, depname, depth);
walk_deps(provider, depth + 1);
}
} else {
/* unresolvable package */
print(pkg.name, null, depname, depth);
}
depends.next ();
}
}
static void print_graph(string parentname, string? pkgname, string? depname)
{
if(depname != null) {
stdout.printf("\"%s\" -> \"%s\" [color=chocolate4];\n", parentname, depname);
if((pkgname != null) && (depname != pkgname) && (provisions.find_str(depname) != null)) {
stdout.printf("\"%s\" -> \"%s\" [arrowhead=none, color=grey];\n", depname, pkgname);
provisions.add(depname);
}
} else if(pkgname != null) {
stdout.printf("\"%s\" -> \"%s\" [color=chocolate4];\n", parentname, pkgname);
}
}
/* parent depends on dep which is satisfied by pkg */
static void print(string? parentname, string? pkgname, string? depname, int depth)
{
if(graphviz) {
print_graph(parentname, pkgname, depname);
} else {
print_text(pkgname, depname, depth);
}
}
static void print_start(string pkgname, string provname)
{
if(graphviz) {
stdout.printf("digraph G { START [color=red, style=filled];\n" +
"node [style=filled, color=green];\n" +
" \"START\" -> \"%s\";\n", pkgname);
} else {
print_text(pkgname, provname, 0);
}
}
static void print_end()
{
if(graphviz) {
/* close graph output */
stdout.printf("}\n");
}
}
#!/usr/bin/python
import gi
gi.require_version('Pamac', '9.0')
from gi.repository import Pamac
def print_pkg_details (details):
print (" -Name:", details.get_name())
print (" -Desc:", details.get_desc())
print (" -Long Desc:", details.get_long_desc())
print (" -Icon:", details.get_icon())
print (" -Screenshots:", details.get_screenshots())
if __name__ == "__main__":
config = Pamac.Config(conf_path="/etc/pamac.conf")
db = Pamac.Database(config=config)
pkgname = "gimp"
print ("Without appstream support:")
pkgs = db.search_pkgs (pkgname)
for pkg in pkgs:
print_pkg_details (pkg)
print ("")
print ("With appstream support:")
db.enable_appstream()
pkgs = db.search_pkgs (pkgname)
for pkg in pkgs:
print_pkg_details (pkg)
#!/usr/bin/python
import gi
gi.require_version('Pamac', '9.0')
from gi.repository import GLib, Pamac
def on_emit_action (transaction, action, data):
print(action)
def on_emit_action_progress (transaction, action, status, progress, data):
print(f"{action} {status}")
def on_emit_hook_progress (transaction, action, details, status, progress, data):
print(f"{action} {details} {status}")
def on_emit_warning (transaction, message, data):
print(message)
def on_emit_error (transaction, message, details, details_length, data):
if details_length > 0:
print(f"{message}:")
for detail in details:
print(detail)
else:
print(message)
def run_transaction():
# /!\ the transaction will run without confirmation /!\
# you need to override Transaction.ask_confirmation() method
# in order to implement your own confirmation step
transaction.add_pkg_to_install ("pkgname");
transaction.run ()
transaction.quit_daemon()
if __name__ == "__main__":
loop = GLib.MainLoop()
config = Pamac.Config(conf_path="/etc/pamac.conf")
db = Pamac.Database(config=config)
transaction = Pamac.Transaction(database=db)
data = None
transaction.connect ("emit-action", on_emit_action, data)
transaction.connect ("emit-action-progress", on_emit_action_progress, data)
transaction.connect ("emit-hook-progress", on_emit_hook_progress, data)
transaction.connect ("emit-error", on_emit_error, data)
transaction.connect ("emit-warning", on_emit_warning, data)
run_transaction()
#!/usr/bin/python
import gi
gi.require_version('Pamac', '9.0')
from gi.repository import Pamac
def list_installed_pkgs():
pkgs = db.get_installed_pkgs()
for pkg in pkgs:
print(pkg.get_name(), pkg.get_version())
if __name__ == "__main__":
config = Pamac.Config(conf_path="/etc/pamac.conf")
db = Pamac.Database(config=config)
list_installed_pkgs()
#!/usr/bin/python
"""
somes tests for python
Depends On:
pamac
pacman
not installed:
ruby-yard
"""
# run only one:
# ./tests.py GetInfosCase.test_versions_search_db
# ./tests.py -v -k files
import gi
import os
import subprocess
import locale
from datetime import date
import unittest
gi.require_version('Pamac', '9.0')
from gi.repository import GLib, Pamac
def get_item_desc(file_pacman: str, key: str = "%VERSION%"):
"""
get values in db pacman file
/var/lib/pacman/local/***-***/{desc,files}
key: %DEPENDS% %INSTALLDATE% %VERSION% %NAME%...
"""
found = False
with open(file_pacman) as f_db:
for line in f_db:
if line.startswith(key):
found = True
continue
if found:
if line.strip():
yield line.strip()
else:
break
class GetInfosCase(unittest.TestCase):
"""Hieght level tests"""
def setUp(self):
"""init tests"""
locale.setlocale(locale.LC_ALL, '')
config = Pamac.Config(conf_path="/etc/pamac.conf")
config.set_enable_aur(True) # is true
self.db = Pamac.Database(config=config) # view src/database.vala
def tearDown(self):
pass
def test_pacman_installed(self):
"""pacman installed for tests"""
pkg = self.db.get_pkg("pacman")
self.assertEqual("pacman", pkg.get_name())
self.assertIsNotNone(pkg.props.installed_version)
def test_not_installed(self):
"""detect not installed"""
# package not exist
pkg = self.db.get_pkg("toto-test")
self.assertNotEqual("toto-test", pkg.get_name())
self.assertEqual(pkg.props.installed_version, "")
# package exist
pkg = self.db.get_pkg("ruby-yard")
self.assertEqual(pkg.props.installed_version, "")
def test_giobject_detail_name(self):
"""attrs .props are same as fonctions"""
pkg = self.db.get_pkg("pacman")
self.assertEqual(pkg.props.name, pkg.get_name())
def test_giobject_search_name(self):
"""function db.search_pkgs()"""
pkgs = self.db.search_pkgs("pacman")
for pkg in pkgs:
self.assertEqual(pkg.props.name, pkg.get_name())
def test_giobject_search_version(self):
"""version install is as version"""
#pkgs = self.db.search_pkgs("pacman")
pkgs = self.db.get_installed_pkgs()
for pkg in pkgs:
if pkg.props.installed_version:
with self.subTest(pkg=pkg):
self.assertEqual(pkg.props.version, pkg.props.installed_version)
def test_count_installed(self):
"""count on disk pacman db packages installed"""
pkgs = self.db.get_installed_pkgs()
ldir = os.listdir("/var/lib/pacman/local/")
ldir.remove("ALPM_DB_VERSION")
self.assertEqual(len(ldir), len(pkgs))
def test_all_installed(self):
"""test names/version on disk pacman db packages installed"""
plist = []
pkgs = self.db.get_installed_pkgs()
plist = {f"{pkg.props.name}-{pkg.props.installed_version}" for pkg in pkgs}
ldir = os.listdir("/var/lib/pacman/local/")
ldir.remove("ALPM_DB_VERSION")
for p_name_v in plist:
self.assertIn(p_name_v, ldir)
def test_versions_search_db(self):
"""VERSION is as pacman"""
pkgs = self.db.search_pkgs("pacman")
for pkg in pkgs:
if pkg.props.installed_version:
with self.subTest(pkg=pkg):
fdesc = f"/var/lib/pacman/local/{pkg.props.name}-{pkg.props.version}/desc"
self.assertTrue(os.path.exists(fdesc))
result = get_item_desc(fdesc, "%VERSION%")
self.assertEqual(pkg.props.version, next(result))
def test_depends_search_db(self):
"""DEPENDS are as pacman"""
pkgs = self.db.search_pkgs("pacman")
for pkg in pkgs:
if pkg.props.installed_version:
with self.subTest(pkg=pkg):
fdesc = f"/var/lib/pacman/local/{pkg.props.name}-{pkg.props.version}/desc"
self.assertTrue(os.path.exists(fdesc))
package = self.db.get_pkg(pkg.props.name)
result = get_item_desc(fdesc, "%DEPENDS%")
for dep in result:
self.assertIn(dep, package.props.depends)
def test_search_pacman(self):
"""compare results with pacman -Ssq"""
result = subprocess.run(['pacman', '-Ssq', 'pacman'], capture_output=True, check=True)
result = result.stdout.decode().split("\n")
result.remove('')
pkgs = self.db.search_pkgs("pacman")
pkgs = {pkg.props.name for pkg in pkgs}
for pkg in result:
self.assertIn(pkg, pkgs)
'''
can't test if aur package installed
for pkg in pkgs:
self.assertIn(pkg, result)
'''
def test_date_detail_pacman(self):
"""valid date and locale date"""
pkg = self.db.get_pkg("pacman")
fdesc = f"/var/lib/pacman/local/{pkg.props.name}-{pkg.props.version}/desc"
self.assertTrue(os.path.exists(fdesc))
result = get_item_desc(fdesc, "%BUILDDATE%")
d_test = int(next(result))
d_test = date.fromtimestamp(d_test).strftime("%x")
self.assertEqual(pkg.props.builddate, d_test)
def test_files(self):
"""files same as pacman db"""
pkg = self.db.get_pkg("pacman")
fdesc = f"/var/lib/pacman/local/{pkg.props.name}-{pkg.props.version}/files"
self.assertTrue(os.path.exists(fdesc))
myfiles = self.db.get_pkg_files("pacman")
result = get_item_desc(fdesc, "%FILES%")
for f_name in result:
if not f_name.endswith("/"):
self.assertIn("/" + f_name, myfiles)
def test_search_aur(self):
"""simple search in aur"""
pkgs = self.db.search_in_aur('pamac');
found = False
for pkg in pkgs:
with self.subTest(pkg=pkg):
self.assertTrue(pkg.props.version)
self.assertEqual(pkg.props.version, pkg.get_version())
self.assertTrue(isinstance(
pkg.props.popularity, (int, float)))
found = True
self.assertTrue(found)
if __name__ == '__main__':
unittest.main(verbosity=2, failfast=True)
......@@ -2,9 +2,8 @@ project('pamac', 'c', 'vala',
default_options : [
'prefix=/usr',
'sysconfdir=/etc',],
version : '9.0')
version : '11.7.1')
subdir('resources')
subdir('src')
subdir('po')
subdir('data')
option('enable-appindicator', type : 'boolean', value : false, description : 'tray icon using appindicator')
option('enable-snap', type : 'boolean', value : false, description : 'install snap packages')
option('enable-fake-gnome-software', type : 'boolean', value : false, description : 'simulate gnome-software')
af
ar
ast
az_AZ
be
bg
bn
bs
ca
cs
cy
da
de
de_CH
de_DE
el
el_GR
en_GB
eo
es
es_419
es_AR
es_ES
es_MX
es_SV
et
eu
fa
fa_IR
fi
fo
fr
gl
gug_PY
he
he_IL
hi
hi_IN
hr
hr_HR
hu
id
is
is_IS
it
ja
ka
ko
lt
ml
ms
nb
nl
nl_BE
nl_NL
nn
pl
pt
pt_BR
pt_PT
ro
ru
si
sk
sl
sl_SI
sq
sr
sr@latin
sr_RS
sr_RS@latin
sv
tr
uk
ur_PK
uz
vi
zh
zh_CN
zh_TW
data/polkit/org.manjaro.pamac.policy.in
src/alpm_utils.vala
src/daemon.vala
src/database.vala
src/transaction.vala
src/transaction-gtk.vala
src/installer.vala
src/tray.vala
src/manager.vala
src/manager_window.vala
src/preferences_dialog.vala
src/choose_pkgs_dialog.vala
src/transaction-cli.vala
src/cli.vala
src/snap_plugin.vala
resources/choose_provider_dialog.ui
resources/progress_dialog.ui
resources/history_dialog.ui
resources/transaction_sum_dialog.ui
resources/manager_window.ui
resources/preferences_dialog.ui
resources/choose_pkgs_dialog.ui
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.