|
Softpanorama |
||||||
| Contents | Bulletin | Scripting in shell and Perl | Network troubleshooting | History | Humor | |
| News | See also | Recommended books | Recommended Links | Bulk Installation |
| Checking Installed Packages | Package Installation | Uninstalling Packages | Making New Packages | Tips |
| pkgadd man | pkgrm man | pkgchk man | pkginfo man | admintool man |
All the software distributed as part of Solaris by Sun is released in package format. This includes all the standard shells and command sets. Packages clearly emerge as the preferred way of distributing software on Solaris specifically due to the following features:
It is possible to convert RPM to Solaris packages. The most commonly used package management commands are:
Here is a list of typical commands used :
There are also several command that permit creation of your own custom packages or modification of existing packages:
In addition, it is possible to use the admintool as a frontend to these commands. Installing packages using admintool has some advantages. Using admintool, you can:
Determine the current runlevel
Determine whether a package is already installed
Determine whether an existing installation is corrupt or only partially installed
Determine whether a new package installation would overwrite existing files
Perform package installations
Permit the execution of setuid/setgid scripts
Permit the installation setuid/setgid files
Print copyright notices
Verify that any pre-installation tasks have been performed
Verify that enough disk space exists for a package to be installed successfully
Package files are text files, meaning that an editor or similar text display program can view their contents. For example, if we downloaded a package for the Apache web server, we could verify its origin by examining its headers:
$ head apache-1.3.12-sol8-sparc-local # PaCkAgE DaTaStReAm SMCapache 1 5392 # end of header NAME=apache ARCH=sparc VERSION=1.3.12 CATEGORY=application VENDOR=Apache Group EMAIL=steve@smc.vnet.netHere, we can see that steve@smc.vnet.net (Steve Christiansen, the maintainer of the www.sunfreeware.com site), created this Apache 1.3.12 archive for the SPARC platform. Following the header material are the actual archived files themselves, packed serially by the pkgmk command.
The pkginfo command can be used to list all of the packages currently installed on a system:
bash-2.03# pkginfo application GNUbash bash application SMCgcc gcc application SMCmake make application SMCsamba samba system SUNWab2m Solaris Documentation Server Lookup system SUNWadmap System administration applications system SUNWadmc System administration core libraries system SUNWadmfw System & Network Administration Framework system SUNWadmr System & Network Administration Root system SUNWarc Archive Libraries system SUNWarrf X11 Arabic required fonts system SUNWatfsr AutoFS, (Root) system SUNWatfsu AutoFS, (Usr) system SUNWaudio Audio applications system SUNWbcp SunOS 4.x Binary Compatibility system SUNWbtool CCS tools bundled with SunOS system SUNWcar Core Architecture, (Root) system SUNWcg6 GX (cg6) Device Driver system SUNWcg6h GX (cg6) Header Files
This target system has a number of system and application packages already installed, including SUNWadmap (system administration applications) and bash, the Bourne again shell (GNUbash), respectively.
Packages can be added easily by using the pkgadd command. Continuing with the example of the Apache file, we would use the following command to install it on a target system:
# /usr/sbin/pkgadd -d apache-1.3.6-sol7-sparc-local
Once the headers have been processed, the following message is displayed:
The following packages are available: 1 SMCapache apache (sparc) 1.3.12 Select package(s) you wish to process (or 'all' to process all packages). (default: all) [?,??,q]:
Typing Enter or 1 here will install the SMCapache package:
Processing package instance <SMCapache> from </tmp/apache-1.3.12-sol8-sparc-local> apache (sparc) 1.3.12 Apache Group Using </usr/local> as the package base directory. ## Processing package information. ## Processing system information. 1 package pathname is already properly installed. ## Verifying disk space requirements. ## Checking for conflicts with packages already installed. ## Checking for setuid/setgid programs. Installing apache as <SMCapache> ## Installing part 1 of 1. /usr/local/apache/bin/ab /usr/local/apache/bin/apachectl ... /usr/local/doc/apache/README.NT /usr/local/doc/apache/README.configure /usr/local/doc/apache/WARNING-NT.TXT [ verifying class <none> ] Installation of <SMCapache> was successful.
This is the idealized example. Realistically, pkgadd often asks you to
confirm various parameters and/or changes that it needs to install the software
correctly. For example, if a directory already exists, and an attribute change
needs to be made, you would encounter the following:
## Checking for conflicts with packages already installed. The following files are already installed on the system and are being used by another package: * /usr/local/apache <attribute change only> * - conflict with a file which does not belong to any package. Do you want to install these conflicting files [y,n,?,q]
Typing y will make the attribute change as requested, and installation will continue as normal.
After processing package and system information, and checking that the required amount of disk space is available, the pkgadd command copies all files from the archive to the local filesystem.
Packages can be removed from a system at any time with the pkgrm command. Before uninstalling a package, it's wise to ensure that no processes are using any of the files contained in the package, by using the ps and lsof commands. To remove the SMCapache package we installed earlier, use the following command:
bash-2.03# pkgrm SMCapache
The following package is currently installed:
SMCapache apache
(sparc) 1.3.12
Do you want to remove this package? y
## Removing installed package instance <SMCapache>
## Verifying package dependencies.
## Removing pathnames in class <none>
/usr/local/doc/apache/WARNING-NT.TXT
/usr/local/doc/apache/README.configure
/usr/local/doc/apache/README.NT
/usr/local/doc/apache/README
/usr/local/doc/apache/Makefile.tmpl
...
/usr/local/apache/bin/apachectl
/usr/local/apache/bin/ab
/usr/local/apache/bin
/usr/local/apache <non-empty directory not removed>
## Updating system information.
Removal of <SMCapache> was successful.
See also solaris-pkg your own software
Making new packages is not as easy as installing or removing them. You need to create a specification for how an archive is to be built (called a prototype file), by using the pkgproto command, before using the pkgmk command to actually build the package. Reviewing the headers of the Apache package file earlier showed us some of the material that needs to be specified before building a package, such as the vendor's name, as well as the email address of the builder. This material needs to be included in a pkginfo file. Here's a list of the most commonly used parameters that can be specified in the pkginfo file:
The architecture (sparc or intel) for which the package is designed
The target directory into which the files will be unpacked
The archive type (system or application)
The contact details for the package builder
The package name
The name of the package builder
The creator of the software being archived
The release level of the software which is to be packaged
Once the pkginfo and prototype files have been created, it's very easy to build a package using pkgmk. In the following example, we're going to create an archive of the Borland Application Server 4.5 (http://www.borland.com). This step would usually occur in a production environment once all the various XML configuration files have been created and localized, and the service tested. Creating a package at this stage allows a baseline restoration to be made easy if (for example) a hard disk becomes corrupt, or a backup server needs to be bought online to meet with increased demand from users.
The pkginfo file should define all the necessary parameters (such as ARCH, BASEDIR, and CATEGORY), which were outlined previously. For the Borland Application Server, these elements would look like this:
PKG="BAS_LOCAL" NAME="Borland App Server" ARCH="sparc" VERSION="4.5" CATEGORY="application" VENDOR="Borland" EMAIL="support@borland.com" PSTAMP="Paul Watters" BASEDIR="/usr/local/inprise/bas45" CLASSES="none"
We can interpret these entries in the following way:
The package name is BAS_LOCAL (indicating a local installation of the BAS).
The package title is Borland Application Server.
The target architecture is SPARC.
The version number is 4.5.
The category of BAS is an application.
The vendor of BAS is Borland.
The e-mail address of the vendor is support@borland.com.
The name of the package builder is the author of this book.
The base installation directory is /usr/local/inprise/bas45.
Once the pkginfo file is created, we should use the following command to create the prototype file:
bash-2.03# touch prototype
Next, we need to specify the location of the pkginfo file, by inserting
the following line into the prototype file:
i pkginfo=/usr/local/borland/bas45/pkginfo
In the base installation directory specified in the pkginfo file, you can
use the following command to generate a list of relative pathnames and files
that is then piped through the pkgproto command. The output is then
appended to the prototype file:
bash-2.03# find . -print | pkgproto >> prototype
We should then be able to examine the contents of the newly constructed prototype file:
bash-2.03# head /usr/local/borland/bas45/prototype i pkginfo=/usr/local/borland/bas45/pkginfo f none install.idb 0644 bas borland d none bin 0775 bas borland f none bin/JdsExplorer 0775 bas borland f none bin/JdsExplorer.config 0775 bas borland f none bin/JdsServer 0775 bas borland f none bin/JdsServer.config 0775 bas borland f none bin/jdbce 0775 bas borland f none bin/jdbce.config 0775 bas borland f none bin/jsql 0775 bas borland f none bin/jsql.config 0775 bas borland
Every file (f) and directory (d) underneath the root directory is represented by a unique entry in the prototype file. This includes details of the user and group who own the file, as well as the permissions currently set on the file (specified in octal format).
If you wish to change some of the properties specified within the prototype file, you can use vi to search and replace entries before running the pkgmk command. For example, if we want to change the group membership of the files from borland to inprise, we use the following substitution command:
:%s/borland/inprise/g
After the prototype file has been modified to your satisfaction, create the package with the following command:
bash-2.03# pkgmk -o -r /usr/local/borland/bas45 ## Building pkgmap from package prototype file. ## Processing pkginfo file. ## Attempting to volumize 986 entries in pkgmap. part 1 -- 8997 blocks, 986 entries ## Packaging one part. /var/spool/pkg/BAS_LOCAL/install.idb /var/spool/pkg/BAS_LOCAL/bin/JdsExplorer /var/spool/pkg/BAS_LOCAL/bin/JdsExplorer.config /var/spool/pkg/BAS_LOCAL/bin/JdsServer /var/spool/pkg/BAS_LOCAL/bin/JdsServer.config /var/spool/pkg/BAS_LOCAL/bin/jdbce /var/spool/pkg/BAS_LOCAL/bin/jdbce.config /var/spool/pkg/BAS_LOCAL/bin/jsql /var/spool/pkg/BAS_LOCAL/bin/jsql.config ...
The files to be packaged have been transferred to the /var/spool/pkg/BAS_LOCAL
directory at this point. Next, you simply need to use the pkgtrans
command to bundle the files into a single archive file:
bash-2.03# pkgtrans -s /var/spool/pkg /backup/BAS_LOCAL.pkg
The following packages are available:
1 BAS_LOCAL Borland Application Server
(sparc) 4.5
Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:
After typing 1, the package file /backup/BAS_LOCAL.pkg
will be created.
Various Solaris package and patch commands
Hi,
Below is a random list of commands / ways of doing things under Solaris
I've picked up while installing stuff on the Sun box.
o List patches applied:
# patchadd -p
o To apply a patch
Untar the patch tar.Z
# patchadd <dir>
o To add a package
# pkgadd -d <package file>
o To add a package in tar format
# tar xvfz package.tar.Z
# pkgadd -d .
This will ask you which packages in the
current directory you wish to install.
o To remove a package
# pkgrm <package>
o To get info on a package
# pkginfo -x <package>
# pkginfo -l <package>
o To list all installed packages
# pkginfo
o To find out which package a file is in
# grep <file> /var/sadm/install/contents
o To find out what files are in a package
# grep <package> /var/sadm/install/contents
o To find out what runlevel you're in
# who -r
docs.sun.com Application Packaging Developer's Guide
Sys Admin Magazinev08, i12 Using Solaris Packages
Converting Solaris Packages for -usr-local Use
MGMG Articles:PkgTools is a set of utilities, released under the BSD license, which can be used to aid in the development of native Solaris packages - i.e. in the pkg format.
- Requirements
- Installation notes
- Known problems
- Change log and releases - you can download the software from here
search.cpan.org SolarisInstallDB - Manages Solaris package information
Using Dialogs to Embed or Edit a Solaris Package
Mike Kruckenberg's Experiences and Observations New Approach to Building Solaris Packages
RPM-for-Unix HOW-TO Convert RPM to Solaris Package rpm2pkg
Carefully follow the download - uncompress - install steps below:
Download When downloading a file, make sure you are saving in binary (not text) mode. Check that the filesize matches the size listed above after downloading.
Uncompress First unzip the package file. This creates a
file without the .zip extension. This is a package "datastream" file,
which is suitable for installation by pkgadd. For example,
unzip fortune-off-5.2-i86pc-solaris5.7.zip;
Note: If you are running an old version of Solaris (2.5.1 or
earlier), you may not have unzip, download unzip for Solaris from
here
for SPARC or
here for
Intel/x86. Rename the unzip program as "unzip" and make it executable:
chmod +x unzip
Install Become root (login or su -). Change to
the directory containing the package. Use /usr/sbin/pkgadd to install
packages after they are uncompressed. For example,
pkgadd -d fortune-off-5.2-i86pc-solaris5.7
Use "pkginfo -l to verify the package is isntalled. For example, pkginfo -l fortune The files you installed from the package are listed at the end of file /var/sadm/install/contents to list information about the pac
Problems? If you have problems, see Steven Christensen's excellent Download and Installation Instructions and Package FAQ.
If you want to ask a question go to the Solaris On Intel mailing list or alt.solaris.x86 USENET newsgroup for Intel/x86 problems or comp.unix.solaris USENET newsgroup for Solaris (Sparc or Intel) problems.
One should create a list of packages to install to the server. for example the following are a resonable subset:
The question arise how to install them with minimal hassle. there are generally three approaches to the problem:
Auto Installation of Solaris Packages
Feel free to use more recent version if they are available. To install the packages you first need to unzip them and then issue the following commands:
su root pkgadd -d gzip-1.3.5-sol8-sparc-local pkgadd -d tar-1.13.19-sol8-sparc-local pkgadd -d top-3.5beta12.5-sol8-sparc-local pkgadd -d gcc-3.0.3-sol8-sparc-local pkgadd -d binutils-2.11.2-sol8-sparc-local pkgadd -d zlib-1.1.4-sol8-sparc-local pkgadd -d perl-5.8.0-sol8-sparc-local pkgadd -d cvs-1.11.5-sol8-sparc-localWe've added a lot of software to the system and we need to ensure that the additional programs and libraries can be found. To do this we need to edit /etc/profile (System wide) or $HOME/.profile (User specific). Whichever file(s) you decide to edit you should ensure that they contain the following lines:-
export PATH PATH=/usr/local/bin:${PATH} export LD_LIBRARY_PATH LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}Note: Each users has there own .profile file located in their default directory. By default each of these files defines their own PATH variable with a hardcoded directory list (i.e. /usr/local/bin is not included). Your options are:- 1) To manually add /usr/local/bin to the PATH declaration in .profile, or, 2) To edit .profile and change the PATH definition so that it takes into account the existing paths.
When you issue a "su root" command the paths are reset and /usr/local/bin is no longer included. To set the default path for the su command it is necessary to edit /etc/default/su. Simply search this file for "SUPATH=" and insert /usr/local/bin immediately following the "=" Make sure you insert a Colon ":" between /usr/local/bin and any existing directories.
Note: If the "SUPATH=" declaration was commented out then simply remove the "#" character.
What I often have to do is install a whole bunch of packages onto a new machine, (or domain on an Enterprise system), and if I had to do it manually, even with the benefit of a script to unpack each package tgz file, it'd take a lot of time. (Not as much time as compiling and installing all the files on each machine, but when you have to install all the files on a lab of 20 new machines, half an hour each makes for a long tedious day This way you can rcp out the scripts and the files, fire off the install scripts in parallel and then go chat to the cute new girl/guy).
What one can do is have a simple shell script which installs all of the packages you want, plus a special file which tells pkgadd to not ask you any questions and to just install the packages as is.
Here is a shell script to install a group of packages automatically:
#!/bin/sh -x
umask 000
/usr/bin/tar -xvvf GNUzip.1.2.4.SPARC.Solaris.2.6.pkg.tar
/usr/sbin/pkgadd -d. -a noask GNUzip
rm -rf GNUzip
/usr/local/bin/gunzip -c GNUbison.1.25.SPARC.Solaris.2.6.pkg.tgz | /usr/bin/tar -xvvf -
/usr/sbin/pkgadd -d. -a noask GNUbison
rm -rf GNUbison
/usr/local/bin/gunzip -c GNUcvs.1.9.SPARC.Solaris.2.6.pkg.tgz | /usr/bin/tar -xvvf -
/usr/sbin/pkgadd -d. -a noask GNUcvs
rm -rf GNUcvs
/usr/local/bin/gunzip -c GNUflex.2.5.4a.SPARC.Solaris.2.6.pkg.tgz | /usr/bin/tar -xvvf -
/usr/sbin/pkgadd -d. -a noask GNUflex
rm -rf GNUflex
/usr/local/bin/gunzip -c GNUgcc.2.8.1.SPARC.Solaris.2.6.pkg.tgz | /usr/bin/tar -xvvf -
/usr/sbin/pkgadd -d. -a noask GNUgcc
rm -rf GNUgcc
/usr/local/bin/gunzip -c GNUgdb.4.16.SPARC.Solaris.2.6.pkg.tgz | /usr/bin/tar -xvvf -
/usr/sbin/pkgadd -d. -a noask GNUgdb
rm -rf GNUgdb
You can see the pkgadd line has a -a noask option. This tells pkgadd to refer to the noask file when it reaches a point in the package installation where it needs to ask a question. The noask file essentially tells pkgadd to skip any checks and just go ahead. Since I've made all the packages I am installing, I know how the system will look after the bulk installation, and that suits me just fine.
The noask file contains:
mail=
instance=overwrite
partial=nocheck
runlevel=nocheck
idepend=nocheck
rdepend=nocheck
space=nocheck
setuid=nocheck
conflict=nocheck
action=nocheck
basedir=default
Below is a perl script to build another script which will do the bulk install for you. It relies on some conventions in the package name that don't always apply. For instance it will use the first word in the large package file to attempt to pkgadd the packge. E.g. when GNUbison.1.28.SPARC.Solaris.2.6.pkg.tgz is added to the system the package name to add is GNUbison. This is true for 95% of the packages. However some packages have names that won't fit into the nine character limit on package names so they have been 'crunched' up, or it made sense to call the package something else. E.g GNUghostscript installs as GNUghoscr and fvwm installs as fvwm2.
How does this affect the script below? Not too much since it automatically checks to see if the guessed at package installed. If it didn't, then it doesn't delete the files afterwards. If you don't actually want to have your big package files deleted after installation then remember to modify the script first.
Note: You need to manually add GNUzip and perl onto your system first.
Here is is:
#!/usr/local/bin/perl
#
# Program : mkbulkinstaller
# Author : Mark <mark@zang.com>
# Date : 27th December 1999
# Purpose : Generate package bulk installation script
#
open(NOASK, ">noask");
print NOASK "mail=\n";
print NOASK "instance=overwrite\npartial=nocheck\nrunlevel=nocheck\n";
print NOASK "idepend=nocheck\nrdepend=nocheck\nspace=nocheck\n";
print NOASK "setuid=nocheck\nconflict=nocheck\naction=nocheck\n";
print NOASK "basedir=default\n";
close(NOASK);
opendir(DIR, ".");
@files = readdir(DIR);
closedir(DIR);
open(OUTPUT, ">bulkinstall");
print OUTPUT "#!/bin/sh -x\n";
print OUTPUT "umask 000\n";
# The pkgname is usually right 95% of the time. If the name is different then
# you will have to manually add the package.
foreach $file (@files) {
next if ($file !~ /\.pkg\.tgz$/);
print OUTPUT "/usr/local/bin/gunzip -c $file | /usr/bin/tar -xvvf -\n";
$pkgname = $file;
$pkgname =~ s/\..*//;
print OUTPUT "/usr/sbin/pkgadd -d. -a noask $pkgname\n";
print OUTPUT "if [ \$? -eq 0 ]; then\n";
print OUTPUT " /bin/rm -rf $file\n";
print OUTPUT "fi\n";
print OUTPUT "/bin/rm -rf $pkgname\n";
}
close(OUTPUT);
chmod(0755, "bulkinstall");
chmod(0644, "noask");
Get all suid files from the /var/sadm/install/contents database:
grep "[46][0-9][0-9][0-9] root" /var/sadm/install/contents | wc -l
To what package the file /usr/bin/ls belongs:
pkgchk -lp /usr/bin/ls
Most popular humor pages:
Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : C++ Humor : ARE YOU A BBS ADDICT? : Object oriented programmers of all nations : C Humor : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor: Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : The Most Comprehensive Collection of Editor-related Humor : Microsoft plans to buy Catholic Church : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor : Best Russian Programmer Humor : Russian Musical Humor : The Perl Purity Test : Politically Incorrect Humor : GPL-related Humor : OFM Humor : IDS Humor : Real Programmers Humor : Scripting Humor : Web Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor :
Copyright © 1996-2013 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine. This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...
|
|
You can use PayPal to make a contribution, supporting hosting of this site with different providers to distribute and speed up access. Currently there are two functional mirrors: softpanorama.info (the fastest) and softpanorama.net. |
Disclaimer:
The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.
Last modified: December 19, 2004