summaryrefslogtreecommitdiff
path: root/mk/bulk/sort-packages
blob: 2312dc5cc02920b57281b359dee4d17a22eae660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /bin/sh
# $NetBSD: sort-packages,v 1.15 2010/04/10 21:44:44 wiz Exp $

# This program scans all binary packages in the current directory and
# creates two lists of files in OUTDIR:
#
# restricted_packages
#	contains all packages that must not be published on the FTP
#	server, for whatever reason
#
# regular_packages
#	contains all the other ("good") packages.
#

set -eu

: ${OUTDIR="/tmp"}
: ${PKG_SUFX=".tgz"}
: ${PKG_ADMIN="pkg_admin"}
: ${PKG_INFO="pkg_info"}

regular_packages="${OUTDIR}/regular_packages"
restricted_packages="${OUTDIR}/restricted_packages"
newline="
"

: > "${regular_packages}"
: > "${restricted_packages}"

for pkg in *${PKG_SUFX}; do
	build_info=`${PKG_INFO} -B "${pkg}"`

	# Note: this code needs to be that complicated because licensing
	# issues are critical to pkgsrc, and we really don't want
	# anything unexpected to happen here. The worst case would be
	# that some file is sorted wrongly because some change in the
	# output of pkg_info which had not been foreseen. Therefore it
	# is better to check as strictly as possible to make those
	# changes immediately visible.

	no_bin_on_ftp="unknown"
	case "${newline}${build_info}${newline}" in
	*"${newline}NO_BIN_ON_FTP=${newline}"*)
		no_bin_on_ftp="no"
		;;
	*"${newline}NO_BIN_ON_FTP="*)
		no_bin_on_ftp="yes"
		;;
	esac

	restricted="unknown"
	case "${newline}${build_info}${newline}" in
	*"${newline}RESTRICTED=${newline}"*)
		restricted="no"
		;;
	*"${newline}RESTRICTED="*)
		restricted="yes"
		;;
	esac

	if [ "${restricted}" != "unknown" ] && [ "${no_bin_on_ftp}" != "unknown" ]; then
		category="restricted"
	else
		category="unknown"
	fi

	: echo "upload> ${pkg} is ${category}."

	case "${category}" in
	"regular")
		echo "${pkg}" >> "${regular_packages}"
		;;
	"restricted")
		echo "${pkg}" >> "${restricted_packages}"
		;;
	*)
		echo "sort-packages> WARNING: Could not sort ${pkg} into a category." 1>&2
		;;
	esac
done