I created my own linux distro (if you can call it that) and the last thing want to do is to create my own package manager and I have no idea on how to do this. How can I create something like apt, yum etc. What are some good resources on this?
答案1
All package managers work the same way which is not exactly too difficult to mimic, the question is implementation details.
If you don't want to use your own package format, e.g. something akin to RPM or DEB, you can simply use tar.gz
Within this tar.gz file you can you have your package files and auxiliary files which contain: description, list of files (if you want allow the user to search for files without extracting the whole archive) and dependencies (might be a simple list of files).
Building dependencies is not a rocket science either. You can use
ldd
or/andstrace
.
Now you have to create a dababase of packages files and dependencies which you can store in e.g. Berkley DB or SQLite DB.
Then you have to find a way to scan these dependencies whenever the user wants to install a new package
Lastly you need to have a database of installed files and packages.
This all involves a ton of code. You'd be better off using something which is already available.
Lastly, of course you can reinvent the wheel and do it all but there are literally thousands of bug reports filed against Open Source projects which you could help by fixing them. No one really needs a new obscure distro which you will maintain for a while and then get rid of, because you don't have enough time for it or you're not motivated enough for various reasons.