Skip to content

Commit 42704e5

Browse files
committed
detect root-user
1 parent efc35f9 commit 42704e5

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

.github/workflows/ci.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ jobs:
7070
alpine:
7171
strategy:
7272
fail-fast: false
73-
matrix:
74-
arch: [amd64, aarch64]
7573
runs-on: ubuntu-latest
7674
container:
7775
image: alpine:latest
@@ -84,7 +82,7 @@ jobs:
8482
- name: Prepare
8583
run: |
8684
apk update
87-
apk add --no-cache ldc dub
85+
apk add --no-cache ldc dub clang
8886
- name: Build
8987
run: |
9088
dub -b release
@@ -93,10 +91,9 @@ jobs:
9391
dub -b release -- list -v
9492
dub -b release -- uninstall ldc2-1.40.0 -v
9593
dub -b release -- list -v
96-
dub -b release -- run -v -- --version
9794
9895
- uses: actions/upload-artifact@v4
9996
if: github.ref == 'refs/heads/main'
10097
with:
101-
name: ldcup-alpine-${{ matrix.arch }}
98+
name: ldcup-alpine-amd64
10299
path: bin

dub.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ldcup",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "Download and manage D compiler [ldc2].",
55
"license": "Apache-2.0",
66
"targetPath": "bin",

source/impl.d

+30-11
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,17 @@ class CompilerManager
8686
else version (FreeBSD)
8787
this.currentOS = OS.freebsd;
8888
else version (linux)
89-
this.currentOS = OS.linux;
89+
version (CRuntime_Musl)
90+
this.currentOS = OS.alpine;
91+
else
92+
this.currentOS = OS.linux;
9093
else version (Windows)
91-
{
92-
this.currentOS = OS.windows;
93-
this.currentArch = Arch.multilib;
94-
}
95-
else version (CRuntime_Musl)
96-
this.currentOS = OS.alpine;
97-
else
98-
static assert(0, "Unsupported operating system");
94+
{
95+
this.currentOS = OS.windows;
96+
this.currentArch = Arch.multilib;
97+
}
98+
else
99+
static assert(0, "Unsupported operating system");
99100
}
100101

101102
void installCompiler(string compilerSpec) @safe
@@ -234,9 +235,27 @@ class CompilerManager
234235
{
235236
try
236237
{
237-
version (linux)
238+
version (FreeBSD)
239+
{
240+
auto result = execute([
241+
"getent", "passwd", environment.get("USER", "root")
242+
]);
243+
if (result.status == 0)
244+
{
245+
246+
string[] parts = result.output.split(":");
247+
if (parts.length > 6)
248+
{
249+
250+
return parts[6].strip();
251+
}
252+
}
253+
}
254+
else version (linux)
238255
{
239-
auto result = execute(["getent", "passwd", environment["USER"]]);
256+
auto result = execute([
257+
"getent", "passwd", environment.get("USER", "root")
258+
]);
240259
if (result.status == 0)
241260
{
242261
string[] parts = result.output.split(":");

0 commit comments

Comments
 (0)