4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
37 #include <sys/types.h>
49 #define ERR_ROOT_SET "Could not set install root from the environment."
50 #define ERR_ROOT_CMD "Command line install root contends with environment."
51 #define ERR_MESG "unable to locate parameter information for \"%s\""
52 #define ERR_FLT "parsing error in parameter file"
53 #define ERR_USAGE "usage:\n" \
54 "\t%s [-v] [-d device] pkginst [param [param ...]]\n" \
55 "\t%s [-v] -f file [param [param ...]]\n"
60 static char *device
= NULL
;
61 static int errflg
= 0;
64 static void print_entry(char *, char *);
69 char *prog
= get_prog_name();
71 (void) fprintf(stderr
, gettext(ERR_USAGE
), prog
, prog
);
76 main(int argc
, char *argv
[])
78 char *value
, *pkginst
;
79 char *param
, parambuf
[128];
84 /* initialize locale mechanism */
86 (void) setlocale(LC_ALL
, "");
88 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
89 #define TEXT_DOMAIN "SYS_TEST"
91 (void) textdomain(TEXT_DOMAIN
);
93 /* determine program name */
95 (void) set_prog_name(argv
[0]);
97 /* establish installation root directory */
99 if (!set_inst_root(getenv("PKG_INSTALL_ROOT"))) {
100 progerr(gettext(ERR_ROOT_SET
));
104 while ((c
= getopt(argc
, argv
, "R:vd:f:?")) != EOF
) {
111 /* -f could specify filename to get parameters from */
116 /* -d could specify stream or mountable device */
117 device
= flex_device(optarg
, 1);
121 if (!set_inst_root(optarg
)) {
122 progerr(gettext(ERR_ROOT_CMD
));
133 set_PKGpaths(get_inst_root());
140 if ((optind
+1) > argc
)
144 return (1); /* couldn't obtain info about device */
145 pkginst
= argv
[optind
++];
148 /* If a filename was specified or install db does not exist */
150 param
= argv
[optind
];
155 value
= pkgparam(pkginst
, param
);
157 if (errno
== EFAULT
) {
158 progerr(gettext(ERR_FLT
));
161 } else if (errno
!= EINVAL
) {
163 * some other error besides no value for this
164 * particular parameter
166 progerr(gettext(ERR_MESG
), pkginst
);
175 print_entry(param
, value
);
177 } while (!argv
[optind
] || (++optind
< argc
));
178 (void) pkgparam(NULL
, NULL
); /* close open FDs so umount won't fail */
180 (void) pkghead(NULL
);
181 return (errflg
? 1 : 0);
185 print_entry(char *param
, char *value
)
188 (void) printf("%s='", param
);
190 if (*value
== '\'') {
191 (void) printf("'\"'\"'");
194 (void) putchar(*value
++);
196 (void) printf("'\n");
198 (void) printf("%s\n", value
);