pkgsrc-WIP-changes archive

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

Import pkgsrc-info



Module Name:	pkgsrc-wip
Committed By:	kikadf <kikadf.01%gmail.com@localhost>
Pushed By:	kikadf
Date:		Thu Oct 2 16:04:58 2025 +0200
Changeset:	ced93132d4bdc06815bb0cb2ccdf295400b44700

Modified Files:
	Makefile
Added Files:
	pkgsrc-info/DESCR
	pkgsrc-info/Makefile
	pkgsrc-info/PLIST
	pkgsrc-info/TODO
	pkgsrc-info/files/get_pkgsrc_infos.sh
	pkgsrc-info/files/pkgsrc-info.sh.in
	pkgsrc-info/options.mk

Log Message:
Import pkgsrc-info

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=ced93132d4bdc06815bb0cb2ccdf295400b44700

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

diffstat:
 Makefile                              |   1 +
 pkgsrc-info/DESCR                     |   4 ++
 pkgsrc-info/Makefile                  |  71 +++++++++++++++++++++++
 pkgsrc-info/PLIST                     |   2 +
 pkgsrc-info/TODO                      |  21 +++++++
 pkgsrc-info/files/get_pkgsrc_infos.sh | 106 ++++++++++++++++++++++++++++++++++
 pkgsrc-info/files/pkgsrc-info.sh.in   |  51 ++++++++++++++++
 pkgsrc-info/options.mk                |  16 +++++
 8 files changed, 272 insertions(+)

diffs:
diff --git a/Makefile b/Makefile
index 337bf906f9..6081181567 100644
--- a/Makefile
+++ b/Makefile
@@ -3260,6 +3260,7 @@ SUBDIR+=	pkg_fake
 SUBDIR+=	pkg_rmleaves
 SUBDIR+=	pkg_summary-utils
 SUBDIR+=	pkgmanager
+SUBDIR+=	pkgsrc-info
 SUBDIR+=	plank
 SUBDIR+=	plantri
 SUBDIR+=	plantuml
