update Tue May 18 00:37:00 PDT 2010
[pkgsrc.git] / mk / bulk / sort-packages
1 #! /bin/sh
2 # $NetBSD: sort-packages,v 1.15 2010/04/10 21:44:44 wiz Exp $
3
4 # This program scans all binary packages in the current directory and
5 # creates two lists of files in OUTDIR:
6 #
7 # restricted_packages
8 #       contains all packages that must not be published on the FTP
9 #       server, for whatever reason
10 #
11 # regular_packages
12 #       contains all the other ("good") packages.
13 #
14
15 set -eu
16
17 : ${OUTDIR="/tmp"}
18 : ${PKG_SUFX=".tgz"}
19 : ${PKG_ADMIN="pkg_admin"}
20 : ${PKG_INFO="pkg_info"}
21
22 regular_packages="${OUTDIR}/regular_packages"
23 restricted_packages="${OUTDIR}/restricted_packages"
24 newline="
25 "
26
27 : > "${regular_packages}"
28 : > "${restricted_packages}"
29
30 for pkg in *${PKG_SUFX}; do
31         build_info=`${PKG_INFO} -B "${pkg}"`
32
33         # Note: this code needs to be that complicated because licensing
34         # issues are critical to pkgsrc, and we really don't want
35         # anything unexpected to happen here. The worst case would be
36         # that some file is sorted wrongly because some change in the
37         # output of pkg_info which had not been foreseen. Therefore it
38         # is better to check as strictly as possible to make those
39         # changes immediately visible.
40
41         no_bin_on_ftp="unknown"
42         case "${newline}${build_info}${newline}" in
43         *"${newline}NO_BIN_ON_FTP=${newline}"*)
44                 no_bin_on_ftp="no"
45                 ;;
46         *"${newline}NO_BIN_ON_FTP="*)
47                 no_bin_on_ftp="yes"
48                 ;;
49         esac
50
51         restricted="unknown"
52         case "${newline}${build_info}${newline}" in
53         *"${newline}RESTRICTED=${newline}"*)
54                 restricted="no"
55                 ;;
56         *"${newline}RESTRICTED="*)
57                 restricted="yes"
58                 ;;
59         esac
60
61         if [ "${restricted}" != "unknown" ] && [ "${no_bin_on_ftp}" != "unknown" ]; then
62                 category="restricted"
63         else
64                 category="unknown"
65         fi
66
67         : echo "upload> ${pkg} is ${category}."
68
69         case "${category}" in
70         "regular")
71                 echo "${pkg}" >> "${regular_packages}"
72                 ;;
73         "restricted")
74                 echo "${pkg}" >> "${restricted_packages}"
75                 ;;
76         *)
77                 echo "sort-packages> WARNING: Could not sort ${pkg} into a category." 1>&2
78                 ;;
79         esac
80 done