aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTing-Wei Lan <lantw44@gmail.com>2017-12-30 22:43:08 +0800
committerTing-Wei Lan <lantw44@gmail.com>2018-01-02 14:06:14 +0800
commitd06ffc910ee48b4804fb3dd77ccbec0f6f6fe47d (patch)
tree626bd42d07e81aff82b926a117da2dd083f7135b
parentdf8d825b7949225ec9507d912ccdc144dfb5c166 (diff)
downloadwspkg-d06ffc910ee48b4804fb3dd77ccbec0f6f6fe47d.tar
wspkg-d06ffc910ee48b4804fb3dd77ccbec0f6f6fe47d.tar.gz
wspkg-d06ffc910ee48b4804fb3dd77ccbec0f6f6fe47d.tar.bz2
wspkg-d06ffc910ee48b4804fb3dd77ccbec0f6f6fe47d.tar.lz
wspkg-d06ffc910ee48b4804fb3dd77ccbec0f6f6fe47d.tar.xz
wspkg-d06ffc910ee48b4804fb3dd77ccbec0f6f6fe47d.tar.zst
wspkg-d06ffc910ee48b4804fb3dd77ccbec0f6f6fe47d.zip
freebsd: Support flavors
Flavors is a new feature of FreeBSD ports, allowing creating different packages from the same port by specifying different flavor values. Python ports have been converted to use flavors, enabling us to have both Python 2 and 3 packages installed on the workstation. This change also means that the path of a port is no longer a unique identifier. To specify a dependency in a port, we need both the path and the flavor. The output file FREEBSD_OUT_PORTS, or freebsd.port, now have the third column to store the flavor specified in the input file with '@' symbol, which is the same as the symbol used in a port Makefile. To simply the processing of the file, ports without flavors have their third column set to '@'. This symbol is not required by the syntax, and it can be changed to any non-alphanumeric symbols other than underscore. Ideally we don't have to specify the flavor in the input file because different flavors of a port produce packages with different names. However, since the index file doesn't have a field for flavor, we have to rely on users to provide them to avoid greatly slowing down the process of generating a meta-port Makefile.
-rwxr-xr-xfreebsd/freebsd.deps.sh5
-rwxr-xr-xfreebsd/freebsd.nopkg-deps.sh6
-rwxr-xr-xfreebsd/freebsd.nopkg-setup.sh8
-rw-r--r--freebsd/freebsd.ports.find.c6
4 files changed, 20 insertions, 5 deletions
diff --git a/freebsd/freebsd.deps.sh b/freebsd/freebsd.deps.sh
index f21f5de..91b1329 100755
--- a/freebsd/freebsd.deps.sh
+++ b/freebsd/freebsd.deps.sh
@@ -5,7 +5,10 @@ ports_file="$1"
exec 4< "${ports_file}"
-while read -r pkg_name pkg_ports 0<&4; do
+while read -r pkg_name pkg_ports pkg_flavor 0<&4; do
+ if [ "${pkg_flavor}" != "@" ]; then
+ pkg_ports="${pkg_ports}@${pkg_flavor}"
+ fi
printf " %s>=a:%s ^%%" "${pkg_name}" "${pkg_ports}"
done
diff --git a/freebsd/freebsd.nopkg-deps.sh b/freebsd/freebsd.nopkg-deps.sh
index 6f3f198..ea70ee2 100755
--- a/freebsd/freebsd.nopkg-deps.sh
+++ b/freebsd/freebsd.nopkg-deps.sh
@@ -4,7 +4,11 @@ ports_file="$1"
: ${ports_file:="freebsd.ports"}
tr '/' '_' < "${ports_file}" | paste "${ports_file}" - | (
- while read -r pkg_name pkg_ports unused pkg_ports_var; do
+ while read -r pkg_name pkg_ports pkg_flavor unused pkg_ports_var unused; do
+ if [ "${pkg_flavor}" != "@" ]; then
+ pkg_ports_var="${pkg_ports_var}_${pkg_flavor}"
+ pkg_ports="${pkg_ports}@${pkg_flavor}"
+ fi
printf ' ${WSPKG_PACKAGE_NAME_%s}>=a:%s ^%%' \
"${pkg_ports_var}" "${pkg_ports}"
done )
diff --git a/freebsd/freebsd.nopkg-setup.sh b/freebsd/freebsd.nopkg-setup.sh
index 1e52ce3..788eeae 100755
--- a/freebsd/freebsd.nopkg-setup.sh
+++ b/freebsd/freebsd.nopkg-setup.sh
@@ -6,8 +6,12 @@ ports_file="$1"
count=`wc -l < "${ports_file}"`
tr '/' '_' < "${ports_file}" | paste "${ports_file}" - | (
index=1
- while read -r pkg_name pkg_ports unused pkg_ports_var; do
- printf 'WSPKG_PACKAGE_NAME_%-25s != printf "\\\\r===> Generating package names (%5d/%5d)" 1>\\&2; $(MAKE) -C ${PORTSDIR}/%-25s -V PKGNAMEPREFIX -V PORTNAME -V PKGNAMESUFFIX \\| tr -d "\\\\n"%%' \
+ while read -r pkg_name pkg_ports pkg_flavor unused pkg_ports_var unused; do
+ if [ "${pkg_flavor}" != "@" ]; then
+ pkg_ports_var="${pkg_ports_var}_${pkg_flavor}"
+ pkg_ports="${pkg_ports} FLAVOR=${pkg_flavor}"
+ fi
+ printf 'WSPKG_PACKAGE_NAME_%-40s != printf "\\\\r===> Generating package names (%5d/%5d)" 1>\\&2; $(MAKE) -C ${PORTSDIR}/%-48s -V PKGNAMEPREFIX -V PORTNAME -V PKGNAMESUFFIX \\| tr -d "\\\\n"%%' \
"${pkg_ports_var}" "${index}" "${count}" "${pkg_ports}"
index=$(( ${index} + 1 ))
done )
diff --git a/freebsd/freebsd.ports.find.c b/freebsd/freebsd.ports.find.c
index 852c2c3..5921811 100644
--- a/freebsd/freebsd.ports.find.c
+++ b/freebsd/freebsd.ports.find.c
@@ -31,6 +31,9 @@ static void write_maps (const char* list_file) {
for (n = 0; getline (&line, &len, fp) >= 0; n++) {
strtok (line, "\n");
+ const char *pkgname = strtok (line, "@");
+ const char *flavor = strtok (NULL, "@");
+
ENTRY hfind = {
.key = line,
.data = NULL
@@ -41,7 +44,8 @@ static void write_maps (const char* list_file) {
exit (4);
}
- printf ("%-32s %s\n", line, hresult->data);
+ printf ("%-32s %-40s %s\n", pkgname, hresult->data,
+ flavor != NULL ? flavor : "@");
}
free (line);