tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
+BUILD_VERSION in the post-CVS world
Hello all,
the attached patches adds a new "digest" subcommand to pkg_admin and use
it to build +BUILD_VERSION. This replaces the existing logic based on
the $NetBSD$ RCS IDs with a VCS independent mechanism. It has the
advantage that it also detects unversioned changes with the downside of
making it more difficult to figure out which revision a file was build
from. A corresponding change for pbulk would follow.
This functionality can't use digest(1) as it would introduce cyclic
dependencies.
Comments?
Joerg
Index: main.c
===================================================================
RCS file: /home/joerg/repo/netbsd/pkgsrc/pkgtools/pkg_install/files/admin/main.c,v
retrieving revision 1.66
diff -u -p -r1.66 main.c
--- main.c 26 Feb 2018 23:45:02 -0000 1.66
+++ main.c 8 Oct 2019 22:07:10 -0000
@@ -10,7 +10,7 @@
__RCSID("$NetBSD: main.c,v 1.66 2018/02/26 23:45:02 ginsbach Exp $");
/*-
- * Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
+ * Copyright (c) 1999-2019 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -59,8 +59,10 @@ __RCSID("$NetBSD: main.c,v 1.66 2018/02/
#endif
#ifndef NETBSD
#include <nbcompat/md5.h>
+#include <nbcompat/sha2.h>
#else
#include <md5.h>
+#include <sha2.h>
#endif
#if HAVE_LIMITS_H
#include <limits.h>
@@ -93,6 +95,7 @@ static const char Options[] = "C:K:SVbd:
int quiet, verbose;
static void set_unset_variable(char **, Boolean);
+static void digest_input(char **);
/* print usage message and exit */
void
@@ -521,6 +524,9 @@ main(int argc, char *argv[])
} else if (strcasecmp(argv[0], "unset") == 0) {
argv++; /* "unset" */
set_unset_variable(argv, TRUE);
+ } else if (strcasecmp(argv[0], "digest") == 0) {
+ argv++; /* "digest" */
+ digest_input(argv);
} else if (strcasecmp(argv[0], "config-var") == 0) {
argv++;
if (argv == NULL || argv[1] != NULL)
@@ -736,3 +742,22 @@ set_unset_variable(char **argv, Boolean
return;
}
+
+static void
+digest_input(char **argv)
+{
+ char digest[SHA256_DIGEST_STRING_LENGTH];
+ int failures = 0;
+
+ while (*argv != NULL) {
+ if (SHA256_File(*argv, digest)) {
+ puts(digest);
+ } else {
+ warn("cannot process %s", *argv);
+ ++failures;
+ }
+ argv++;
+ }
+ if (failures)
+ exit(EXIT_FAILURE);
+}
Index: pkg_admin.1
===================================================================
RCS file: /home/joerg/repo/netbsd/pkgsrc/pkgtools/pkg_install/files/admin/pkg_admin.1,v
retrieving revision 1.37
diff -u -p -r1.37 pkg_admin.1
--- pkg_admin.1 8 Oct 2019 21:33:35 -0000 1.37
+++ pkg_admin.1 8 Oct 2019 21:57:39 -0000
@@ -1,10 +1,11 @@
-.\" $NetBSD: pkg_admin.1,v 1.37 2019/10/08 21:33:35 joerg Exp $
+.\" $NetBSD: pkg_admin.1,v 1.36 2018/08/22 20:48:38 maya Exp $
.\"
-.\" Copyright (c) 1999-2010 The NetBSD Foundation, Inc.
+.\" Copyright (c) 1999-2019 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
-.\" by Hubert Feyrer <hubert%feyrer.de@localhost>.
+.\" by Hubert Feyrer <hubert%feyrer.de@localhost> and
+.\" by Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -27,7 +28,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd February 25, 2018
+.Dd October 8, 2019
.Dt PKG_ADMIN 1
.Os
.Sh NAME
@@ -182,6 +183,9 @@ otherwise it exits with error.
Print the current value of
.Ar variable
as used after parsing the configuration file.
+.It Cm digest Ar file ...
+Compute a SHA256 message digest of
+.Ar file .
.It Cm dump
Dump the contents of the package database, similar to
.Cm pkg_info -F .
Index: pkg_admin.cat
===================================================================
RCS file: /home/joerg/repo/netbsd/pkgsrc/pkgtools/pkg_install/files/admin/pkg_admin.cat,v
retrieving revision 1.6
diff -u -p -r1.6 pkg_admin.cat
--- pkg_admin.cat 8 Oct 2019 21:33:35 -0000 1.6
+++ pkg_admin.cat 8 Oct 2019 21:58:21 -0000
@@ -105,6 +105,9 @@ OOPPTTIIOONNSS
Print the current value of _v_a_r_i_a_b_l_e as used after parsing the
configuration file.
+ ddiiggeesstt _f_i_l_e _._._.
+ Compute a SHA256 message digest of _f_i_l_e.
+
dduummpp Dump the contents of the package database, similar to ppkkgg__iinnffoo
--FF. Columns are printed for the key field used in the pkgdb -
the filename -, and the data field - the package the file belongs
@@ -206,4 +209,4 @@ HHIISSTTOORRYY
AAUUTTHHOORRSS
The ppkkgg__aaddmmiinn command was written by Hubert Feyrer.
-pkgsrc February 25, 2018 pkgsrc
+pkgsrc October 8, 2019 pkgsrc
diff -r 61cf524aa5e9 mk/pkgformat/pkg/metadata.mk
--- a/mk/pkgformat/pkg/metadata.mk Thu May 16 14:09:58 2019 +0200
+++ b/mk/pkgformat/pkg/metadata.mk Wed Oct 09 00:32:36 2019 +0200
@@ -159,12 +159,10 @@
${RUN} \
${CAT} ${.TARGET}.tmp | \
while read file; do \
- ${GREP} '\$$NetBSD' $$file 2>/dev/null | \
- ${SED} -e "s|^|$$file:|"; \
+ ${PKG_ADMIN} digest $$file 2>/dev/null | \
+ ${SED} -e "s|^|$$file: |"; \
done | \
${AWK} '{ sub("^${PKGSRCDIR}/", ""); \
- sub(":.*[$$]NetBSD", ": $$NetBSD"); \
- sub("[$$][^$$]*$$", "$$"); \
print; }' | \
${SORT} -u > ${.TARGET} && ${RM} -f ${.TARGET}.tmp
Home |
Main Index |
Thread Index |
Old Index