Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] xbps-src: add XBPS_LIBC/XBPS_TARGET_LIBC
@ 2019-07-27  0:51 voidlinux-github
  2019-07-30 15:34 ` voidlinux-github
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: voidlinux-github @ 2019-07-27  0:51 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 988 bytes --]

There is a new pull request by q66 against master on the void-packages repository

https://github.com/void-ppc/void-packages xbps-libc
https://github.com/void-linux/void-packages/pull/13356

xbps-src: add XBPS_LIBC/XBPS_TARGET_LIBC
This can be used in template checks to remove the clunky case statements and pattern matching, as well as simplify normal ifs.

For example:

```
if [ "${XBPS_TARGET_MACHINE%-musl}" = "${XBPS_TARGET_MACHINE}" ]; then
    ... glibc specific ...
fi
```

or

```
case "$XBPS_TARGET_MACHINE" in
    *-musl) ;;
    *) ... glibc specific ...
esac
```

becomes a simple:

```
if [ "${XBPS_TARGET_LIBC}" = "glibc" ]; then
   ... glibc specific ...
fi
```

I've noticed these are common enough of patterns in our stuff to make this worthwhile. The implementation should be sound, I checked and there aren't any `uname` values with a dash in them.

A patch file from https://github.com/void-linux/void-packages/pull/13356.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-xbps-libc-13356.patch --]
[-- Type: text/x-diff, Size: 1406 bytes --]

From 359fd986fd67956560fa7317bd7a5cc21f8f2eb4 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Sat, 27 Jul 2019 02:44:57 +0200
Subject: [PATCH] xbps-src: add XBPS_LIBC/XBPS_TARGET_LIBC

This can be used in template checks to remove the clunky case
statements and pattern matching, as well as simplify normal ifs.

For example:

if [ "${XBPS_TARGET_MACHINE%-musl}" = "${XBPS_TARGET_MACHINE}" ]; then
    ... glibc specific ...
fi

becomes:

if [ "${XBPS_TARGET_LIBC}" = "glibc" ]; then
   ... glibc specific ...
fi
---
 common/xbps-src/shutils/common.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 146d4e0604d..6aa9ad14d7e 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -312,6 +312,18 @@ setup_pkg() {
         XBPS_CHECKVERS_XCMD="$XBPS_CHECKVERS_CMD"
     fi
 
+    if [ "${XBPS_MACHINE%-*}" = "${XBPS_MACHINE}" ]; then
+        export XBPS_LIBC="glibc"
+    else
+        export XBPS_LIBC="${XBPS_MACHINE#*-}"
+    fi
+
+    if [ "${XBPS_TARGET_MACHINE%-*}" = "${XBPS_TARGET_MACHINE}" ]; then
+        export XBPS_TARGET_LIBC="glibc"
+    else
+        export XBPS_TARGET_LIBC="${XBPS_TARGET_MACHINE#*-}"
+    fi
+
     export XBPS_INSTALL_XCMD XBPS_QUERY_XCMD XBPS_RECONFIGURE_XCMD \
         XBPS_REMOVE_XCMD XBPS_RINDEX_XCMD XBPS_UHELPER_XCMD
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-30 15:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-27  0:51 [PR PATCH] xbps-src: add XBPS_LIBC/XBPS_TARGET_LIBC voidlinux-github
2019-07-30 15:34 ` voidlinux-github
2019-07-30 15:38 ` voidlinux-github
2019-07-30 15:38 ` voidlinux-github
2019-07-30 15:39 ` voidlinux-github

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).