Skip to content

Commit

Permalink
GHA musl: need to install compilers (#42)
Browse files Browse the repository at this point in the history
* GHA musl: need to install compilers

* GHA musl: need libcurl as well

* GHA musl: more system packages

* Fix compilation on musl

* GHA musl: need checkbashisms, do not strip
  • Loading branch information
gaborcsardi authored Nov 2, 2024
1 parent 1a0c537 commit 40aba5e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/musl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ permissions: read-all

jobs:
R-CMD-check:
name: Alpine 3.20
name: Alpine 3.19
runs-on: ubuntu-latest
container:
image: ghcr.io/r-hub/r-minimal/r-minimal:latest
Expand All @@ -28,6 +28,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install compilers, system libs
run: |
apk add gcc musl-dev g++ curl-dev linux-headers checkbashisms
shell: bash

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
Expand All @@ -39,3 +44,5 @@ jobs:
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
env:
_R_SHLIB_STRIP_: false
25 changes: 25 additions & 0 deletions src/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,15 @@ SEXP r_nsl(SEXP hostname, SEXP server, SEXP class, SEXP type) {
SET_VECTOR_ELT(result, 0, records);
SET_VECTOR_ELT(result, 1, mkNamed(LGLSXP, flagnames));

#if (__RES >= 19991006)
struct __res_state state;
res_state statep = &state;
memset(statep, 0, sizeof(state));
ret = res_ninit(statep);
#else
res_state statep = &_res;
ret = res_init();
#endif
if (ret) R_THROW_SYSTEM_ERROR("Failed to initialize resolver library");

if (!isNull(server)) {
Expand All @@ -322,21 +327,29 @@ SEXP r_nsl(SEXP hostname, SEXP server, SEXP class, SEXP type) {
statep->nsaddr_list[0].sin_addr = addr;
}

#if (__RES >= 19991006)
ret = res_nquery(
statep,
#else
ret = res_query(
#endif
CHAR(STRING_ELT(hostname, 0)),
INTEGER(class)[0],
INTEGER(type)[0],
answer,
sizeof answer);
if (ret == -1) {
#if (__RES >= 19991006)
res_nclose(statep);
#endif
R_THROW_SYSTEM_ERROR("DNS query failed");
}

ret = ns_initparse(answer, ret, &msg);
if (ret == -1) {
#if (__RES >= 19991006)
res_nclose(statep);
#endif
R_THROW_SYSTEM_ERROR("Cannot parse DNS answer");
}

Expand Down Expand Up @@ -369,7 +382,9 @@ SEXP r_nsl(SEXP hostname, SEXP server, SEXP class, SEXP type) {

ret = ns_parserr(&msg, ns_s_an, i, &rec);
if (ret == -1) {
#if (__RES >= 19991006)
res_nclose(statep);
#endif
R_THROW_SYSTEM_ERROR("Cannot parse DNS record");
}
class = ns_rr_class(rec);
Expand Down Expand Up @@ -417,7 +432,9 @@ SEXP r_nsl(SEXP hostname, SEXP server, SEXP class, SEXP type) {
ret = xxns_name_uncompress(ns_msg_base(msg), ns_msg_end(msg),
data, buf, sizeof buf);
if (ret < 0) {
#if (__RES >= 19991006)
res_nclose(statep);
#endif
R_THROW_SYSTEM_ERROR("Cannot parse SOA DNS record");
}

Expand All @@ -429,7 +446,9 @@ SEXP r_nsl(SEXP hostname, SEXP server, SEXP class, SEXP type) {
ret = xxns_name_uncompress(ns_msg_base(msg), ns_msg_end(msg),
data, buf2, bufsize);
if (ret < 0) {
#if (__RES >= 19991006)
res_nclose(statep);
#endif
R_THROW_SYSTEM_ERROR("Cannot parse SOA DNS record");
}

Expand All @@ -439,7 +458,9 @@ SEXP r_nsl(SEXP hostname, SEXP server, SEXP class, SEXP type) {
}

if (ns_msg_end(msg) - data < 5*NS_INT32SZ) {
#if (__RES >= 19991006)
res_nclose(statep);
#endif
R_THROW_ERROR("Cannot parse SOA DNS record");
}
for (j = 0; j < 5; j++) NS_GET32(soa[j], data);
Expand All @@ -457,14 +478,18 @@ SEXP r_nsl(SEXP hostname, SEXP server, SEXP class, SEXP type) {
}

if (ret < 0) {
#if (__RES >= 19991006)
res_nclose(statep);
#endif
R_THROW_SYSTEM_ERROR("Cannot parse NS/PTR/CNAME DNS record");
}

if (!raw) SET_VECTOR_ELT(VECTOR_ELT(records, 4), i, mkString(buf));
}

#if (__RES >= 19991006)
res_nclose(statep);
#endif
UNPROTECT(3);
return result;
}
Expand Down

0 comments on commit 40aba5e

Please sign in to comment.