Author Topic: [SOLVED] APT-RPM Local Repository Questions  (Read 1999 times)

skyhawk

  • Guest
[SOLVED] APT-RPM Local Repository Questions
« on: October 20, 2009, 04:24:49 PM »
I have PCLinuxOS LXDE installed on my P3 machine. I have the four DVD's containing the complete PCLinuxOS 2009 Repository (Version 2009.05.18), purchased from On-Disc.com. Now I want to create a local repository on my P3 machine, which has only a CD-RW drive. My P4 Windows XP Pro SP2 machine does have a DVD/CD-RW drive, so I would like to copy the packages contained on the DVD's to CD's, and then have Synaptic (apt-rpm) use the packages directly from the CD's, rather than copying packages from CD to hard disk. Since there will be more CD's than the original number of DVD's, I need to know, first: if this is possible to do, as I have described, and second: how can (should) the CD's be labelled, so that they will be recognized by Synaptic? I would like Synaptic to ask for each disc, one-by-one, as they are needed for packages to be installed.

I already understand the basics as to how a local repository can be created, and these basic facts lead me to believe that, where the original DVD repository discs have the directory tree structure of:

DVD1  /Repository/pclinuxos/2007/base
DVD1  /Repository/pclinuxos/2007/RPMS.gnome
DVD1  /Repository/pclinuxos/2007/RPMS.main

DVD2  /Repository/pclinuxos/2007/RPMS.kde
DVD2  /Repository/pclinuxos/2007/RPMS.kde4
DVD2  /Repository/pclinuxos/2007/RPMS.nonfree

DVD3  /Repository/pclinuxos/2007/RPMS.extra

DVD4  individual packages only, no tree structure

I will need a directory tree structure something like:

/home/rg/Repository/pclinuxos/2007/RPMS.main/disc1/
/home/rg/Repository/pclinuxos/2007/RPMS.main/disc2/
... etc.

to allow for the multiple CD's burned from each DVD, due, of course, to the smaller storage capacity of CD's, compared to DVD's.

If the above-described procedure is not possible, I will revert to a method similar to that which I used with Mandriva Free 2007.0, where selected packages were copied to my local repository, then installed using URPMI's GUI. I understand that apt-rpm's "genbasedir" command is the equivalent of URPMI's "genhdlist" command, used to auto-generate a package list for the local repository. Once the package list is generated, I can use Synaptic to do the installation. Of course, if my P3 machine had a much larger capacity hard disk and a DVD/CD-RW drive, things would be very easy, but I am not going to put any more money into the P3; it will have to hobble onward as it is.

Thanks in advance for any assistance. I recognize that this is an advanced topic, and that local repositories are seldom needed by Linux users, particularly those seeking the most user-friendly distro that is available. My ultimate success with my Mandriva local repository was largely due to trial-and-error on my part; documentation was very scarce.
« Last Edit: October 21, 2009, 11:17:36 AM by skyhawk »

skyhawk

  • Guest
Re: APT-RPM Local Repository Questions
« Reply #1 on: October 21, 2009, 11:15:57 AM »
As an addendum to my initial post, I am providing more information here, gleaned from "Google" searches, that seems to point the way to where I want to go. These "snippets" are specifically targeted toward RedHat users, but interpolation can be used to make them apply to PCLinuxOS. It appears that making Synaptic recognize custom-burned CD's is not as difficult as I had thought, and that my suppositions about the tree structure for a local repository, as far as using CD's is concerned, was in error. It is important to note, if the information I copied is correct, that packages on disc are given priority over packages on the remote server, only if package versions are the same; newer versions will be downloaded from the remote server. In summary, I think I now have what I need to proceed with my local repository plans, and I will mark this thread [SOLVED] -- although helpful additions are always welcome. What follows below is not my work; it was copied and is essentially unmodified.

=================================================
PREPARING AN APT MIRROR
=================================================
Apt directories require specific structure. The tools required to generate this repository come with the apt rpm package. But first a bit of preparation is required. A release file defines the type of repository; it is shown here:

  Archive: stable
  Component: os
  Version: 7.2
  Origin: RedHat
  Label: RedHat
  Architecture: i386

Then, a second directory tree is constructed and symlinks are generated to the actual rpm files mirrored above. Finally the genbasedir program can be ran to generate the apt database files. We will return to this in a short bit.

The genbasedir tool calls other tools in the apt distribution to generate database files for the packages listed. The main directory of an apt tree, in our case, "redhat-7.2-i386/redhat", is referred to as the distribution. Each distribution has its own line in the sources.list file. Parts of a distribution, such as os, are called components. Each requires its own database. The release file mentioned above is located in the base directory with the name of "release.os" where the suffix names the component it describes.

