xref: /illumos-gate/usr/src/pkg/scripts/pkglist.awk (revision eb9a1df2aeb866bf1de4494433b6d7e5fa07b3ae)
1# This file and its contents are supplied under the terms of the
2# Common Development and Distribution License ("CDDL"), version 1.0.
3# You may only use this file in accordance with the terms of version
4# 1.0 of the CDDL.
5#
6# A full copy of the text of the CDDL should have accompanied this
7# source. A copy of the CDDL is also available via the Internet at
8# http://www.illumos.org/license/CDDL.
9
10# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
11# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
12
13#
14# We do the work in the BEGIN action instead of using pattern matching because
15# we expect the fmri to be at or near the first line of each input file, and
16# this way lets us avoid reading the rest of the file after we find what we
17# need.
18#
19# We keep track of a failure to locate an fmri, so we can exit with an error
20# code which will cause the make run to fail, but we still attempt to process
21# each package on the command line, in hope of maybe giving some additional
22# useful info.
23#
24
25BEGIN {
26	if (ARGC < 2) {
27		exit
28	}
29	retcode = 0
30	for (i = 1; i < ARGC; i++) {
31		do {
32			e = getline f < ARGV[i]
33		} while ((e == 1) && (f !~ /name=pkg.fmri/))
34		if (e == 1) {
35			l = split(f, a, "=")
36			fmri = a[l]
37			facet = 0
38			do {
39				e = getline f < ARGV[i]
40				if (e == 1 &&
41				    f ~ /org.opensolaris.incorp-facet.*=true/)
42					facet = 1
43			} while ((e == 1) && (f ~ /^set name=/))
44			close(ARGV[i])
45			printf("depend fmri=%s type=$(PKGDEP_TYPE)", fmri)
46			if (facet)
47				printf(" vlfacet=true")
48			print ""
49		} else {
50			print "no fmri in " ARGV[i] >> "/dev/stderr"
51			retcode = 2
52		}
53	}
54	exit retcode
55}
56