Skip to content

Commit

Permalink
git based packages mark as unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed Dec 12, 2023
1 parent 87929d7 commit 5411521
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
25 changes: 21 additions & 4 deletions src/util/build.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class builder {
backup_env();
clear_env();
set_env("PATH","/sbin:/bin:/usr/sbin:/usr/bin");

bool unsafe = get_bool("unsafe");
string srcpath = srealpath(path);
string srcpkg = "";
string binpkg = "";
Expand All @@ -57,10 +57,9 @@ public class builder {
} else {
output = srealpath(output);
}
if (!isdir(output)) {
create_dir(output);
}

if (startswith(path, "git@") || endswith(path, ".git")) {
set_bool("unsafe", true);
srcpath = get_build_dir() + "/" + sbasename(path);
if (isdir(srcpath)) {
remove_all(srcpath);
Expand All @@ -74,6 +73,7 @@ public class builder {
return 2;
}
} else if (startswith(path, "http://") || startswith(path, "https://")) {
set_bool("unsafe", true);
string file = get_build_dir() + "/.cache/" + sbasename(path);
create_dir(file);
string farg = file + "/" + sbasename(path);
Expand All @@ -82,6 +82,9 @@ public class builder {
}
srcpath = farg;
}
if (!isdir(output)) {
create_dir(output);
}
if (isfile(srcpath)) {
string srcdir = get_build_dir() + "/" + calculate_md5sum(srcpath);
create_dir(srcdir);
Expand All @@ -92,19 +95,25 @@ public class builder {
srcpath = srcdir;
if (!isfile(srcpath + "/ympbuild")) {
error_add(_("Package is invalid: %s").printf(srcpath));
set_bool("unsafe", unsafe);
restore_env();
return 2;
}
}
if (!isfile(srcpath + "/ympbuild")) {
set_bool("unsafe", unsafe);
restore_env();
return 0;
}
if (!set_build_target(srcpath)) {
error_add(_("Failed to set build target: %s").printf(srcpath));
set_bool("unsafe", unsafe);
restore_env();
return 1;
}
if (!build_target.create_metadata_info()) {
error_add(_("Failed to create metadata: %s").printf(srcpath));
set_bool("unsafe", unsafe);
restore_env();
return 1;
}
Expand All @@ -115,11 +124,13 @@ public class builder {

info("Check build dependencies");
if (!check_build_dependencies({srcpath})) {
set_bool("unsafe", unsafe);
restore_env();
return 1;
}
info("Fetch sources");
if (!fetch_package_sources()) {
set_bool("unsafe", unsafe);
restore_env();
return 2;
}
Expand All @@ -128,6 +139,7 @@ public class builder {
print(colorize(_("Create source package from :"), yellow) + ymp_build.ympbuild_srcpath);
srcpkg = build_target.create_source_archive();
if (srcpkg == "") {
set_bool("unsafe", unsafe);
restore_env();
return 1;
}
Expand All @@ -139,30 +151,35 @@ public class builder {
if (!get_bool("no-binary")) {
info("Create binary package");
if (!extract_package_sources()) {
set_bool("unsafe", unsafe);
restore_env();
return 3;
}
if (!build_package()) {
set_bool("unsafe", unsafe);
restore_env();
return 1;
}
print(colorize(_("Create binary package from: %s"), yellow).printf(build_path));
binpkg = build_target.create_binary_package();
if (binpkg == "") {
set_bool("unsafe", unsafe);
restore_env();
return 1;
}
if (get_bool("install")) {
if (0 != install_main({
binpkg
})) {
set_bool("unsafe", unsafe);
restore_env();
return 1;
}
}
string target = output + "/" + output_package_name + "_" + build_target.arch + "." + build_target.suffix;
move_file(binpkg, target);
}
set_bool("unsafe", unsafe);
restore_env();
return 0;
}
Expand Down
6 changes: 5 additions & 1 deletion src/util/builder_target/ymp.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ public void build_target_ymp_init() {
ymp_target.create_source_archive.connect(() => {
string buildpath = ymp_target.builder.ymp_build.ympbuild_buildpath;
string curdir = pwd();
bool unsafe = get_bool("unsafe");
cd(ymp_target.builder.ymp_build.ympbuild_srcpath);
string metadata = ymp_target.builder.ymp_build.get_ympbuild_metadata();
if (unsafe) {
metadata += " unsafe: true\n";
}
writefile(srealpath(buildpath + "/metadata.yaml"), metadata.strip() + "\n");
var tar = new archive();
tar.load(buildpath + "/source.zip");
Expand Down Expand Up @@ -155,7 +159,7 @@ public void build_target_ymp_init() {
deps.adds(yaml.get_array(srcdata, "depends"));
}
if (unsafe) {
new_data += " unsafe: true/n";
new_data += " unsafe: true\n";
}
string[] use_flags = ssplit(get_value("use"), " ");
string package_use = get_config("package.use", name);
Expand Down

0 comments on commit 5411521

Please sign in to comment.