I don't think they're actually that hard to make. I can already think of a basic structure.
You have a bunch of command-line tools (who needs a GUI for this sort of thing? GUIs are for web browsers and video players and ballerinas):
add-pkg -- install a package
rm-pkg -- remove a package
upgrade-pkg -- upgrade a package
update-pkg -- update the package list
search-pkg -- search for packages |
Now, all you have to do is have a central database of packages, e.g.
The database stores the URIs of various installable packages, e.g.
+------------------+----------------+------------+----------------------+
| Package Name | Latest Release | Installed? | Date of Installation |
+------------------+----------------+------------+----------------------+
| foo | 1/1/1970 | No | N/A |
+------------------+----------------+------------+----------------------+
| End of the world | 23/12/2012 | No | N/A |
+------------------+----------------+------------+----------------------+ |
(you could get rid of the Installed? column because the Date of Installation is N/A when a package isn't installed).
When you want to install a package,
1. Check you haven't installed it already
If you have, skip to 3, otherwise, continue
2. Install it
3. Check you have the most recent version (check the date last modified on the server vs. your date of installation)
If you do, quit. If you don't, go to step 2.
The big hole in this arises when you want to remove or upgrade packages. For this, I would suggest having a list of files for each package, e.g.
which could look something like
foo|/usr/bin/foo:/usr/lib/libfoo.a:/usr/share/lib/libfoo.so |
or whatever.
When you want to remove a package,
1. Check you have it (check /var/pkg/packages.db)
2. Find the .lst file for it (in /var/pkg/lists/ or whatever)
3. Delete all the files it created
4. Delete the .lst file
5. Mark as uninstalled in packages.db
To upgrade a package, you can go one of two ways (that I can think of).
1. Delete it and reinstall it
2. Download the new version and overwrite the old files
If you choose to delete and reinstall it,
1. Check it really is out of date (packages.db)
2. Call rm-pkg for it
3. Call add-pkg for it
Otherwise,
1. Check it's actually out of date
2. Download the newest version
3. Extract it
4. Replace all the old files
5. Install new files if any
6. Recreate the .lst file
I would say the second way was probably marginally faster, but also harder to write.
Either updating or searching is the easiest.
Updating:
Download a new packages.db file from a server
Searching
Parse the existing packages.db file and look for what the user entered (or the closest match).
Of course, I didn't even touch on dependencies. That will likely be the most difficult part, unless you rely on package maintainers to tell you what packages their package depends on. Then all you do is fork() and exec() add-pkg on each dependency... the issue being that if you download a program that has 10 dependencies, and each of those has 10 dependencies, and so on, you quickly fill up the process table and start printing seeing a lot more
perror("fork()");
:P