So I'm currently working on creating an automated system that copies the whole PND repository out to a file system (for rsync, FTP and whatnot; I've not considered creating an *importer* because a repository should be write-once read-everywhere; we can't deal with randomw rites coming from all over the place)
...and was just thinking: The (kind of) current repository.xml file contains static absolute canonical URLs to various resources (PND files, screen shots, etc), aka in the style of "http://repo.com/packages/foo-1.2.3.4.pnd" which is suboptimal if you want to create copies of the repository, since all URLs then need to be rewritten to match the new repository location.
Now, I've done some more research and studied the RPM and APT package repository meta data formats, and have seen that they tend to use semi-relative paths to locate package files. This of course has some advantages and disadvantages. The primary advantage is that you can move the entire repository tree to another location, and you won't have to change any files within to still be able to use its contents. The disadvantage is of course that all of the repository related files have to stay inside of the repository tree in order to always be accessible, since there aren't any absolute URLs that guarantee a fixed location for the files.
For now, I've thought that the advantages outweigh the disadvantages, and have thus created the following directory structure (yes, I've changed a lot):
/meta/repository.xml (1)
/meta/packages/1.xml (2)
/pnds/foo_bar-1.2.3.4.pnd (3)
/icons/1.png (4) (oh and these are 128x128 pixels in size)
/smallicons/1.png (4) (these are 64x64)
(1) The repository descriptor. Contains a list of all packages, including a "details"-URL for each package that point to the meta files described below
(2) Meta data about a package. Currently, the magic file name in this case is the database ID of a package (I was lazy), and it shouldn't really matter what it is, since you simply are able to find a package in the repository.xml file and use the URL within to locate the meta file. So the package meta files' names and locations are moot; I just put them there for convenience (and again, since we're using semi-relative URLs, they should be close at hand in case we want to move the repository). If someone creates an alternative implementation of this, they'll be able to store the files in whichever location they choose as long as they keep the repository.xml file in the same location.
(3) These are the actual PND files, conveniently named by name. Their name/location doesn't really matter either, since, as above, they are referenced from the master repository file and the package meta data file, but I gave them good names because they thus don't create naming conflicts when downloaded.
(4) The icons belonging to a package, and again referenced by DB id, also since their URL is in the meta data.
This system would then work as follows:
- The actual repository location that an user would enter into some package installer would be the canonical path to the repository root dir. Examples:
- Repofile loc: http://pndmanager.org/meta/repository.xml ; What the user enters as the repository path: http://pndmanager.org/
- Repofile: ftp://192.168.2.7/packages/pnd/meta/repository.xml; path: ftp://192.168.2.7/packages/pnd/
- The various metadata files reference other files by using the repository location as their "root directory" (à la APT/dpkg). So in a package metadata file, a pnd file URL would be "/pnds/mypackage-1.2.3.4.pnd".
- The whole thing is portable and can be accessed over any protocol, including http, ssh, ftp, whatever
Anything that I've missed or something I should change?
Oh and in case anyone looks at the repository file and notices lots of '<icon href="..."></icon>' instead of the usual '<icon href="..."/>'; this is because expanded tags are easier to read by many XML parsers, and since this is the default Scala XML mode anyways, I stuck with it.