Skip to content

Commit d931069

Browse files
committed
wip
1 parent f1fcb85 commit d931069

File tree

6 files changed

+66
-15
lines changed

6 files changed

+66
-15
lines changed

bin/pkg-test

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ async function prep_script(srcroot: Path, { pkg }: Installation, tmpdir: Path) {
8787
import test_runner from '${srcroot.join("projects", pkg.project, "test.ts").fileURL()}';
8888
import { Path, SemVer } from 'brewkit';
8989
const prefix = new Path(Deno.args[0]);
90-
const version = new SemVer(prefix.basename());
90+
const version = new SemVer(Deno.args[1]);
91+
92+
for (const envln of Deno.args.slice(2)) {
93+
const [key, value] = envln.split("=");
94+
Deno.env.set(key, value);
95+
}
9196

9297
if (Deno.env.get("GITHUB_ACTIONS")) {
9398
console.log("::group::env");
@@ -121,7 +126,9 @@ async function prep_script(srcroot: Path, { pkg }: Installation, tmpdir: Path) {
121126
}
122127
}
123128

124-
async function run(deno: string, srcroot: Path, { path: prefix, pkg }: Installation, tmpdir: Path, env: Record<string, string>) {
129+
async function run(deno: string, srcroot: Path, { path: prefix, pkg }: Installation, tmpdir: Path, runenv: Record<string, string>) {
130+
const env: Record<string, string> = {}
131+
125132
let [cmd, ...args]: string[] = (() => {
126133
if (Deno.build.os !== 'darwin') return [deno];
127134

@@ -173,6 +180,7 @@ async function run(deno: string, srcroot: Path, { path: prefix, pkg }: Installat
173180
tmpdir.join("run-test.ts").string,
174181
prefix.string,
175182
pkg.version.toString(),
183+
...Object.entries(runenv).map((value, key) => `${key}=${value}`),
176184
);
177185

178186
const cwd = tmpdir.join("testbed").mkdir().string;

brewkit/mod.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,16 @@ export { getVersions as gitlab };
231231

232232
import venvify from "./venvify.ts";
233233
export { venvify };
234+
235+
export async function tmp<T>(fn: (d: Path) => Promise<T>): Promise<T> {
236+
//TODO actually base off of original CWD
237+
const tmp = Path.cwd().join(Math.random().toString(36).substring(2, 15))
238+
.mkdir();
239+
try {
240+
Deno.chdir(tmp.string);
241+
return await fn(tmp);
242+
} finally {
243+
Deno.chdir(tmp.parent().string);
244+
tmp.rm("rf");
245+
}
246+
}

brewkit/run.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,37 @@ export function backticks_quiet(
7979
}
8080

8181
function splitArgs(input: string): string[] {
82-
const regex = /"([^"]*)"|'([^']*)'|(\S+)/g;
82+
// Remove comments
83+
input = input.replace(/#.*$/gm, "").trim();
84+
8385
const args: string[] = [];
86+
const regex = /(?:[^\s"'=]+=(?:"[^"]*"|'[^']*'|[^\s]+)|"[^"]*"|'[^']*'|[^\s]+)/g;
8487
let match;
8588

86-
// Remove comments
87-
input = input.replace(/#.*$/gm, "");
88-
8989
while ((match = regex.exec(input)) !== null) {
90-
args.push((match[1] || match[2] || match[3]).trim());
90+
let token = match[0];
91+
92+
// Strip outer quotes around right-hand side of `key=val`
93+
if (token.includes("=")) {
94+
const [key, val] = token.split(/=(.+)/, 2);
95+
if (
96+
(val.startsWith('"') && val.endsWith('"')) ||
97+
(val.startsWith("'") && val.endsWith("'"))
98+
) {
99+
args.push(`${key}=${val.slice(1, -1)}`);
100+
} else {
101+
args.push(token);
102+
}
103+
} else {
104+
// Strip quotes for standalone quoted values
105+
if (
106+
(token.startsWith('"') && token.endsWith('"')) ||
107+
(token.startsWith("'") && token.endsWith("'"))
108+
) {
109+
token = token.slice(1, -1);
110+
}
111+
args.push(token);
112+
}
91113
}
92114

93115
return args;

projects/gnu.org/gcc/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default async function build({ prefix, version }: BuildOptions) {
1818
--enable-lto
1919
#TODO --with-system-zlib
2020
--with-bugurl=https://github.com/pkgxdev/manifests/issues
21-
"--with-pkgversion=pkgx GCC ${version}"
21+
--with-pkgversion="pkgx GCC ${version}"
2222
`;
2323
run`make --jobs ${navigator.hardwareConcurrency}`;
2424
run`make install-strip`;

projects/gnu.org/glibc/build.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
1-
import { BuildOptions, env_include, Path, run, stub, unarchive } from "brewkit";
1+
import { BuildOptions, env_include, Path, run, stub, unarchive, tmp } from "brewkit";
22

33
export default async function ({ prefix, tag, version }: BuildOptions) {
44
await unarchive(`http://ftp.gnu.org/gnu/libc/glibc-${tag}.tar.gz`);
55

66
stub("gawk bison");
77
env_include("gnu.org/gcc");
88

9+
const kernel_headers = Path.cwd().join(`kernel-5.4`);
10+
await tmp(async () => {
11+
await unarchive(`https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.tar.xz`);
12+
run`make INSTALL_HDR_PATH=${kernel_headers}`;
13+
});
14+
915
Path.cwd().join("build").mkdir().cd();
1016

1117
run`../configure
1218
--prefix=${prefix}
1319
--disable-debug
14-
# --enable-kernel=2.6.0
20+
--enable-kernel=5.4 # LTS 2029
1521
--disable-dependency-tracking
1622
--disable-silent-rules
1723
--disable-werror
18-
--enable-obsolete-rpc
1924
--without-gd
2025
--without-selinux
21-
--enable-multi-arch # makes our glibc work on more intel archs
22-
"--with-pkgversion=pkgx glibc-${version}"
26+
--with-pkgversion="pkgx glibc-${version}"
2327
--with-bugurl=https://github.com/pkgxdev/pantry/issues/new
24-
"CFLAGS=-O2 -march=x86-64 -mtune=generic"
28+
--with-headers=${kernel_headers}/include
29+
CFLAGS="-O2 -march=x86-64 -mtune=generic"
2530
`;
26-
run`make`;// --jobs ${navigator.hardwareConcurrency}`;
31+
run`make --jobs ${navigator.hardwareConcurrency}`;
2732
// run`make check`;
2833
run`make install`;
2934
}

projects/gnu.org/glibc/test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default async function() {
2+
//TODO
3+
}

0 commit comments

Comments
 (0)