2 # Functions for HP-UX package management
4 sub list_package_system_commands
6 return ("swlist", "swinstall");
9 # list_packages([package]*)
10 # Fills the array %packages with all or listed packages
13 local($i, $name, $class, @contents, $products, $title_flag);
15 $products = join(' ', @_);
19 open(SW, "swlist -v -a title -a contents |");
22 # bundles and unbundled products
25 $packages{$i,'name'} = $1;
26 $packages{$i,'class'} = $1;
28 if (/^bundle/ || /^product/) {
31 if (/^title\s+(.*)/ && $title_flag) {
32 $packages{$i,'desc'} = $1;
33 if ($products eq "" || (index $products,$name) ne -1) {
39 if (/^contents\s+(.*)/) {
40 @contents = split(/\./, $1);
41 $packages{$i,'name'} = "$name.$contents[0]";
42 $packages{$i,'class'} = $name;
43 if (($products eq "" ||
44 (index $products,"$contents[0]") ne -1) &&
45 $packages{$i,'name'} ne $packages{$i - 1,'name'} ) {
55 # package_info(package)
56 # Returns an array of package information in the order
57 # name, class, description, arch, version, vendor, installtime
60 local(@name, $level, $name, $class, $desc, $arch, $version, $vendor, $date);
63 @name = split(/\./, $name);
66 open(SW, "swlist -l product -v -a vendor.title -a title -a revision -a architecture -a date $name | ");
70 ($name[1] eq "" && $date eq "" || $name[1] ne "")) {
73 if (/^architecture\s+(.*)/ &&
74 ($name[1] eq "" && $arch eq "" || $name[1] ne "")) {
77 if (/^revision\s+(.*)/ &&
78 ($name[1] eq "" && $version eq "" || $name[1] ne "")) {
81 if (/^vendor\.title\s+(.*)/ &&
82 ($name[1] eq "" && $vendor eq "" || $name[1] ne "")) {
85 if (/^title\s+(.*)/ &&
86 ($name[1] eq "" && $desc eq "" || $name[1] ne "")) {
92 return ($name, $class, $desc, $arch, $version, $vendor, $date);
96 # Check if some file is a package file
100 $out = `swlist -s $_[0] 2>&1`;
101 return $out !~ /ERROR: /;
104 # file_packages(file)
105 # Returns a list of all packages in the given file, in the form
106 # package description
110 open(SW, "swlist -s $_[0] |");
113 if (/^ (\S*)\s+(\S*)/) {
114 push (@list, "$1 $2");
122 # install_options(file, package)
123 # Outputs HTML for choosing install options for some package
126 print &ui_table_row($text{'hpux_create_target_path'},
127 &ui_yesno_radio("create_target_path", 1));
129 print &ui_table_row($text{'hpux_mount_all_filesystems'},
130 &ui_yesno_radio("mount_all_filesystems", 1));
132 print &ui_table_row($text{'hpux_reinstall'},
133 &ui_yesno_radio("reinstall", 0));
135 print &ui_table_row($text{'hpux_reinstall_files'},
136 &ui_yesno_radio("reinstall_files", 1));
138 print &ui_table_row($text{'hpux_reinstall_files_use_cksum'},
139 &ui_yesno_radio("reinstall_files_use_cksum", 1));
141 print &ui_table_row($text{'hpux_allow_multiple_versions'},
142 &ui_yesno_radio("allow_multiple_versions", 0));
144 print &ui_table_row($text{'hpux_defer_configure'},
145 &ui_yesno_radio("defer_configure", 0));
147 print &ui_table_row($text{'hpux_autorecover_product'},
148 &ui_yesno_radio("autorecover_product", 0));
150 print &ui_table_row($text{'hpux_allow_downdate'},
151 &ui_yesno_radio("allow_downdate", 0));
153 print &ui_table_row($text{'hpux_allow_incompatible'},
154 &ui_yesno_radio("allow_incompatible", 0));
156 print &ui_table_row($text{'hpux_autoselect_dependencies'},
157 &ui_yesno_radio("autoselect_dependencies", 1));
159 print &ui_table_row($text{'hpux_enforce_dependencies'},
160 &ui_yesno_radio("enforce_dependencies", 1));
162 print &ui_table_row($text{'hpux_enforce_scripts'},
163 &ui_yesno_radio("enforce_scripts", 1));
165 print &ui_table_row($text{'hpux_enforce_dsa'},
166 &ui_yesno_radio("enforce_dsa", 1));
168 print &ui_table_row($text{'hpux_root'},
169 &ui_textbox("root", "/", 50)." ".
170 &file_chooser_button("root", 1), 3);
173 # install_package(file, package)
174 # Install the given package from the given file, using options from %in
177 local $in = $_[2] ? $_[2] : \%in;
178 foreach $o ('create_target_path',
179 'mount_all_filesystems',
182 'reinstall_files_use_cksum',
183 'allow_multiple_versions',
185 'autorecover_product',
187 'allow_incompatible',
188 'autoselect_dependencies',
189 'enforce_dependencies',
192 if ($in->{$o}) { $opts .= " -x $o=true"; }
193 else { $opts .= " -x $o=false"; }
195 if ($in->{'root'} =~ /^\/.+/) {
196 if (!(-d $in->{'root'})) {
197 return "Root directory '$in->{'root'}' does not exist";
199 $opts .= " -r $in->{'root'}";
201 $out = &backquote_logged("swinstall -s $_[0] $opts $_[1] 2>&1");
202 if ($?) { return "<pre>$out</pre>"; }
206 # check_files(package)
207 # Fills in the %files array with information about the files belonging
211 local($i, $path); $i = -1;
212 open(SW, "swlist -l file -v -a path -a owner -a group -a type -a link_source -a size $_[0] | ");
215 if (/^path\s+(.*)/) {
217 $files{$i,'path'} = $1;
218 $files{$i,'size'} = "-";
219 $files{$i,'user'} = "-";
220 $files{$i,'group'} = "-";
221 $files{$i,'link'} = "";
224 if (/^owner\s+(.*)/ && $path ne "") {
225 $files{$i,'user'} = $1;
227 if (/^group\s+(.*)/ && $path ne "") {
228 $files{$i,'group'} = $1;
230 if (/^type\s+(.*)/ && $path ne "") {
231 $files{$i,'type'} = $1 eq "f" ? 0 :
237 if (/^link_source\s+(.*)/ && $path ne "") {
238 $files{$i,'link'} = $1;
240 if (/^size\s+(.*)/ && $path ne "") {
241 $files{$i,'size'} = $1;
244 $files{$i,'error'} = "\n";
250 # installed_file(file)
251 # Given a filename, fills %file with details of the given file and returns 1.
252 # If the file is not known to the package system, returns 0
255 local($path, $search, @tmp, $product, $product_flag, $path_flag);
258 open(SW, "swlist -l file -v -a path -a owner -a group -a type -a link_source -a mode -a size | ");
264 if (/^# (\S*)/ && $product_flag) {
265 @tmp = split(/\./, $1);
269 if (/^path\s+(.*)/) {
275 $file{'group'} = "-";
276 if ((index $file{'packages'},$product) eq -1) {
277 $file{'packages'} = join(' ', $product, $file{'packages'});
285 if (/^owner\s+(.*)/ && $path_flag) {
288 if (/^group\s+(.*)/ && $path_flag) {
291 if (/^type\s+(.*)/ && $path_flag) {
292 $file{'type'} = $1 eq "f" ? 0 :
298 if (/^link_source\s+(.*)/ && $path_flag) {
301 if (/^mode\s+(.*)/ && $path_flag) {
304 if (/^size\s+(.*)/ && $path_flag) {
307 $file{'error'} = "\n";
311 if ($file{'packages'} ne "") { return 1; }
312 else { undef(%file); return 0; }
315 # delete_package(package)
316 # Attempt to remove some package
319 $out = &backquote_logged("swremove $_[0] 2>&1");
320 if ($out) { return "<pre>$out</pre>"; }
331 return "swinstall swlist swremove";