pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/mk



Module Name:    pkgsrc
Committed By:   pho
Date:           Sun Apr 28 10:58:06 UTC 2024

Modified Files:
        pkgsrc/mk: haskell.mk
Added Files:
        pkgsrc/mk/haskell: check-hackage.sh developer.mk

Log Message:
mk/haskell.mk: New target check-hackage to check for updates


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 pkgsrc/mk/haskell.mk
cvs rdiff -u -r0 -r1.1 pkgsrc/mk/haskell/check-hackage.sh \
    pkgsrc/mk/haskell/developer.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/mk/haskell.mk
diff -u pkgsrc/mk/haskell.mk:1.60 pkgsrc/mk/haskell.mk:1.61
--- pkgsrc/mk/haskell.mk:1.60   Sun Apr 28 08:55:37 2024
+++ pkgsrc/mk/haskell.mk        Sun Apr 28 10:58:06 2024
@@ -1,4 +1,4 @@
-# $NetBSD: haskell.mk,v 1.60 2024/04/28 08:55:37 pho Exp $
+# $NetBSD: haskell.mk,v 1.61 2024/04/28 10:58:06 pho Exp $
 #
 # This Makefile fragment handles Haskell Cabal packages. Package
 # configuration, building, installation, registration and unregistration
@@ -151,7 +151,7 @@ HASKELL_ENABLE_HADDOCK_DOCUMENTATION?=      y
 HASKELL_ENABLE_TESTS?=                 no
 HASKELL_UNRESTRICT_DEPENDENCIES?=      # empty
 
-.include "../../lang/ghc96/buildlink3.mk"
+.include "../../lang/ghc98/buildlink3.mk"
 
 # Some Cabal packages requires preprocessors to build, and we don't
 # want them to implicitly depend on such tools. Place dummy scripts by
@@ -160,6 +160,9 @@ HASKELL_UNRESTRICT_DEPENDENCIES?=   # empt
 .include "../../mk/haskell/tools/cpphs.mk"
 .include "../../mk/haskell/tools/happy.mk"
 
+# Define some useful targets for pkgsrc developers.
+.include "../../mk/haskell/developer.mk"
+
 # Tools
 _HASKELL_BIN=          ${BUILDLINK_PREFIX.ghc:U${LOCALBASE}}/bin/ghc
 _HASKELL_PKG_BIN=      ${BUILDLINK_PREFIX.ghc:U${LOCALBASE}}/bin/ghc-pkg

Added files:

Index: pkgsrc/mk/haskell/check-hackage.sh
diff -u /dev/null pkgsrc/mk/haskell/check-hackage.sh:1.1
--- /dev/null   Sun Apr 28 10:58:06 2024
+++ pkgsrc/mk/haskell/check-hackage.sh  Sun Apr 28 10:58:06 2024
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# $NetBSD: check-hackage.sh,v 1.1 2024/04/28 10:58:06 pho Exp $
+#
+: ${CURL:=curl}
+: ${JQ:=jq}
+: ${HACKAGE_URL:=https://hackage.haskell.org}
+
+# Abort if tools are missing.
+if ! type "${CURL}" >/dev/null 2>&1; then
+    echo >&2 "$0: ${CURL} is missing. Please install \`www/curl' first."
+    exit 1
+fi
+if ! type "${JQ}" >/dev/null 2>&1; then
+    echo >&2 "$0: ${JQ} is missing. Please install \`devel/jq' first."
+    exit 1
+fi
+
+# Abort if arguments are missing.
+if [ $# -lt 1 ]; then
+    echo >&2 "Usage: $0 {DISTNAME}"
+    exit 1
+fi
+readonly DISTNAME="$1"
+readonly pkgname="${DISTNAME%%-[0-9]*}"
+readonly pkgversion="${DISTNAME#${pkgname}-}"
+
+#
+# Example contents of ${pkgname}.json:
+# {
+#     "0.0.0.1": "normal",
+#     "0.0.0.2": "deprecated",
+#     "0.0.0.3": "normal",
+#     "0.0.0.4": "normal"
+# }
+#
+# So we drop deprecated versions and pick the greatest one.
+#
+pkg_info_json="$(${CURL} --silent --show-error --fail "${HACKAGE_URL}/package/${pkgname}.json")"
+if [ $? -ne 0 ]; then
+    echo >&2 "$0: Failed to retrieve package info for ${pkgname}."
+    exit 1
+fi
+
+readonly latest=$(
+    echo "$pkg_info_json" |
+        ${JQ} --raw-output '
+            def split_pvp:
+                split(".") | map(tonumber);
+            map_values(if . == "normal" then . else empty end) |
+            keys |
+            sort_by(split_pvp) |
+            last
+            ')
+
+if [ "$latest" = "$pkgversion" ]; then
+    echo "${DISTNAME} is up to date."
+else
+    echo "A new version ${pkgname}-${latest} is available."
+    echo "Consider updating the package:"
+    echo "    ${HACKAGE_URL}/package/${pkgname}-${latest}"
+fi
Index: pkgsrc/mk/haskell/developer.mk
diff -u /dev/null pkgsrc/mk/haskell/developer.mk:1.1
--- /dev/null   Sun Apr 28 10:58:06 2024
+++ pkgsrc/mk/haskell/developer.mk      Sun Apr 28 10:58:06 2024
@@ -0,0 +1,11 @@
+# $NetBSD: developer.mk,v 1.1 2024/04/28 10:58:06 pho Exp $
+#
+# Targets for pkgsrc developers for updating Haskell packages.
+#
+# check-hackage:
+#      Check for the Hackage repository to see if there is an update to
+#      the ${PKGPATH}.
+
+.PHONY: check-hackage
+check-hackage:
+       ${RUN} ${SH} ../../mk/haskell/check-hackage.sh "${DISTNAME}"



Home | Main Index | Thread Index | Old Index