Skip to content

Commit

Permalink
parallel package extract
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed May 21, 2024
1 parent c3a9b65 commit 74b9859
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
22 changes: 12 additions & 10 deletions src/data/package.vala
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,19 @@ public class package {
var rootfs_medatata = get_storage () + "/quarantine/metadata/";
var rootfs_files = get_storage () + "/quarantine/files/";
var rootfs_links = get_storage () + "/quarantine/links/";
var tempdir = get_storage () + "/quarantine/tmp/"+ name;
if (isfile (rootfs_medatata + name + ".yaml")) {
debug (_ ("Skip quartine package extract: %s").printf (name));
return;
}
// extract data archive
pkgfile.set_target (get_storage () + "/quarantine");
pkgfile.set_target (tempdir);
foreach (string data in pkgfile.list_files ()) {
// Allowed formats: data.tar.xz data.zip data.tar.zst data.tar.gz ..
if (startswith (data, "data.")) {
// 1. data.* file extract to quarantine from ymp package
pkgfile.extract (data);
var datafile = get_storage () + "/quarantine/" + data;
var datafile = tempdir + "/" + data;
// 2. validate data archive
var data_hash = calculate_sha1sum (datafile);
if (data_hash != get ("archive-hash")) {
Expand All @@ -266,20 +267,21 @@ public class package {
}
}
// extract metadata
if (isfile (rootfs_medatata + "metadata.yaml")) {
remove_file (rootfs_medatata + "metadata.yaml");
if (isfile (tempdir + "/metadata.yaml")) {
remove_file (tempdir + "/metadata.yaml");
}
pkgfile.set_target (rootfs_medatata);
pkgfile.set_target (tempdir);
pkgfile.extract ("metadata.yaml");
move_file (rootfs_medatata + "metadata.yaml", rootfs_medatata + name + ".yaml");
move_file (tempdir + "/metadata.yaml", rootfs_medatata + name + ".yaml");
// extract files
pkgfile.set_target (rootfs_files);
pkgfile.set_target (tempdir);
pkgfile.extract ("files");
move_file (rootfs_files + "files", rootfs_files + name);
move_file (tempdir + "/files", rootfs_files + name);
// extract links
pkgfile.set_target (rootfs_links);
pkgfile.set_target (tempdir);
pkgfile.extract ("links");
move_file (rootfs_links + "links", rootfs_links + name);
move_file (tempdir + "/links", rootfs_links + name);
// remove tempdir
error (3);
}
//DOC: `void package.build ():`
Expand Down
1 change: 1 addition & 0 deletions src/data/quarantine.vala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ private array quarantine_file_broken_list;
public void quarantine_reset () {
remove_all (get_storage () + "/quarantine/");
create_dir (get_storage () + "/quarantine/rootfs");
create_dir (get_storage () + "/quarantine/tmp");
create_dir (get_storage () + "/quarantine/files");
create_dir (get_storage () + "/quarantine/links");
create_dir (get_storage () + "/quarantine/metadata");
Expand Down
19 changes: 14 additions & 5 deletions src/operations/package-manager/install.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ private static int install_main (string[] args) {
if (get_bool ("download-only")) {
return 0;
}
j = new jobs();
foreach (string name in pkgs) {
package pkg = install_single (name);
package *pkg = package_get_single (name);
if (pkg == null) {
error (1);
}else {
pkg_obj += pkg;
j.add((void*)package_extract_single, pkg);
}
}
j.run();
string[] leftovers = calculate_leftover (pkg_obj);
if (!quarantine_validate_files ()) {
error_add (_ ("Quarantine validation failed."));
Expand All @@ -74,7 +77,7 @@ private static int install_main (string[] args) {
error (1);
return 0;
}
private static package install_single (string pkg) {
private static package package_get_single (string pkg) {
package p = null;
// Download package files from repository
if (isfile (pkg)) {
Expand All @@ -96,8 +99,8 @@ private static package install_single (string pkg) {
}
}
error (2);
print (colorize (_ ("Installing: %s"), yellow).printf (p.name));
if (p.is_source || get_bool ("sync-single")) {
print (colorize (_ ("Building: %s"), yellow).printf (p.name));
p.build ();
if (!quarantine_validate_files ()) {
error_add (_ ("Quarantine validation failed."));
Expand All @@ -107,11 +110,17 @@ private static package install_single (string pkg) {
quarantine_install ();
quarantine_reset ();
sysconf_main ( {});
}else {
p.extract ();
}
return p;
}

private static void package_extract_single(package *p){
if (!p->is_source) {
print (colorize (_ ("Installing: %s"), yellow).printf (p->name));
p->extract();
}
}

private static string[] calculate_leftover (package[] pkgs) {
print (colorize (_ ("Calculating leftovers"), yellow));
var files = new array ();
Expand Down

0 comments on commit 74b9859

Please sign in to comment.