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: Mon May 6 09:33:22 UTC 2024
Modified Files:
pkgsrc/mk: haskell.mk
Added Files:
pkgsrc/mk/haskell: install.sh
Log Message:
mk/haskell.mk: Rework the installation script
It turned out the old script didn't work for packages containing 10 or more internal libraries. It affected devel/haskell-language-server.
To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 pkgsrc/mk/haskell.mk
cvs rdiff -u -r0 -r1.1 pkgsrc/mk/haskell/install.sh
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.68 pkgsrc/mk/haskell.mk:1.69
--- pkgsrc/mk/haskell.mk:1.68 Sat May 4 11:21:26 2024
+++ pkgsrc/mk/haskell.mk Mon May 6 09:33:22 2024
@@ -1,4 +1,4 @@
-# $NetBSD: haskell.mk,v 1.68 2024/05/04 11:21:26 pho Exp $
+# $NetBSD: haskell.mk,v 1.69 2024/05/06 09:33:22 pho Exp $
#
# This Makefile fragment handles Haskell Cabal packages. Package
# configuration, building, installation, registration and unregistration
@@ -487,57 +487,15 @@ _HASKELL_PKG_DESCR_DIR= ${PREFIX}/lib/$
_HASKELL_PKG_DESCR_FILE_OR_DIR= ${_HASKELL_PKG_DESCR_DIR}/package-description
_HASKELL_PKG_ID_FILE= ${_HASKELL_PKG_DESCR_DIR}/package-id
-# Packages may contain internal libraries. If this is the case, "./Setup
-# register --gen-pkg-config" creates a directory containing files named
-# {index}-{pkg-id} for each library. Otherwise it creates a single regular
-# file. "./Setup register --print-ipid" becomes useless in this case, as it
-# only prints the ID of the main library. devel/hs-attoparsec is an example
-# of such packages.
INSTALLATION_DIRS+= ${_HASKELL_PKG_DESCR_DIR}
do-install:
- ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC} && \
- ./Setup register ${PKG_VERBOSE:D-v} \
- --gen-pkg-config=dist/package-description \
- --print-ipid \
- > dist/package-id && \
- ./Setup copy ${PKG_VERBOSE:D-v} --destdir=${DESTDIR:Q} && \
- if [ -d dist/package-description ]; then \
- ${INSTALL_DATA_DIR} ${DESTDIR:Q}${_HASKELL_PKG_DESCR_FILE_OR_DIR:Q}; \
- ${CAT} /dev/null > dist/package-id; \
- i=1; \
- while ${TRUE}; do \
- found=no; \
- for f in dist/package-description/$${i}-*; do \
- if [ ! -f "$$f" ]; then \
- break; \
- fi; \
- ${INSTALL_DATA} "$$f" \
- "${DESTDIR}${_HASKELL_PKG_DESCR_FILE_OR_DIR}/$${i}"; \
- ${ECHO} "$$f" | \
- ${SED} -e "s|dist/package-description/$${i}-||" \
- >> dist/package-id; \
- found=yes; \
- break; \
- done; \
- if [ "$$found" = "yes" ]; then \
- i=`${EXPR} $$i + 1`; \
- else \
- break; \
- fi; \
- done; \
- ${INSTALL_DATA} dist/package-id \
- ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q}; \
- elif [ -f dist/package-description ]; then \
- ${INSTALL_DATA} dist/package-description \
- ${DESTDIR:Q}${_HASKELL_PKG_DESCR_FILE_OR_DIR:Q}; \
- ${INSTALL_DATA} dist/package-id \
- ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q}; \
- fi
-# Executable-only packages tend to create an empty directory tree in
-# lib/ which results in useless @pkgdir in PLIST.
- ${RUN}${FIND} ${DESTDIR:Q}${PREFIX}/lib -type d | \
- ${TAIL} -n 1 | \
- ${XARGS} ${RMDIR} -p 2>/dev/null || ${TRUE}
+ ${RUN} ${SH} ../../mk/haskell/install.sh \
+ -s "${WRKSRC}" \
+ -d "${DESTDIR}" \
+ -D "${_HASKELL_PKG_DESCR_FILE_OR_DIR}" \
+ -i "${_HASKELL_PKG_ID_FILE}" \
+ -p "${PREFIX}" \
+ ${PKG_VERBOSE:D-v}
# Substitutions for INSTALL and DEINSTALL.
FILES_SUBST+= HASKELL_GLOBAL_PKG_DB=${_HASKELL_GLOBAL_PKG_DB:Q}
Added files:
Index: pkgsrc/mk/haskell/install.sh
diff -u /dev/null pkgsrc/mk/haskell/install.sh:1.1
--- /dev/null Mon May 6 09:33:22 2024
+++ pkgsrc/mk/haskell/install.sh Mon May 6 09:33:22 2024
@@ -0,0 +1,99 @@
+# $NetBSD: install.sh,v 1.1 2024/05/06 09:33:22 pho Exp $
+#
+# Install a Cabal package.
+#
+set -eu
+
+: ${CAT:=cat}
+: ${ECHO:=echo}
+: ${EXPR:=expr}
+: ${FIND:=find}
+: ${INSTALL_DATA:=install -m 644}
+: ${INSTALL_DATA_DIR:=install -d -m 755}
+: ${RMDIR:=rmdir}
+: ${SORT:=sort}
+: ${TAIL:=tail}
+: ${TEST:=test}
+: ${TRUE:=true}
+: ${XARGS:=xargs}
+
+usage() {
+ ${ECHO} >&2 "Usage: $0 -s SRCDIR -d DESTDIR -D PKG_DESCR_FILE_OR_DIR -i PKG_ID_FILE -p PREFIX [-v]"
+}
+
+srcdir=
+destdir=
+pkg_descr_file_or_dir=
+pkg_id_file=
+prefix=
+verbose=
+while getopts s:d:D:i:p:v opt; do
+ case $opt in
+ s)
+ srcdir="${OPTARG}";;
+ d)
+ destdir="${OPTARG}";;
+ D)
+ pkg_descr_file_or_dir="${OPTARG}";;
+ i)
+ pkg_id_file="${OPTARG}";;
+ p)
+ prefix="${OPTARG}";;
+ v)
+ verbose=1;;
+ \?)
+ usage
+ exit 1
+ esac
+done
+if ${TEST} -z "$srcdir" -o -z "$destdir" -o \
+ -z "$pkg_descr_file_or_dir" -o -z "$pkg_id_file" -o \
+ -z "$prefix"; then
+ usage
+ exit 1
+fi
+
+cd "$srcdir"
+
+# Never use -v even if verbose output is requested. It writes garbage to
+# stdout and messes up the ID file.
+./Setup register \
+ --gen-pkg-config=dist/package-description \
+ --print-ipid \
+ > dist/package-id
+
+./Setup copy ${verbose:+-v} --destdir="$destdir"
+
+# Packages may contain internal libraries. If that's the case "./Setup
+# register --gen-pkg-config" creates a directory containing files named
+# {index}-{pkg-id} for each library. Otherwise it creates a single regular
+# file. "./Setup register --print-ipid" becomes useless in this case, as it
+# only prints the ID of the main library. devel/hs-attoparsec is an example
+# of such packages.
+if ${TEST} -d dist/package-description; then
+ ${INSTALL_DATA_DIR} "${destdir}${pkg_descr_file_or_dir}"
+ ${CAT} /dev/null > dist/package-id
+ ${FIND} dist/package-description -type f | ${SORT} |
+ while read fpath; do
+ # But the thing is, when the package has 10 components or more,
+ # "./Setup register" pads the component index with zero! It's
+ # nice for human beings but isn't nice for POSIX sh...
+ fname="${fpath##*/}" # "01-foo-bar-1.2.3.4-xxxxxxxx"
+ padded_idx="${fname%%-*}" # "01"
+ pkg_id="${fname#*-}" # "foo-bar-1.2.3.4-xxxxxxxx"
+ idx="$(${EXPR} "$padded_idx" + 0)" # "1"
+ ${INSTALL_DATA} "$fpath" "${destdir}${pkg_descr_file_or_dir}/${idx}"
+ ${ECHO} "$pkg_id" >> dist/package-id
+ done
+ ${INSTALL_DATA} dist/package-id "${destdir}${pkg_id_file}"
+
+elif ${TEST} -f dist/package-description; then
+ ${INSTALL_DATA} dist/package-description "${destdir}${pkg_descr_file_or_dir}"
+ ${INSTALL_DATA} dist/package-id "${destdir}${pkg_id_file}"
+fi
+
+# Executable-only packages tend to create an empty directory tree in lib/
+# which results in useless @pkgdir in PLIST.
+${FIND} "${destdir}${prefix}/lib" -type d |
+ ${TAIL} -n 1 |
+ ${XARGS} ${RMDIR} -p 2>/dev/null || ${TRUE}
Home |
Main Index |
Thread Index |
Old Index