Skip to content

Commit

Permalink
okay
Browse files Browse the repository at this point in the history
  • Loading branch information
shinohara-rin committed Mar 17, 2024
1 parent ea49458 commit 91b3f08
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 38 deletions.
33 changes: 14 additions & 19 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30943,33 +30943,28 @@ function setup_precompiled_qemu(version) {

function get_freebsd_image_url_template(version, arch) {
version == "latest" && (version = "14.0");
let [base_url, subdir] = ["14.0", "13.2", "12.4"].includes(version)
? [
`https://download.freebsd.org/releases/VM-IMAGES/${version}-RELEASE`,
"Latest",
]
: [
`http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/VM-IMAGES/${version}-RELEASE`,
"",
];
if(!["14.0", "13.2", "12.4"].includes(version)) {
throw new Error(`Unsupported FreeBSD version: ${version}`);
}
let base_url = `https://github.com/uwulab/manyvm-freebsd-builder/releases/download/v${version}`

let [url_arch, os_arch, instruction_set] =
let [os_arch, instruction_set] =
{
amd64: ["amd64", "", "amd64"],
x86_64: ["amd64", "", "amd64"],
i386: ["i386", "", "i386"],
aarch64: ["aarch64", "arm64", "aarch64"],
riscv64: ["riscv64", "riscv", "riscv64"],
amd64: ["", "amd64"],
x86_64: ["", "amd64"],
i386: ["", "i386"],
aarch64: ["arm64", "aarch64"],
riscv64: ["riscv", "riscv64"],
}[arch] ||
(() => {
throw new Error(`Unknown architecture: ${arch}`);
})();

let filename = `FreeBSD-${version}-RELEASE-${
let filename = `manyvm-FreeBSD-${version}-RELEASE-${
!os_arch ? "" : `${os_arch}-`
}${instruction_set}.qcow2.xz`;
return [
`${base_url}/${url_arch}/${!subdir ? "" : `${subdir}/`}${filename}`,
`${base_url}/${filename}`,
filename,
];
};
Expand Down Expand Up @@ -31054,7 +31049,7 @@ function start_vm(qemu_version, os, cpu, arch, bios, machine, filename, pubkey)
core.startGroup("Start VM");
show_message("info", "Starting VM");

const qemu_executable = `/tmp/qemu-${qemu_version}/bin/qemu-system-${arch}`;
const qemu_executable = `/tmp/qemu-${qemu_version}/usr/local/bin/qemu-system-${arch}`;
let qemu_args = [];
switch (arch) {
case "amd64":
Expand Down Expand Up @@ -31205,7 +31200,7 @@ try {
show_message("info", `Using image URL: ${os_image_url}`);
}

filename = path.resolve(process.cwd(), filename);
filename = path.resolve(`${process.cwd()}/${filename}`);

let uncompressed_filename = filename;
if (filename.endsWith(".xz")) {
Expand Down
33 changes: 14 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,28 @@ function setup_precompiled_qemu(version) {

function get_freebsd_image_url_template(version, arch) {
version == "latest" && (version = "14.0");
let [base_url, subdir] = ["14.0", "13.2", "12.4"].includes(version)
? [
`https://download.freebsd.org/releases/VM-IMAGES/${version}-RELEASE`,
"Latest",
]
: [
`http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/VM-IMAGES/${version}-RELEASE`,
"",
];
if(!["14.0", "13.2", "12.4"].includes(version)) {
throw new Error(`Unsupported FreeBSD version: ${version}`);
}
let base_url = `https://github.com/uwulab/manyvm-freebsd-builder/releases/download/v${version}`

let [url_arch, os_arch, instruction_set] =
let [os_arch, instruction_set] =
{
amd64: ["amd64", "", "amd64"],
x86_64: ["amd64", "", "amd64"],
i386: ["i386", "", "i386"],
aarch64: ["aarch64", "arm64", "aarch64"],
riscv64: ["riscv64", "riscv", "riscv64"],
amd64: ["", "amd64"],
x86_64: ["", "amd64"],
i386: ["", "i386"],
aarch64: ["arm64", "aarch64"],
riscv64: ["riscv", "riscv64"],
}[arch] ||
(() => {
throw new Error(`Unknown architecture: ${arch}`);
})();

let filename = `FreeBSD-${version}-RELEASE-${
let filename = `manyvm-FreeBSD-${version}-RELEASE-${
!os_arch ? "" : `${os_arch}-`
}${instruction_set}.qcow2.xz`;
return [
`${base_url}/${url_arch}/${!subdir ? "" : `${subdir}/`}${filename}`,
`${base_url}/${filename}`,
filename,
];
};
Expand Down Expand Up @@ -164,7 +159,7 @@ function start_vm(qemu_version, os, cpu, arch, bios, machine, filename, pubkey)
core.startGroup("Start VM");
show_message("info", "Starting VM");

const qemu_executable = `/tmp/qemu-${qemu_version}/bin/qemu-system-${arch}`;
const qemu_executable = `/tmp/qemu-${qemu_version}/usr/local/bin/qemu-system-${arch}`;
let qemu_args = [];
switch (arch) {
case "amd64":
Expand Down Expand Up @@ -315,7 +310,7 @@ try {
show_message("info", `Using image URL: ${os_image_url}`);
}

filename = path.resolve(process.cwd(), filename);
filename = path.resolve(`${process.cwd()}/${filename}`);

let uncompressed_filename = filename;
if (filename.endsWith(".xz")) {
Expand Down

0 comments on commit 91b3f08

Please sign in to comment.