Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Almost working pkg2ng. Ordering problem now...
jlaffaye committed 15 years ago
commit f0d4883bae4a83ef28d20eab277ee83ee820871a
parent 353bab3c169e7856c5f8ee17c98cea3643243405
2 files changed +17 -19
modified libpkg/pkg.c
@@ -539,13 +539,16 @@ pkg_addfile(struct pkg *pkg, const char *path, const char *sha256)
	if (path == NULL || path[0] == '\0')
		return (ERROR_BAD_ARG("path"));

-
	if (sha256 == NULL || strlen(sha256) != 64)
+
	/* sha256 can be NULL, but if it is defined it must be a valid sha256 */
+
	if (sha256 != NULL && strlen(sha256) != 64)
		return (ERROR_BAD_ARG("sha256"));

	pkg_file_new(&file);

	strlcpy(file->path, path, sizeof(file->path));
-
	strlcpy(file->sha256, sha256, sizeof(file->sha256));
+

+
	if (sha256 != NULL)
+
		strlcpy(file->sha256, sha256, sizeof(file->sha256));

	array_init(&pkg->files, 10);
	array_append(&pkg->files, file);
modified ports/pkg2ng
@@ -9,17 +9,15 @@ do
	DB="/var/db/pkg/${PKG}"
	COMMENT=`cat ${DB}/+COMMENT`
	DESC="${DB}/+DESC"
-
	MTREE="${DB}/+MTREE"
-

-
	# Should check for existence and add to CMD only if true...
+
	MTREE="${DB}/+MTREE_DIRS"
	MESSAGE="${DB}/+DISPLAY"

-
	# +CONTENTS \o/
-
	DEPENDSF=`mktemp /tmp/pkg2ng.deps.XXXXXX`
+
	# +CONTENTS
	PLIST=`mktemp /tmp/pkg2ng.plist.XXXXXX`
-
	eval `awk -v dfile=${DEPENDSF} -v pfile=${PLIST} '
+
	eval `awk -v pfile=${PLIST} '
	BEGIN{
		origin=""
+
		depends=""
		conflicts=""
	}
	{
@@ -28,7 +26,7 @@ do
			getline
			orig=$2
			sub(/DEPORIGIN/,"",orig)
-
			print dep""orig >> dfile
+
			depends=depends" "dep""orig
		} else if ( $0 ~ /^@comment ORIGIN/ ) {
			origin=$2
			sub(/ORIGIN:/,"",origin)
@@ -44,6 +42,7 @@ do
	}
	END{
		print "export ORIGIN=\""origin"\""
+
		print "export DEPENDS=\""depends"\""
		print "export CONFLICTS=\""conflict"\""
	}
	' ${DB}/+CONTENTS`
@@ -53,21 +52,17 @@ do

	MAINTAINER=`make -C /usr/ports/${ORIGIN} -V MAINTAINER`

+
	test -n "${DEPENDS}" && CMD_ARGS="${CMD_ARGS} -P ${DEPENDS}"
	test -n "${SCRIPTS}" && CMD_ARGS="${CMD_ARGS} -s ${SCRIPTS}"
	test -n "${OPTIONS}" && CMD_ARGS="${CMD_ARGS} -O ${OPTIONS}"
	test -f "${MESSAGE}" && CMD_ARGS="${CMD_ARGS} -M ${MESSAGE}"
	test -n "${CONFLICTS}" && CMD_ARGS="${CMD_ARGS} -C ${CONFLICTS}"

-
	if [ -s "${DEPENDSF}" ]; then
-
		pkg register -c ${COMMENT} -d ${DESC} -p /usr/local -m ${MTREE} \
-
		-n ${PKG} -o ${ORIGIN} -a ${ARCH} \
-
		-r ${MAINTAINER} -f ${PLIST} ${CMD_ARGS} -P "`cat ${DEPENDSF}`"
-
	else
-
		pkg register -c ${COMMENT} -d ${DESC} -p /usr/local -m ${MTREE} \
-
		-n ${PKG} -o ${ORIGIN} -a ${ARCH} \
-
		-r ${MAINTAINER} -f ${PLIST} ${CMD_ARGS}
-
	fi
+
	pkg register -c "${COMMENT}" -d ${DESC} -p /usr/local -m ${MTREE} \
+
	-n ${PKG} -o ${ORIGIN} -a ${ARCH} \
+
	-r ${MAINTAINER} -f ${PLIST} ${CMD_ARGS}
+

+
	rm ${PLIST}

-
	rm ${DEPENDSF} ${PLIST}
	echo " done"
done