Github messages for voidlinux
 help / color / mirror / Atom feed
From: voidlinux-github@inbox.vuxu.org
To: ml@inbox.vuxu.org
Subject: [PR PATCH] xbps-src: add XBPS_LIBC/XBPS_TARGET_LIBC
Date: Sat, 27 Jul 2019 02:51:47 +0200	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-13356@inbox.vuxu.org> (raw)

[-- 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
 

             reply	other threads:[~2019-07-27  0:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-27  0:51 voidlinux-github [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-13356@inbox.vuxu.org \
    --to=voidlinux-github@inbox.vuxu.org \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).