Commit 83132dab authored by guinux's avatar guinux

better handle clone build files failure

parent 477d6c18
......@@ -120,7 +120,7 @@ namespace Pamac {
uint64 rates_nb;
public signal int choose_provider (string sender, string depend, string[] providers);
public signal void compute_aur_build_list (string sender);
public signal bool compute_aur_build_list (string sender);
public signal void start_preparing (string sender);
public signal void stop_preparing (string sender);
public signal void start_downloading (string sender);
......@@ -869,7 +869,9 @@ namespace Pamac {
aur_conflicts_to_remove = new List<PackageStruct?> ();
aur_pkgbases_to_build = new GenericArray<string> ();
emit_script_output (sender, "");
compute_aur_build_list (sender);
if (!compute_aur_build_list (sender)) {
return false;
}
return trans_run_real ();
}
if (ask_commit (sender, summary)) {
......@@ -925,7 +927,9 @@ namespace Pamac {
aur_conflicts_to_remove = new List<PackageStruct?> ();
aur_pkgbases_to_build = new GenericArray<string> ();
emit_script_output (sender, "");
compute_aur_build_list (sender);
if (!compute_aur_build_list (sender)) {
return false;
}
return trans_run_real ();
}
}
......
......@@ -109,7 +109,7 @@ namespace Pamac {
Cond answer_cond;
Mutex answer_mutex;
int? choosen_provider_answer;
bool? compute_aur_build_list_answer;
bool? compute_aur_build_list_success;
bool? ask_edit_build_files_answer;
bool? edit_build_files_answer;
bool? ask_commit_answer;
......@@ -175,7 +175,7 @@ namespace Pamac {
return choose_provider_callback (sender, depend, providers);
});
alpm_utils.compute_aur_build_list.connect ((sender) => {
compute_aur_build_list_callback (sender);
return compute_aur_build_list_callback (sender);
});
alpm_utils.ask_edit_build_files.connect ((sender, summary) => {
return ask_edit_build_files_callback (sender, summary);
......@@ -678,19 +678,20 @@ namespace Pamac {
answer_mutex.unlock ();
}
void compute_aur_build_list_callback (string sender) {
compute_aur_build_list_answer = null;
bool compute_aur_build_list_callback (string sender) {
compute_aur_build_list_success = null;
compute_aur_build_list (sender);
answer_mutex.lock ();
while (compute_aur_build_list_answer == null) {
while (compute_aur_build_list_success == null) {
answer_cond.wait (answer_mutex);
}
answer_mutex.unlock ();
return compute_aur_build_list_success;
}
public void aur_build_list_computed () throws Error {
public void aur_build_list_computed (bool success) throws Error {
answer_mutex.lock ();
compute_aur_build_list_answer = true;
compute_aur_build_list_success = success;
answer_cond.signal ();
answer_mutex.unlock ();
}
......
......@@ -47,7 +47,7 @@ namespace Pamac {
string[] temporary_ignorepkgs,
string[] overwrite_files) throws Error;
public abstract void answer_choose_provider (int provider) throws Error;
public abstract void aur_build_list_computed () throws Error;
public abstract void aur_build_list_computed (bool success) throws Error;
public abstract void answer_ask_edit_build_files (bool answer) throws Error;
public abstract void build_files_edited () throws Error;
public abstract void answer_ask_commit (bool answer) throws Error;
......
......@@ -1345,6 +1345,7 @@ namespace Pamac {
builddir.make_directory_with_parents ();
} catch (Error e) {
critical ("%s\n", e.message);
return null;
}
}
var pkgdir = builddir.get_child (pkgname);
......@@ -1428,7 +1429,7 @@ namespace Pamac {
public bool regenerate_srcinfo (string pkgname, Cancellable? cancellable = null) {
bool success = false;
string pkgname_copy = pkgname;
new Thread<int> ("clone_build_files", () => {
new Thread<int> ("regenerate_srcinfo", () => {
success = regenerate_srcinfo_real (pkgname_copy, cancellable);
loop.quit ();
return 0;
......
......@@ -279,26 +279,33 @@ namespace Pamac {
}
}
void compute_aur_build_list () {
bool compute_aur_build_list () {
// set building to allow cancellation
building = true;
build_cancellable.reset ();
start_building ();
compute_aur_build_list_real ();
bool success = compute_aur_build_list_real ();
stop_building ();
building = false;
return success;
}
void launch_subprocess (string[] cmds) {
int launch_subprocess (string[] cmds) {
int status = 1;
try {
var process = new Subprocess.newv (cmds, SubprocessFlags.NONE);
process.wait ();
if (process.get_if_exited ()) {
status = process.get_exit_status ();
}
} catch (Error e) {
critical ("%s\n", e.message);
emit_error (dgettext (null, "Failed to prepare transaction"), {e.message});
}
return status;
}
void compute_aur_build_list_real () {
bool compute_aur_build_list_real () {
string tmp_path = "/tmp/pamac";
var file = GLib.File.new_for_path (tmp_path);
if (!file.query_exists ()) {
......@@ -315,7 +322,9 @@ namespace Pamac {
foreach (unowned AURPackage aur_update in aur_updates) {
to_build_array.add (aur_update.name);
}
check_aur_dep_list (to_build_array.data);
if (!check_aur_dep_list (to_build_array.data)) {
return false;
}
if (aur_desc_list.length > 0) {
// create a fake aur db
launch_subprocess ({"rm", "-f", "%s/aur.db".printf (tmp_path)});
......@@ -323,11 +332,14 @@ namespace Pamac {
foreach (unowned string name_version in aur_desc_list) {
cmds += name_version;
}
launch_subprocess (cmds);
if (launch_subprocess (cmds) != 0) {
return false;
}
}
return true;
}
void check_aur_dep_list (string[] pkgnames) {
bool check_aur_dep_list (string[] pkgnames) {
var dep_to_check = new GenericArray<string> ();
var aur_pkgs = new HashTable<string, AURPackage?> (str_hash, str_equal);
if (clone_build_files) {
......@@ -335,7 +347,7 @@ namespace Pamac {
}
foreach (unowned string pkgname in pkgnames) {
if (build_cancellable.is_cancelled ()) {
return;
return false;
}
if (already_checked_aur_dep.contains (pkgname)) {
continue;
......@@ -345,18 +357,19 @@ namespace Pamac {
unowned AURPackage? aur_pkg = aur_pkgs.lookup (pkgname);
if (aur_pkg == null) {
// error
continue;
return false;
}
// clone build files
// use packagebase in case of split package
emit_action (dgettext (null, "Cloning %s build files").printf (aur_pkg.packagebase) + "...");
clone_dir = database.clone_build_files (aur_pkg.packagebase, false, build_cancellable);
if (build_cancellable.is_cancelled ()) {
return;
return false;
}
if (clone_dir == null) {
// error
continue;
emit_error (dgettext (null, "Failed to clone build files"), {});
return false;
}
already_checked_aur_dep.add (aur_pkg.packagebase);
} else {
......@@ -382,17 +395,18 @@ namespace Pamac {
}
} catch (Error e) {
critical ("%s\n", e.message);
return false;
}
continue;
}
emit_action (dgettext (null, "Generating %s informations").printf (pkgname) + "...");
if (!(database.regenerate_srcinfo (pkgname, build_cancellable))) {
// error
continue;
return false;
}
}
if (build_cancellable.is_cancelled ()) {
return;
return false;
}
emit_action (dgettext (null, "Checking %s dependencies").printf (pkgname) + "...");
var srcinfo = clone_dir.get_child (".SRCINFO");
......@@ -631,12 +645,13 @@ namespace Pamac {
}
} catch (Error e) {
critical ("%s\n", e.message);
continue;
return false;
}
}
if (dep_to_check.length > 0) {
check_aur_dep_list (dep_to_check.data);
return check_aur_dep_list (dep_to_check.data);
}
return true;
}
void check_signature (string pkgname, SList<string> keys) {
......@@ -824,7 +839,9 @@ namespace Pamac {
}
}
if (to_build.length > 0 || check_aur_updates_now) {
compute_aur_build_list ();
if (!compute_aur_build_list ()) {
return false;
}
aur_updates = new List<AURPackage> ();
if (build_cancellable.is_cancelled ()) {
return false;
......
......@@ -44,7 +44,7 @@ namespace Pamac {
public abstract void trans_cancel () throws Error;
public abstract void quit_daemon () throws Error;
public signal int choose_provider (string depend, string[] providers);
public signal void compute_aur_build_list ();
public signal bool compute_aur_build_list ();
public signal bool ask_edit_build_files (TransactionSummaryStruct summary);
public signal void edit_build_files (string[] pkgnames);
public signal bool ask_commit (TransactionSummaryStruct summary);
......
......@@ -271,9 +271,9 @@ namespace Pamac {
if (sender != this.sender) {
return;
}
compute_aur_build_list ();
bool success = compute_aur_build_list ();
try {
system_daemon.aur_build_list_computed ();
system_daemon.aur_build_list_computed (success);
} catch (Error e) {
critical ("build_files_edited: %s\n", e.message);
}
......
......@@ -42,7 +42,7 @@ namespace Pamac {
return choose_provider (depend, providers);
});
alpm_utils.compute_aur_build_list.connect ((sender) => {
compute_aur_build_list ();
return compute_aur_build_list ();
});
alpm_utils.emit_download_progress.connect ((sender, action, status, progress) => {
emit_download_progress (action, status, progress);
......
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