diff --git a/pkgsrc-info/DESCR b/pkgsrc-info/DESCR
new file mode 100644
index 0000000000..2431ba43c8
--- /dev/null
+++ b/pkgsrc-info/DESCR
@@ -0,0 +1,4 @@
+pkgsrc-info is a small tool to display basic informations
+about the pkgsrc tree where it was built. It prints branch,
+last commit, architecture, operating system, and the
+default versions of main components.
diff --git a/pkgsrc-info/Makefile b/pkgsrc-info/Makefile
new file mode 100644
index 0000000000..3cb3dd36da
--- /dev/null
+++ b/pkgsrc-info/Makefile
@@ -0,0 +1,71 @@
+# $NetBSD$
+
+DISTNAME=	pkgsrc-info-1
+CATEGORIES=	pkgtools
+DISTFILES=	# none
+
+MAINTAINER=	kikadf.01%gmail.com@localhost
+HOMEPAGE=	https://www.NetBSD.org/docs/pkgsrc/
+COMMENT=	Small tool to display basic information about the pkgsrc tree
+LICENSE=	2-clause-bsd
+
+.include "../../mk/bsd.prefs.mk"
+.include "../../mk/krb5.buildlink3.mk"
+.include "../../lang/lua/luaversion.mk"
+.include "../../lang/go/version.mk"
+PYTHON_FOR_BUILD_ONLY=	yes
+.include "../../lang/python/pyversion.mk"
+.include "../../lang/php/phpversion.mk"
+.include "../../lang/ruby/rubyversion.mk"
+
+HOSTNAME=	${UNAME} -n
+BUILD_DEFS+=	JPEG_DEFAULT EMACS_TYPE LIBUSB_TYPE
+
+SUBST_CLASSES+=		files
+SUBST_STAGE.files=	pre-configure
+SUBST_MESSAGE.files=	Set variables in pkgsrc-info
+SUBST_FILES.files+=	pkgsrc-info.sh.in
+SUBST_SED.files+=	-e 's,@HOST@,${OPSYS} ${OS_VERSION} ${MACHINE_ARCH},g'
+SUBST_SED.files+=	-e 's,@HOSTNAME@,${HOSTNAME:sh},g'
+SUBST_SED.files+=	-e 's,@X11@,${X11_TYPE},g'
+SUBST_SED.files+=	-e 's,@JPEG@,${JPEG_DEFAULT},g'
+SUBST_SED.files+=	-e 's,@LUA@,${LUA_VERSION_DEFAULT},g'
+SUBST_SED.files+=	-e 's,@GO@,${GO_VERSION_DEFAULT},g'
+SUBST_SED.files+=	-e 's,@EMACS@,${EMACS_TYPE},g'
+SUBST_SED.files+=	-e 's,@LIBUSB@,${LIBUSB_TYPE},g'
+SUBST_SED.files+=	-e 's,@KRB5@,${KRB5_DEFAULT},g'
+SUBST_SED.files+=	-e 's,@PYTHON@,${PYTHON_VERSION_DEFAULT},g'
+SUBST_SED.files+=	-e 's,@PHP@,${PHP_VERSION_DEFAULT},g'
+SUBST_SED.files+=	-e 's,@RUBY@,${RUBY_VERSION_DEFAULT},g'
+
+.include "options.mk"
+
+.if !empty(PKG_OPTIONS:Mjava)
+SUBST_SED.files+=	-e 's,@JVM@,${_PKG_JVM_DEFAULT},g'
+.else
+SUBST_SED.files+=	-e 's,@JVM@,Not checked,g'
+.endif
+
+.if !empty(PKG_OPTIONS:Mrust)
+SUBST_SED.files+=	-e 's,@RUST@,${RUST_TYPE},g'
+.else
+SUBST_SED.files+=	-e 's,@RUST@,Not checked,g'
+.endif
+
+TOOL_DEPENDS+=	git-base-[0-9]*:../../devel/git-base
+TOOL_DEPENDS+=	${PYPKGPREFIX}-mercurial-[0-9]*:../../devel/py-mercurial
+
+WRKSRC=			${WRKDIR}
+INSTALLATION_DIRS+=	bin
+
+do-extract:
+	${CP} ${FILESDIR}/pkgsrc-info.sh.in ${WRKSRC}
+
+do-build:
+	cd ${FILESDIR} && \
+		${SH} ./get_pkgsrc_infos.sh || ${FALSE}
+
+do-install:
+	${INSTALL_SCRIPT} ${WRKSRC}/pkgsrc-info.sh ${DESTDIR}${PREFIX}/bin/pkgsrc-info
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/pkgsrc-info/PLIST b/pkgsrc-info/PLIST
new file mode 100644
index 0000000000..74ecd684c9
--- /dev/null
+++ b/pkgsrc-info/PLIST
@@ -0,0 +1,2 @@
+@comment $NetBSD$
+bin/pkgsrc-info
diff --git a/pkgsrc-info/TODO b/pkgsrc-info/TODO
new file mode 100644
index 0000000000..a2dbee438d
--- /dev/null
+++ b/pkgsrc-info/TODO
@@ -0,0 +1,21 @@
+$ pkgsrc-info
+PKGSRC: pkgsrc-2025Q2 (NetBSD 10.1 x86_64)
+  from: yamato git 2025-08-29 18:32:05 +0000
+        (f63824d4522661effe8f96ce743c1390163102e0)
+
+DEFAULTS:
+  X11        = native
+  Emacs      = emacs29
+  Jpeg       = libjpeg-turbo
+  JVM        = openjdk17
+  Kerberos   = heimdal
+  Libusb     = compat
+  MySQL      = mariadb114
+  PostgreSQL = 16
+  Go         = 124
+  Lua        = 54
+  PHP        = 82
+  Python     = 312
+  Ruby       = 32
+  Rust       = src
+$
diff --git a/pkgsrc-info/files/get_pkgsrc_infos.sh b/pkgsrc-info/files/get_pkgsrc_infos.sh
new file mode 100644
index 0000000000..69f9442a3f
--- /dev/null
+++ b/pkgsrc-info/files/get_pkgsrc_infos.sh
@@ -0,0 +1,106 @@
+#!/bin/sh
+
+# NOTE: stat not portable
+
+set -e
+export LC_TIME=C
+OS=$(uname -s)
+PKG_ROOT=$(cd .. && pwd)
+PKGSRC_ROOT=$(cd "../../.." && pwd)
+
+if [ ! -f "${PKGSRC_ROOT}/doc/pkgsrc.txt" ]; then
+    echo "PKGSRC_ROOT(=$PKGSRC_ROOT) fail"
+    exit 1
+else
+    cd ${PKGSRC_ROOT}
+fi
+
+if [ -d ".git" ]; then
+    git config --global --add safe.directory "${PKGSRC_ROOT}"
+    VCS="git"
+elif [ -d ".hg" ]; then
+    VCS="mercurial"
+elif [ -d "CVS" ]; then
+    VCS="cvs"
+fi
+
+last_changed() {
+    case "$OS" in
+        NetBSD|FreeBSD|OpenBSD|DragonFly|Darwin)
+            find . \( -type d -name "CVS" \
+                    -o -type d -name "wip" \
+                    -o -type d -name "distfiles" \
+                    -o -type d -name "work" \
+                    -o -type d -name "packages" \) -prune \
+                -o -type f -print0 | xargs -0 stat -f '%m %N' | sort -n | tail -1 | cut -d' ' -f2-
+            ;;
+        Linux|SunOS)
+            find . \( -type d -name "CVS" \
+                    -o -type d -name "wip" \
+                    -o -type d -name "distfiles" \
+                    -o -type d -name "work" \
+                    -o -type d -name "packages" \) -prune \
+                -o -type f -print0 | xargs -0 stat -c '%Y %n' | sort -n | tail -1 | cut -d' ' -f2-
+            ;;
+        *)
+            # fallback
+            ls -tr doc/ | tail -1
+            ;;
+    esac
+}
+
+last_time() {
+    case "$OS" in
+        NetBSD|FreeBSD|OpenBSD|DragonFly|Darwin)
+            date -j -f "%a %b %d %T %Y" \
+                "$(grep $(basename "$1") $(dirname "$1")/CVS/Entries | cut -d/ -f4)" \
+                "+%F %T %z"
+            ;;
+        Linux)
+            date -d "%a %b %d %T %Y" \
+                "$(grep $(basename "$1") $(dirname "$1")/CVS/Entries | cut -d/ -f4)" \
+                "+%F %T %z"
+            ;;
+        *)
+            grep $(basename "$1") $(dirname "$1")/CVS/Entries | cut -d/ -f4
+            ;;
+    esac
+}
+
+case "$VCS" in
+    git)
+        BRANCH=$(git rev-parse --abbrev-ref HEAD)
+        LAST_HASH=$(git log -1 --format=%H)
+        LAST_DATE=$(git log -1 --format=%ci)
+        ;;
+    mercurial)
+        BRANCH=$(hg branch)
+        LAST_HASH=$(hg log -l 1 --template "{node}\n")
+        LAST_DATE=$(hg log -l 1 --template "{date|isodate}\n")
+        ;;
+    cvs)
+        BRANCH=$(cvs status -v "doc/pkgsrc.txt" \
+                | sed -n 's/.*Sticky Tag:\t*\(.*\)/\1/p' \
+                | cut -d' ' -f1)
+        if [ "$BRANCH" = "(none)" ]; then
+            BRANCH="trunk"
+        fi
+        LAST_HASH=$(last_changed)
+        LAST_DATE=$(last_time ${LAST_HASH})
+        ;;
+esac
+
+MYSQL=$(sed -n 's|MYSQL_VERSION_DEFAULT?=.*\t\(.*\)|\1|p' mk/mysql.buildlink3.mk)
+PGSQL=$(sed -n 's|PGSQL_VERSION_DEFAULT?=.*\t\(.*\)|\1|p' mk/pgsql.buildlink3.mk)
+NODE=$(sed -n 's|NODE_VERSION_DEFAULT?=.*\t\(.*\)|\1|p' lang/nodejs/nodeversion.mk)
+
+sed -e "s|@VCS@|$VCS|g" \
+    -e "s|@BRANCH@|$BRANCH|g" \
+    -e "s|@CREF@|$LAST_HASH|g" \
+    -e "s|@CDATE@|$LAST_DATE|g" \
+    -e "s|@MYSQL@|$MYSQL|g" \
+    -e "s|@PGSQL@|$PGSQL|g" \
+    -e "s|@NODE@|$NODE|g" \
+    "${PKG_ROOT}/work/pkgsrc-info.sh.in" > "${PKG_ROOT}/work/pkgsrc-info.sh"
+
+exit 0
diff --git a/pkgsrc-info/files/pkgsrc-info.sh.in b/pkgsrc-info/files/pkgsrc-info.sh.in
new file mode 100644
index 0000000000..4c4ea5e68d
--- /dev/null
+++ b/pkgsrc-info/files/pkgsrc-info.sh.in
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+main() {
+	echo "PKGSRC: @BRANCH@ (@HOST@)"
+	echo "  from: @HOSTNAME@ @VCS@ @CDATE@"
+	echo "        (@CREF@)"
+	echo ""
+	echo "DEFAULTS:"
+	echo "  X11        = @X11@"
+	echo "  Emacs      = @EMACS@"
+	echo "  Jpeg       = @JPEG@"
+	echo "  JVM        = @JVM@"
+	echo "  Kerberos   = @KRB5@"
+	echo "  Libusb     = @LIBUSB@"
+	echo "  MySQL      = @MYSQL@"
+	echo "  PostgreSQL = @PGSQL@"
+	echo "  Go         = @GO@"
+	echo "  Lua        = @LUA@"
+	echo "  PHP        = @PHP@"
+	echo "  Python     = @PYTHON@"
+	echo "  Ruby       = @RUBY@"
+	echo "  Rust       = @RUST@"
+}
+
+info() {
+	echo "pkgsrc-info is a small tool to display basic informations"
+	echo "about the pkgsrc tree where it was built. Without argument"
+	echo "prints all informations, the header is:"
+	echo ""
+	echo "PKGSRC: <pkgsrc branch> (<opsys> <osrelease> <arch>)"
+	echo "  from: <hostname> <pkgsrc distribution method> <date of last change>"
+	echo "        (<git/hg: hash of last change|cvs: last changed file>)"
+	echo ""
+	echo "With argument:"
+	echo " -q	quiet, only prints the branch of pkgsrc"
+	echo " -h	prints this help"
+}
+
+case "$1" in
+	-q)
+		echo "@BRANCH@"
+		;;
+	-h|--help|--info)
+		info
+		;;
+	*)
+		main
+		;;
+esac
+
+exit 0
diff --git a/pkgsrc-info/options.mk b/pkgsrc-info/options.mk
new file mode 100644
index 0000000000..71c1330919
--- /dev/null
+++ b/pkgsrc-info/options.mk
@@ -0,0 +1,16 @@
+# $NetBSD: $
+
+PKG_OPTIONS_VAR=		PKG_OPTIONS.pkgsrc-info
+PKG_SUPPORTED_OPTIONS+=		java rust
+PKG_SUGGESTED_OPTIONS+=		java rust
+
+.include "../../mk/bsd.options.mk"
+
+.if !empty(PKG_OPTIONS:Mjava)
+USE_JAVA=	build
+.include "../../mk/java-vm.mk"
+.endif
+
+.if !empty(PKG_OPTIONS:Mrust)
+.include "../../lang/rust/rust.mk"
+.endif


Home | Main Index | Thread Index | Old Index