genbasedir expects a certain directory structure. This must be setup before genbasedir is ran. The directory "redhat-7.2-i386/redhat", which bears the name of the distribution, must contain a base directory for the internal use of apt; i.e., database files will be generated in this dir. It also requires at least one RPMS.XXX directory where the XXX is a name of a component. In our case the component directory is called "RPMS.os", as our only component is the os component. "RPMS.os" can actually be a symlink to the "redhat-7.2-en/os/i386/RedHat/RPMS" directory in our mirror. Once setup, we run genbasedir as follows:

  $ genbasedir --topdir=/path/to/apt/tree/ --bloat --bz2only redhat-7.2-i386/redhat os

After running genbasedir, the base subdir will contain a bzipped database files with all the package information. For the above example, the database file is called pkglist.os.bz2. Your repository is now ready to be used by apt-get.

=================================================
ADDING THE PLANET CCRMA CDROMS TO APT
=================================================
This is only needed if you are going to be using the Planet CCRMA cdroms.

If you are installing from the Planet CCRMA cdroms you need to configure apt to use the cdroms in addition to the internet connection to the repository (which is what you just set up by installing the custom sources.list file).

Unmount your Planet CCRMA cdrom first and type:

  apt-cdrom add

Insert the first cdrom (it does not matter which) when prompted, and press enter when ready so that apt-cdrom can scan it. When it is done it will prompt for a name for that particular cdrom, just type in whatever you scribbled on it to differentiate it from the other(s). Do the same with the other cdrom(s).

If you now look at the /etc/apt/sources.list file you will see that apt-cdrom has added several lines before the ones that were there before. They start with "rpm cdrom:" instead of "rpm http:" and point to the cdroms you just inserted. From now on apt-get knows about your cdroms (in addition to the Planet CCRMA apt repository) and your cdroms will have precedence over the network when versions match (the network URLs will override the cdrom if the online version of a package is newer than the cdrom version).

If you ever want to get rid of the cdroms just erase those lines from /etc/apt/sources.list (or comment them out by prepending a "#") and do an "apt-get update".

That's it. If something you want to install is in the cdroms you will be prompted by apt-get (or synaptic, see below) to insert it and the packages will be copied from it to the hard disk before the installation begins. If there is a newer version in the CCRMA apt repository, it will be downloaded instead.

If you do not have a network connection at all in the install machine you should comment out all the /etc/apt/sources.list entries that begin with "rpm http:". In that way apt will not try to load the network repository apt databases. Caveat: if you do not have the full set of Planet CCRMA cdroms (including the custom RedHat install cdroms) you may not be able to install all Planet CCRMA packages if you did not originally install all RedHat packages. Some Planet CCRMA packages may depend on original RedHat packages that are not installed in your computer, and the apt database only knows about what you have installed and the cdroms you have fed to apt-cdrom.

Caveat: depending on your desktop settings it might happen that the desktop itself mounts the cdrom before apt-cdrom gets to see it and then the subsequent mount attempt will fail (and you have to unmount and try again). You'll have to be fast or just disable the obnoxious (IMHO) automatic mounting of removable media in your desktop of choice (for Gnome go to "Settings", "Peripherials" and "CD Properties" and uncheck the autorun boxes -- for manual "gui" oriented mounting you can always add the "Drive Mount" applet to your panel and configure it to point to the cdrom drive).

=================================================
SYNCHRONIZING WITH THE REPOSITORY
=================================================
After you have configured apt (and maybe added the cdroms to the mix) type:

  apt-get update

This will load the package database from the Planet CCRMA repository. You will have to do that whenever you start a new session of upgrades or installs as the repository might have changed since the last time you accessed it.

Offline Joble

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6804
  • USA - Mountain Time
Re: [SOLVED] APT-RPM Local Repository Questions
« Reply #2 on: October 21, 2009, 11:25:30 AM »
Wow, I didn't even know that was possible!  Way Cool!
Search First.
Forum Rules
Hero means I talk a lot, nothing more, nothing less!
Have an Awesome Day!
Healthy System

skyhawk

  • Guest
Re: [SOLVED] APT-RPM Local Repository Questions
« Reply #3 on: October 21, 2009, 11:39:30 AM »
Wow, I didn't even know that was possible!  Way Cool!

Yes, Joble ... way cool ... and almost mind-boggling. Eat your heart out Bill Gates and company.

I also want to mention that there are a lot of "hidden secrets" to be found in the apt man pages: apt-get, apt-cache, apt-cdrom, etc. They are well worth reading, and will provide a lot of insight as to what goes on behind Synaptic. I found much more information during my "Google" searches, which I will not go into here, but anyone who has the time can search using the keywords "apt-rpm" and "apt-rpm local repository" to find much useful information. And note that PCLinuxOS Synaptic is just a frontend for an adaptation of apt-rpm.