You've correctly noticed that a package has a name, an author, and a version. These three uniquely identify a package. If you need to map this to a file system, you could choose a structure such as
This allows two authors to offer different packages under the same name, and multiple versions of one package to be installed at once. If no support for multiple versions is needed, you can drop the
The question is how to assign author IDs. Java uses the nice trick of simply using domain names, since they should be unique anyway. This works well if every developer can be expected to own a domain (this would seem to be the case in web application development). However, Java reverses the order of subdomains so that the hierarchically most important information is at the front of the name. The domain
dev.example.com is mapped to the prefix
It is useful to have a file in each package that describes metadata. This file could declare information about dependencies, a summary of what this package does, an a version number.
With this structure, installing or upgrading a package would work like this:
- The new package is unpacked into a temp directory, and the metadata is read.
- The directory of installed modules is searched for a package of same name from the same author. If no match is found, this package is installed.
- If a match was found and the version number is higher, then the old package is removed and the new package installed.
- Before installation, the presence of dependencies is verified.
There are tons of package managers which you can steal ideas from. Take a look at CPAN (Perl), pip (Python), gem (Ruby), npm (Node.js). Each of these have some strengths and some weaknesses.