Commit 947ab246 authored by Philip Müller's avatar Philip Müller

add PKGBUILD editing support

parent a94f2157
Pamac is a GUI for libalpm (pacman) with AUR and Appstream support
Pamac is a Package Manager based on libalpm with AUR and Appstream support
#### Features
- Library to access package infos and run transactions
- Python bindings
- CLI
- GTK3 frontend with Dbus daemon
- Tray icon with Updates notifications
- libpamac: Library to access package infos and run transactions
- Python bindings for libpamac
- pamac: a CLI
- pamac_manager/pamac-updater: a Gtk3 GUI
- pamac-tray: a Gtk3 tray icon with updates notifications
- ppamac-tray-appindicator: a AppIndicator tray icon with updates notifications
#### Installing from source
......
......@@ -11,13 +11,13 @@ RefreshPeriod = 6
#NoUpdateHideIcon
## Allow Pamac to search and install packages from AUR:
#EnableAUR
EnableAUR
## When AUR support is enabled check for updates from AUR:
#CheckAURUpdates
CheckAURUpdates
## AUR build directory:
BuildDirectory = /tmp
BuildDirectory = /var/tmp
## Number of versions of each package to keep in the cache:
KeepNumPackages = 3
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkPopoverMenu" id="popovermenu">
......@@ -97,6 +97,127 @@
<property name="gravity">center</property>
<property name="show_menubar">False</property>
<signal name="delete-event" handler="on_ManagerWindow_delete_event" swapped="no"/>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkBox" id="header_left_buttonbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">32</property>
<child>
<object class="GtkButton" id="button_back">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<signal name="clicked" handler="on_button_back_clicked" swapped="no"/>
<child>
<object class="GtkImage" id="back_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-previous-symbolic</property>
<property name="icon_size">1</property>
</object>
</child>
<style>
<class name="image-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="header_filter_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="select_all_button">
<property name="label" translatable="yes">Select All</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="margin_left">18</property>
<signal name="clicked" handler="on_select_all_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="header_right_buttonbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">3</property>
<child>
<object class="GtkToggleButton" id="search_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<signal name="toggled" handler="on_search_button_toggled" swapped="no"/>
<child>
<object class="GtkImage" id="search_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">edit-find-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="menu_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="popover">popovermenu</property>
<signal name="toggled" handler="on_menu_button_toggled" swapped="no"/>
<child>
<object class="GtkImage" id="menu_icon">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">open-menu-symbolic</property>
<property name="icon_size">1</property>
</object>
</child>
<style>
<class name="image-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="main_box">
<property name="visible">True</property>
......@@ -651,24 +772,10 @@
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkSpinner" id="checking_spinner">
<property name="height_request">40</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="checking_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -849,6 +956,34 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="build_togglebutton">
<property name="label" translatable="yes">Build</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<signal name="toggled" handler="on_build_togglebutton_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="reset_files_button">
<property name="label" translatable="yes">Reset build files</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_reset_files_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
......@@ -1203,126 +1338,5 @@
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkBox" id="header_left_buttonbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">32</property>
<child>
<object class="GtkButton" id="button_back">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<signal name="clicked" handler="on_button_back_clicked" swapped="no"/>
<child>
<object class="GtkImage" id="back_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-previous-symbolic</property>
<property name="icon_size">1</property>
</object>
</child>
<style>
<class name="image-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="header_filter_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="select_all_button">
<property name="label" translatable="yes">Select All</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="margin_left">18</property>
<signal name="clicked" handler="on_select_all_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="header_right_buttonbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">3</property>
<child>
<object class="GtkToggleButton" id="search_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<signal name="toggled" handler="on_search_button_toggled" swapped="no"/>
<child>
<object class="GtkImage" id="search_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">edit-find-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="menu_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="popover">popovermenu</property>
<signal name="toggled" handler="on_menu_button_toggled" swapped="no"/>
<child>
<object class="GtkImage" id="menu_icon">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">open-menu-symbolic</property>
<property name="icon_size">1</property>
</object>
</child>
<style>
<class name="image-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</template>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="PamacTransactionSumDialog" parent="GtkDialog">
......@@ -11,6 +11,9 @@
<property name="icon_name">system-software-install</property>
<property name="type_hint">dialog</property>
<property name="deletable">False</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox6">
<property name="can_focus">False</property>
......@@ -25,6 +28,9 @@
<property name="label" translatable="yes">_Cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
</object>
......@@ -39,9 +45,6 @@
<property name="label" translatable="yes">Commit</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">False</property>
</object>
<packing>
......
This diff is collapsed.
......@@ -25,37 +25,41 @@ namespace Pamac {
const string rpc_multiinfo = "&type=info";
const string rpc_multiinfo_arg = "&arg[]=";
Json.Array rpc_query (string uri) {
async Json.Array rpc_query (string uri) {
SourceFunc callback = rpc_query.callback;
var results = new Json.Array ();
var session = new Soup.Session ();
// set a 15 seconds timeout because it is also the dbus daemon timeout
session.timeout = 15;
var message = new Soup.Message ("GET", uri);
var parser = new Json.Parser ();
session.send_message (message);
try {
parser.load_from_data ((string) message.response_body.flatten ().data, -1);
} catch (Error e) {
critical (e.message);
}
unowned Json.Node? root = parser.get_root ();
if (root != null) {
if (root.get_object ().get_string_member ("type") == "error") {
stderr.printf ("Failed to query %s from AUR\n", uri);
} else {
results = root.get_object ().get_array_member ("results");
session.queue_message (message, (sess, mess) => {
try {
parser.load_from_data ((string) mess.response_body.flatten ().data, -1);
unowned Json.Node? root = parser.get_root ();
if (root != null) {
if (root.get_object ().get_string_member ("type") == "error") {
stderr.printf ("Failed to query %s from AUR\n", uri);
} else {
results = root.get_object ().get_array_member ("results");
}
}
} catch (Error e) {
critical (e.message);
}
}
Idle.add ((owned) callback);
});
yield;
return results;
}
internal Json.Array aur_search (string[] needles) {
internal async Json.Array aur_search (string[] needles) {
if (needles.length == 0) {
return new Json.Array ();
} else {
Json.Array[] found_array = {};
foreach (unowned string needle in needles) {
found_array += rpc_query (rpc_url + rpc_search + Uri.escape_string (needle));
found_array += yield rpc_query (rpc_url + rpc_search + Uri.escape_string (needle));
}
var result = new Json.Array ();
foreach (unowned Json.Array found in found_array) {
......@@ -81,17 +85,44 @@ namespace Pamac {
}
}
internal Json.Array aur_multiinfo (string[] pkgnames) {
internal async Json.Array aur_multiinfo (string[] pkgnames) {
if (pkgnames.length == 0) {
return new Json.Array ();
}
var builder = new StringBuilder ();
builder.append (rpc_url);
builder.append (rpc_multiinfo);
foreach (unowned string pkgname in pkgnames) {
builder.append (rpc_multiinfo_arg);
builder.append (Uri.escape_string (pkgname));
// query pkgnames hundred by hundred to avoid too long uri error
// example: ros-lunar-desktop
if (pkgnames.length <= 100) {
var builder = new StringBuilder ();
builder.append (rpc_url);
builder.append (rpc_multiinfo);
foreach (unowned string pkgname in pkgnames) {
builder.append (rpc_multiinfo_arg);
builder.append (Uri.escape_string (pkgname));
}
return yield rpc_query (builder.str);
} else {
var result = new Json.Array ();
int index_max = pkgnames.length - 1;
int index = 0;
while (index < index_max) {
var builder = new StringBuilder ();
builder.append (rpc_url);
builder.append (rpc_multiinfo);
for (int i = 0; i < 100; i++) {
unowned string pkgname = pkgnames[index];
builder.append (rpc_multiinfo_arg);
builder.append (Uri.escape_string (pkgname));
index++;
if (index == index_max) {
break;
}
}
var array = yield rpc_query (builder.str);
array.foreach_element ((array, index, node) => {
result.add_element (node);
});
}
return result;
}
return rpc_query (builder.str);
}
}
......@@ -99,7 +99,10 @@ namespace Pamac {
} else if (args[2] == "--aur" || args[2] == "-a") {
init_database ();
database.config.enable_aur = true;
search_in_aur (concatenate_strings (args[3:args.length]));
search_in_aur.begin (concatenate_strings (args[3:args.length]), () => {
loop.quit ();
});
loop.run ();
} else if (args[2] == "--files" || args[2] == "-f") {
init_database ();
search_files (args[3:args.length]);
......@@ -117,7 +120,10 @@ namespace Pamac {
} else if (args[2] == "--aur" || args[2] == "-a") {
init_database ();
database.config.enable_aur = true;
display_aur_infos (args[3:args.length]);
display_aur_infos.begin (args[3:args.length], () => {
loop.quit ();
});
loop.run ();
} else {
init_database ();
display_pkg_infos (args[2:args.length]);
......@@ -245,7 +251,10 @@ namespace Pamac {
} else if (args[1] == "checkupdates") {
if (args.length == 2) {
init_database ();
checkupdates ();
checkupdates.begin (() => {
loop.quit ();
});
loop.run ();
} else if (args.length == 3) {
if (args[2] == "--help" || args[2] == "-h") {
display_checkupdates_help ();
......@@ -253,7 +262,10 @@ namespace Pamac {
init_database ();
database.config.enable_aur = true;
database.config.check_aur_updates = true;
checkupdates ();
checkupdates.begin ((obj, res) => {
loop.quit ();
});
loop.run ();
} else {
display_checkupdates_help ();
}
......@@ -742,8 +754,8 @@ namespace Pamac {
}
}
void search_in_aur (string search_string) {
var pkgs = database.search_in_aur (search_string);
async void search_in_aur (string search_string) {
var pkgs = yield database.search_in_aur (search_string);
if (pkgs.length () == 0) {
exit_status = 1;
return;
......@@ -997,7 +1009,7 @@ namespace Pamac {
}
}
void display_aur_infos (string[] pkgnames) {
async void display_aur_infos (string[] pkgnames) {
string[] properties = {};
properties += dgettext (null, "Name");
properties += dgettext (null, "Package Base");
......@@ -1025,7 +1037,7 @@ namespace Pamac {
}
}
foreach (string pkgname in pkgnames) {
var details = database.get_aur_pkg_details (pkgname);
var details = yield database.get_aur_pkg_details (pkgname);
if (details.name == "") {
print_error (dgettext (null, "target not found: %s").printf (pkgname) + "\n");
return;
......@@ -1306,8 +1318,8 @@ namespace Pamac {
}
}
void checkupdates () {
var updates = database.get_updates ();
async void checkupdates () {
var updates = yield database.get_updates ();
uint updates_nb = updates.repos_updates.length () + updates.aur_updates.length ();
if (updates_nb == 0) {
stdout.printf ("%s.\n", dgettext (null, "Your system is up-to-date"));
......@@ -1362,7 +1374,6 @@ namespace Pamac {
dgettext (null, "AUR"));
}
}
loop.quit ();
}
void install_pkgs (string[] targets) {
......
......@@ -65,6 +65,7 @@ namespace Pamac {
public string installed_version;
public string desc;
public double popularity;
public string packagebase;
}
struct AURPackageDetailsStruct {
......@@ -99,9 +100,4 @@ namespace Pamac {
public PackageStruct[] aur_conflicts_to_remove;
public string[] aur_pkgbases_to_build;