Skip to content

Commit 650eaea

Browse files
committed
refactor: update unarchive logic for Windows and improve tar command handling
1 parent 52fc782 commit 650eaea

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

bin/pkg-build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ async function prep_toolchain() {
5555
Deno.env.set("PATH", `${bin};${Deno.env.get("PATH")}`);
5656

5757
// bsdtar needs a gzip.exe and I couldn’t figure out how to make a .cmd that worked
58-
const gzip = backticks_quiet`pkgx -q +github.com/ebiggers/libdeflate -- where libdeflate-gzip`;
59-
new Path(gzip).cp({ to: bin.join("gzip.exe") });
58+
// const gzip = backticks_quiet`pkgx -q +github.com/ebiggers/libdeflate -- where libdeflate-gzip`;
59+
// new Path(gzip).cp({ to: bin.join("gzip.exe") });
6060
}
6161

6262
Deno.env.set("PKGX_BIN", bin.string);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@echo off
2+
setlocal
3+
4+
pkgx -q cmake %*
5+
if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%
6+
7+
endlocal
8+
exit /b 0

brewkit/unarchive.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export default async function (
88
): Promise<void> {
99
console.error("%c+", "color:yellow", "unarchiving:", url);
1010

11-
if (url.endsWith(".zip")) {
11+
// on windows the tar is bsdtar which can extract zip files
12+
if (url.endsWith(".zip") && Deno.build.os != "windows") {
1213
const tmp = new Path(Deno.makeTempFileSync());
1314
const rsp = await fetch(url);
1415
if (!rsp.ok) {
@@ -78,7 +79,7 @@ function mktar(url: string, stripComponents: number) {
7879
const rv = ["pkgx"];
7980
if (mode == 'xJf') rv.push('+xz');
8081
if (mode == 'xjf') rv.push('+bzip2');
81-
rv.push("bsdtar", mode, "-", `--strip-components=${stripComponents}`);
82+
rv.push("--", "tar", mode, "-", `--strip-components=${stripComponents}`);
8283
return rv;
8384
}
8485
}

projects/git-scm.org/build.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { BuildOptions, inreplace, Path, run, unarchive } from "brewkit";
22

3-
export default async function ({ prefix, version, props }: BuildOptions) {
4-
await unarchive(`https://mirrors.edge.kernel.org/pub/software/scm/git/git-${version}.tar.gz`);
3+
export default async function ({ prefix, tag, version, props }: BuildOptions) {
4+
// windows fails to unarchive the .tag.gz for some reason
5+
const url = Deno.build.os != 'windows'
6+
? `https://mirrors.edge.kernel.org/pub/software/scm/git/git-${version}.tar.gz`
7+
: `https://github.com/git-for-windows/git/archive/refs/tags/${tag}.zip`;
8+
9+
await unarchive(url);
510

611
props.join("config.mak").cp({ into: Path.cwd() });
712

projects/git-scm.org/versions.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
import { Range } from "jsr:@std/semver@^1";
2-
import { github } from "brewkit";
1+
import { github, Range, SemVer } from "brewkit";
32

43
export default async function (constraint: Range) {
4+
if (Deno.build.os == 'windows') {
5+
return (await github.releases("git-for-windows/git", constraint)).map(({tag_name}) => {
6+
const vstr = tag_name.replace(/\.windows\.\d+$/, "");
7+
return { tag: tag_name, version: new SemVer(vstr) };
8+
});
9+
}
510
return (await github.tags("git/git")).map((x) => {
611
try {
712
if (!x.name.startsWith("v") || /-.*$/.test(x.name)) {

0 commit comments

Comments
 (0)