This tutorial guides you through the steps involved in making your own Pacman cache. It's easy.
First, setup Pacman as usual, so that % pacman -version does something like
Pacman Version: 2.060
Platform: linux-redhat-7.0
Python Version: 2.1 (#2, Jun 24 2001, 15:32:22)
[GCC 2.96 20000731 (Red Hat Linux 7.0)]
Choose a work area and make subdirectories like so
% mkdir localcache
% mkdir installs
The localcache directory will be your new Pacman cache and the installs directory is a temporary installation for testing purposes. These directories can be anywhere in the file system, but if you want the cache to also be visible to remote users, put it in a web visible part of the file system (on many systems, a location like /home/yourname/public_html is web visible).
For practice, let's pretend that nedit isn't already available and we're making a Pacman file for it. First just create an empty text file named nedit.pacman and put it in the localcaches subdirectory. Then cd over to installs and do
% pacman -get /.../localcache:nedit
where "/.../" should be replaced as appropriate. After agreeing to trust the new cache /.../localcache, pacman will install "nedit" which, at this stage, is a package with no attributes other than a name. Then try % pacman -info switch causes a web browser to be launched showing the status of your new installation. You should see that a package called nedit is installed and you should be able to follow links to view your new cache and the standard Pacman cache.
Now edit the file caches in the current directory and remove the line Pacman so you are only trusting your own local cache. You can modify the caches file at any time.
Now let's try to add something more to the nedit package. Edit the file nedit.pacman and add the lines
description = 'Text Editor'
url = 'http://www.nedit.org/'
and save the file to disk. Then do
% pacman
to update the database and web page. Reloading your browser, you should see that the column labelled "update" now says "yes" indicating that the package nedit has a new version. To update your installation, do
% pacman -updateall
and reload the web page. You should see a new description of nedit and a pointer to the nedit web site.
Next, let's do something more substantial. Get the tarball nedit-5.1.1-linux-glibc.tar.gz from one of the previous tutorials [or go to a scratch area and do % pacman -fetch nedit] and put it in the localcache area. Add the following line to nedit.pacman:
download = {'*' : 'nedit-5.1.1-linux-glibc.tar.gz'}
and do % pacman -updateall as before. The download attribute above indicates that for any operating system (that's what the "*" means), download nedit-5.1.1-linux-glibc.tar.gz.
So far, nedit is being fetched, unzipped and untarred. Since this tarball delivers working binaries, there is not much else to do in this case. Of course, to actually use nedit, the binary has to be in the path for the user. To do this, add
paths = [['PATH','']]
to the nedit.pacman file and re-update with % pacman -updateall (see the Pacman file syntax page for what this means exactly). Now if you look at the files setup.csh or setup.sh in your local directory, you will see that you can do % source setup.csh and then proceed to use nedit. In general, sourcing the file setup.csh or setup.sh is meant to do all the setting up that's necessary to use all the software in the installation. For example, do
% pacman -get Pacman:Python
and you will find that a version of Python and it's documentation gets installed on your system and that setup.csh is updated so that it sets up Python properly if you source setup.csh. You can add any shell commands that you want to the setup procedure by using the setup attribute. For example, add the line
setup = ['pwd','ls']
to nedit.pacman, re-update and you will see that these just get put directly in the setup script.
At this stage, your file nedit.pacman will look something like this:
description = 'Text Editor'
url = 'http://www.nedit.org/'
download = {'*': 'nedit-5.1.1-linux-glibc.tar.gz' }
paths = [['PATH','']]
setup = ['pwd','ls']
Even though your nedit.pacman is working, it helps to add a few refinements, especially if you expect others to use your cache. For example, you might want to
download = { 'linux-redhat-7.0' : 'nedit-5.1.1-linux-glibc.tar.gz' }
so that if the system is not RedHat linux 7.0, Pacman will explain the problem rather than letting some obscure failure occur. You can arrange for different downloads for different platforms by using multiple entries in download as in
download = { 'linux-redhat' : 'nedit-5.1.1-linux-glibc.tar.gz', '*': 'nedit-5.1.1.tar.gz' }
which will download the same file as before in the case of Red Hat Linux and will download nedit-5.1.1.tar.gz otherwise. Do % pacman -platforms to see which platform types are available.
inpath = ['tar','gunzip','gcc']
for example, this guarantees that tar, gunzip and gcc are available to the installer before the installation proceeds. The advantage in doing this is that if one of these items is missing, Pacman will nicely say what's missing rather than letting a more obscure failure occur.
install = {'*':['./configure','make'], 'root':['.configure','make','make install'] }
which causes pacman to execute the second set of commands if you're root and the first set of commands if you're anyone else. You can put any shell commands in these lists including launching interactive programs. For example, you will find mozilla.pacman in the standard Pacman cache and it contains a line
install = {'*': ['mozilla-installer'] }
If you do % pacman -get Pacman:mozilla, Pacman will unzip, untar and run the standard mozilla installer gui.
Notice, also, that mozilla.pacman contains a line
source = 'http://ftp.mozilla.org/pub/mozilla/releases/mozilla1.0/'
which means that Pacman will fetch the tarball from this location rather than from the same directory containing mozilla.pacman. This is useful if for stable software or if you don't want to be in a position of re-distributing someone else's tarball.
Pacman also knows how to handle rpm files instead of tarballs. If you fetch an rpm, it will automatically handle the rpm commands necessary for installing and uninstalling the rpm. If an rpm of the same name exists, it will ask you first if you want to replace it unless you use the -force-rpm switch to force replacing rpms. Of course, you usually have to be root to do this.
Although nedit is a stand-alone application, let's pretend that nedit is dependent on Python and Pacman. In this case, you would add a line
depends = ['Pacman:Python','Pacman:Pacman']
and if you re-update nedit, you will find that Python and Pacman are automatically installed first. You could also have put the explicit urls in the depends attribute as in
depends = ['http://physics.bu.edu/~youssef/pacman/sample_cache/:Python', 'http://physics.bu.edu/~youssef/pacman/sample_cache/:Pacman']
You can also just do
depends = ['Python','Pacman']
in which case Pacman will take the first package called Python and Pacman from your caches list. For a complete list of attributes available in Pacman files, see the Pacman file syntax page.
RPMs are automatically handled analogously to tarballs. For example, if you do
download = {'linux-red-hat':'my-rpm-package-1.0.rpm'}
and you put the rpm in the same directory as the .pacman file, Pacman will automatically download and install the rpm. If an rpm already exists, it will first ask you if you want to replace it (unless you use -force-rpm which always replaces). Of course, to do such things, you must be root. The only slightly tricky aspect of this is that an rpm package with rpm name XXX must be made into a Pacman package XXX.pacman or you will not be able to uninstall the package automatically.
Once an installation has succeeded, Pacman will automatically remove any downloaded files unless you use the switch -savedownload.