Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
pamac
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
154
Issues
154
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Applications
pamac
Commits
749c0780
Commit
749c0780
authored
Oct 20, 2018
by
guinux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve cancellation
parent
f7daca32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
61 deletions
+84
-61
src/cli.vala
src/cli.vala
+13
-5
src/transaction-cli.vala
src/transaction-cli.vala
+2
-0
src/transaction.vala
src/transaction.vala
+69
-56
No files found.
src/cli.vala
View file @
749c0780
...
...
@@ -191,7 +191,6 @@ namespace Pamac {
}
else
if
(
arg
==
"--recurse"
||
arg
==
"-r"
)
{
recurse
=
true
;
}
else
if
(
arg
==
"--builddir"
)
{
stdout
.
printf
(
"dir %s\n"
,
args
[
i
+
1
]);
if
(
args
[
i
+
1
]
!=
null
)
{
database
.
config
.
aur_build_dir
=
args
[
i
+
1
];
}
...
...
@@ -252,6 +251,15 @@ namespace Pamac {
if
(
parent
!=
null
)
{
database
.
config
.
aur_build_dir
=
parent
.
get_path
();
}
}
else
if
(!
transaction
.
clone_build_files
)
{
// check if targets exist
foreach
(
unowned
string
target
in
targets
)
{
var
dir
=
File
.
new_for_path
(
Path
.
build_path
(
"/"
,
database
.
config
.
aur_build_dir
,
target
));
if
(!
dir
.
query_exists
())
{
print_error
(
dgettext
(
null
,
"target not found: %s"
).
printf
(
target
));
return
;
}
}
}
build_pkgs
(
targets
);
}
else
if
(
args
[
1
]
==
"install"
)
{
...
...
@@ -964,7 +972,7 @@ namespace Pamac {
foreach
(
unowned
string
pkgname
in
pkgnames
)
{
var
details
=
database
.
get_pkg_details
(
pkgname
,
""
,
false
);
if
(
details
.
name
==
""
)
{
print_error
(
dgettext
(
null
,
"target not found: %s"
).
printf
(
pkgname
)
+
"\n"
);
print_error
(
dgettext
(
null
,
"target not found: %s"
).
printf
(
pkgname
));
continue
;
}
// Name
...
...
@@ -1166,7 +1174,7 @@ namespace Pamac {
unowned
AURPackageDetails
details
;
while
(
iter
.
next
(
out
pkgname
,
out
details
))
{
if
(
details
.
name
==
""
)
{
print_error
(
dgettext
(
null
,
"target not found: %s"
).
printf
(
pkgname
)
+
"\n"
);
print_error
(
dgettext
(
null
,
"target not found: %s"
).
printf
(
pkgname
));
return
;
}
// Name
...
...
@@ -1758,7 +1766,7 @@ namespace Pamac {
unowned
AURPackageDetails
aur_pkg_details
;
while
(
iter
.
next
(
out
pkgname
,
out
aur_pkg_details
))
{
if
(
aur_pkg_details
.
name
==
""
)
{
print_error
(
dgettext
(
null
,
"target not found: %s"
).
printf
(
pkgname
)
+
"\n"
);
print_error
(
dgettext
(
null
,
"target not found: %s"
).
printf
(
pkgname
));
continue
;
}
else
{
// clone build files
...
...
@@ -1808,7 +1816,7 @@ namespace Pamac {
unowned
AURPackage
aur_pkg
;
while
(
iter
.
next
(
out
pkgname
,
out
aur_pkg
))
{
if
(
aur_pkg
.
name
==
""
)
{
print_error
(
dgettext
(
null
,
"target not found: %s"
).
printf
(
pkgname
)
+
"\n"
);
print_error
(
dgettext
(
null
,
"target not found: %s"
).
printf
(
pkgname
));
return
false
;
}
}
...
...
src/transaction-cli.vala
View file @
749c0780
...
...
@@ -506,6 +506,8 @@ namespace Pamac {
yield
process
.
wait_async
();
if
(
process
.
get_if_exited
())
{
if
(
process
.
get_exit_status
()
==
0
)
{
// emit start_preparing to make regenerate_srcinfo cancellable
start_preparing
();
return
yield
regenerate_srcinfo
(
pkgname
);
}
}
...
...
src/transaction.vala
View file @
749c0780
...
...
@@ -174,7 +174,7 @@ namespace Pamac {
}
}
}
catch
(
GLib
.
Error
e
)
{
stderr
.
printf
(
"Error: %s\n"
,
e
.
message
);
stderr
.
printf
(
"Error: %s\n"
,
e
.
message
);
}
return
files
;
}
...
...
@@ -185,25 +185,39 @@ namespace Pamac {
var
launcher
=
new
SubprocessLauncher
(
SubprocessFlags
.
STDOUT_PIPE
);
launcher
.
set_cwd
(
pkgdir_name
);
emit_action
(
dgettext
(
null
,
"Generating %s informations"
).
printf
(
pkgname
)
+
"..."
);
// set building to allow cancellation
building
=
true
;
try
{
Subprocess
process
=
launcher
.
spawnv
({
"makepkg"
,
"--printsrcinfo"
});
yield
process
.
wait_async
();
if
(
process
.
get_if_exited
())
{
if
(
process
.
get_exit_status
()
==
0
)
{
var
dis
=
new
DataInputStream
(
process
.
get_stdout_pipe
());
var
file
=
File
.
new_for_path
(
Path
.
build_path
(
"/"
,
pkgdir_name
,
".SRCINFO"
));
// delete the file before rewrite it
yield
file
.
delete_async
();
// creating a DataOutputStream to the file
var
dos
=
new
DataOutputStream
(
yield
file
.
create_async
(
FileCreateFlags
.
REPLACE_DESTINATION
));
// writing makepkg output to .SRCINFO
yield
dos
.
splice_async
(
dis
,
0
);
return
true
;
try
{
yield
process
.
wait_async
(
build_cancellable
);
if
(
process
.
get_if_exited
())
{
if
(
process
.
get_exit_status
()
==
0
)
{
try
{
var
dis
=
new
DataInputStream
(
process
.
get_stdout_pipe
());
var
file
=
File
.
new_for_path
(
Path
.
build_path
(
"/"
,
pkgdir_name
,
".SRCINFO"
));
// delete the file before rewrite it
yield
file
.
delete_async
();
// creating a DataOutputStream to the file
var
dos
=
new
DataOutputStream
(
yield
file
.
create_async
(
FileCreateFlags
.
REPLACE_DESTINATION
));
// writing makepkg output to .SRCINFO
yield
dos
.
splice_async
(
dis
,
0
);
building
=
false
;
return
true
;
}
catch
(
Error
e
)
{
stderr
.
printf
(
"Error: %s\n"
,
e
.
message
);
}
}
}
}
catch
(
Error
e
)
{
// cancelled
process
.
send_signal
(
Posix
.
Signal
.
INT
);
process
.
send_signal
(
Posix
.
Signal
.
KILL
);
}
}
catch
(
Error
e
)
{
stderr
.
printf
(
"Error: %s\n"
,
e
.
message
);
}
building
=
false
;
return
false
;
}
...
...
@@ -272,34 +286,18 @@ namespace Pamac {
if
(!
success
)
{
on_trans_prepare_finished
(
false
);
}
else
{
to_build
=
{};
sysupgrading
=
true
;
emit_action
(
dgettext
(
null
,
"Starting full system upgrade"
)
+
"..."
);
if
(
database
.
config
.
check_aur_updates
)
{
database
.
get_aur_updates
.
begin
((
obj
,
res
)
=>
{
var
aur_updates
=
database
.
get_aur_updates
.
end
(
res
);
to_build
=
{};
foreach
(
unowned
AURPackage
aur_update
in
aur_updates
)
{
if
(!(
aur_update
.
name
in
temporary_ignorepkgs
))
{
to_build
+=
aur_update
.
name
;
}
}
if
(
to_build
.
length
!=
0
)
{
// set building to allow cancellation
building
=
true
;
build_cancellable
.
reset
();
compute_aur_build_list
.
begin
((
obj
,
res
)
=>
{
bool
compute_success
=
compute_aur_build_list
.
end
(
res
);
building
=
false
;
if
(!
compute_success
||
build_cancellable
.
is_cancelled
())
{
on_trans_prepare_finished
(
false
);
return
;
}
aur_unresolvables
=
{};
sysupgrade_real
();
});
}
else
{
sysupgrade_real
();
}
sysupgrade_real
();
});
}
else
{
sysupgrade_real
();
...
...
@@ -336,7 +334,7 @@ namespace Pamac {
downloading_updates_finished
();
}
async
bool
compute_aur_build_list
()
{
async
void
compute_aur_build_list
()
{
string
tmp_path
=
"/tmp/pamac"
;
try
{
var
file
=
GLib
.
File
.
new_for_path
(
tmp_path
);
...
...
@@ -350,8 +348,8 @@ namespace Pamac {
}
aur_desc_list
.
remove_all
();
already_checked_aur_dep
.
remove_all
();
bool
success
=
yield
check_aur_dep_list
(
to_build
);
if
(
success
)
{
yield
check_aur_dep_list
(
to_build
);
if
(
aur_desc_list
.
length
>
0
)
{
// create a fake aur db
try
{
var
list
=
new
StringBuilder
();
...
...
@@ -363,13 +361,11 @@ namespace Pamac {
Process
.
spawn_command_line_sync
(
"bsdtar -cf %s/aur.db -C %s %s"
.
printf
(
tmp_path
,
aurdb_path
,
list
.
str
));
}
catch
(
SpawnError
e
)
{
stderr
.
printf
(
"SpawnError: %s\n"
,
e
.
message
);
success
=
false
;
}
}
return
success
;
}
async
bool
check_aur_dep_list
(
string
[]
pkgnames
)
{
async
void
check_aur_dep_list
(
string
[]
pkgnames
)
{
string
[]
dep_to_check
=
{};
var
aur_pkgs
=
new
HashTable
<
string
,
AURPackage
>
(
str_hash
,
str_equal
);
if
(
clone_build_files
)
{
...
...
@@ -377,14 +373,14 @@ namespace Pamac {
}
foreach
(
unowned
string
pkgname
in
pkgnames
)
{
if
(
build_cancellable
.
is_cancelled
())
{
return
false
;
return
;
}
File
?
clone_dir
;
if
(
clone_build_files
)
{
unowned
AURPackage
aur_pkg
=
aur_pkgs
.
lookup
(
pkgname
);
if
(
aur_pkg
.
name
==
""
)
{
emit_error
(
dgettext
(
null
,
"target not found: %s"
).
printf
(
pkgname
),
{});
return
fals
e
;
// error
continu
e
;
}
// clone build files
// use packagebase in case of split package
...
...
@@ -392,18 +388,21 @@ namespace Pamac {
clone_dir
=
yield
database
.
clone_build_files
(
aur_pkg
.
packagebase
,
false
);
if
(
clone_dir
==
null
)
{
// error
return
fals
e
;
continu
e
;
}
}
else
{
clone_dir
=
File
.
new_for_path
(
Path
.
build_path
(
"/"
,
database
.
config
.
aur_build_dir
,
pkgname
));
if
(!
clone_dir
.
query_exists
())
{
// error
return
false
;
continue
;
}
if
(!(
yield
regenerate_srcinfo
(
pkgname
)))
{
// error
continue
;
}
yield
regenerate_srcinfo
(
pkgname
);
}
if
(
build_cancellable
.
is_cancelled
())
{
return
false
;
return
;
}
emit_action
(
dgettext
(
null
,
"Checking %s dependencies"
.
printf
(
pkgname
))
+
"..."
);
var
srcinfo
=
clone_dir
.
get_child
(
".SRCINFO"
);
...
...
@@ -627,21 +626,35 @@ namespace Pamac {
}
}
}
catch
(
GLib
.
Error
e
)
{
stderr
.
printf
(
"Error: %s\n"
,
e
.
message
);
return
fals
e
;
stderr
.
printf
(
"Error: %s\n"
,
e
.
message
);
continu
e
;
}
}
bool
success
=
true
;
if
(
dep_to_check
.
length
>
0
)
{
success
=
yield
check_aur_dep_list
(
dep_to_check
);
yield
check_aur_dep_list
(
dep_to_check
);
}
return
success
;
}
void
sysupgrade_real
()
{
start_preparing
();
// this will respond with trans_prepare_finished signal
transaction_interface
.
start_sysupgrade_prepare
(
enable_downgrade
,
to_build
,
temporary_ignorepkgs
,
overwrite_files
);
if
(
to_build
.
length
!=
0
)
{
// set building to allow cancellation
building
=
true
;
build_cancellable
.
reset
();
compute_aur_build_list
.
begin
(()
=>
{
building
=
false
;
if
(
build_cancellable
.
is_cancelled
())
{
on_trans_prepare_finished
(
false
);
return
;
}
aur_unresolvables
=
{};
// this will respond with trans_prepare_finished signal
transaction_interface
.
start_sysupgrade_prepare
(
enable_downgrade
,
to_build
,
temporary_ignorepkgs
,
overwrite_files
);
});
}
else
{
// this will respond with trans_prepare_finished signal
transaction_interface
.
start_sysupgrade_prepare
(
enable_downgrade
,
to_build
,
temporary_ignorepkgs
,
overwrite_files
);
}
}
public
void
start_sysupgrade
(
bool
force_refresh
,
bool
enable_downgrade
,
string
[]
temporary_ignorepkgs
,
string
[]
overwrite_files
)
{
...
...
@@ -653,14 +666,14 @@ namespace Pamac {
}
void
trans_prepare_real
()
{
start_preparing
();
if
(
to_build
.
length
!=
0
)
{
// set building to allow cancellation
building
=
true
;
build_cancellable
.
reset
();
compute_aur_build_list
.
begin
((
obj
,
res
)
=>
{
bool
success
=
compute_aur_build_list
.
end
(
res
);
compute_aur_build_list
.
begin
(()
=>
{
building
=
false
;
if
(
!
success
||
build_cancellable
.
is_cancelled
())
{
if
(
build_cancellable
.
is_cancelled
())
{
on_trans_prepare_finished
(
false
);
return
;
}
...
...
@@ -680,7 +693,6 @@ namespace Pamac {
this
.
temporary_ignorepkgs
=
temporary_ignorepkgs
;
this
.
overwrite_files
=
overwrite_files
;
emit_action
(
dgettext
(
null
,
"Preparing"
)
+
"..."
);
start_preparing
();
connecting_signals
();
trans_prepare_real
();
}
...
...
@@ -737,7 +749,7 @@ namespace Pamac {
launcher
.
set_cwd
(
pkgdir
);
try
{
Subprocess
process
=
launcher
.
spawnv
({
"makepkg"
,
"--packagelist"
});
yield
process
.
wait_async
(
null
);
yield
process
.
wait_async
(
build_cancellable
);
if
(
process
.
get_if_exited
())
{
status
=
process
.
get_exit_status
();
}
...
...
@@ -1216,6 +1228,7 @@ namespace Pamac {
}
else
if
(
build_cancellable
.
is_cancelled
())
{
finish_transaction
(
false
);
}
else
if
(
to_build
.
length
>
0
)
{
emit_action
(
dgettext
(
null
,
"Failed to prepare transaction"
)
+
"."
);
check_aur_unresolvables_and_edit_build_files
.
begin
();
}
else
{
handle_error
(
get_current_error
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment