-
Notifications
You must be signed in to change notification settings - Fork 0
4. Centaur files
A .centaur file is just a sequence of bash commands to install a package. Inspired by portage's ebuilds, these files turn centaur into a compile-based package manager. I've designed the syntax of these files to be as easy to create and use as possible and what better way of doing this than parsing bash (which so many people know already).
- Mostly Bash (which means all the CLI commands you normally use will work in .centaur files)
- Comments
- Environment variables
- More stuff coming later because I've just started making this project :P
There are a couple of things that you need to remember when writing .centaur files:
# Do this:
mkdir example_dir
cd emable_dir# These two lines:
echo "This is the first line
and this is the second line"
# Will be executed like this:
echo "This is the first line and this is the second line"A space character (" ") will be joined inbetween. This is mainly used for making long commands easier to read.
Sorry, my C skills aren't great and I will be eventually implementing a way for any number of characters in one line, but for now this is good enough. Use the tip above for overcoming this.
Pretty self-explanatory...
# I am a comment, the rest of this line will be ignored by the parser
echo "what does this do?" # this prints to the consolePlease follow this standard:
[Package Name]-[Package Version].centaur
# For example:
writedoc-2.3-p1.centaurCentaur will already have been called with root permissions for installation and uninstallation (is that a word?). You do not need to include sudo in your commands.
- Preferably download a tarball with
wget, you could usegit clonebutwgetis easier IMO - Please download it to
/tmp/centaur/
Example:
wget https://github.com/Chiron8/writedoc/archive/refs/tags/v2.3-p1.tar.gz -O /tmp/centaur/writedoc.tar.gzinstalls the writedoc v2.3-p1 tarball to /tmp/centaur/writedoc.tar.gz
- No specific software, do whatever
- Use
rmwith minimal permissions. Example:
rm writedoc.tar.gz
rm -r writedoc-2.3-p1/Deletes the tarball and extracted directory.
- Please use
echo -e "...\n" | tee -a .... Due to the way the .centaur files are passed it is more readable than usingcat.
Example:
export UNINSTALL="/etc/centaur/packages/uninstall/writedoc-2.3-p1.centaur"
echo -e "rm /usr/local/bin/writedoc \n" |
tee -a $UNINSTALL
echo -e "rm /usr/local/share/man/man1/writedoc.1 \n" |
tee -a $UNINSTALL
echo -e "rm -r /usr/local/share/writedoc \n" |
tee -a $UNINSTALLWrites instructions to uninstall file. Uses environment variable to make it a little less monotonous. I know it's not the best. But there shouldn't really be that many files/directories needed to be removed.
- Use
echo
Example:
echo "Finished installing!"It's a good idea to let the user what is going on.
Take a look at writedoc-2.3-p1.centaur:
echo "Downloading..."
wget https://github.com/Chiron8/writedoc/archive/refs/tags/v2.3-p1.tar.gz -O /tmp/centaur/writedoc.tar.gz
echo "Installing..."
sudo tar -xf /tmp/centaur/writedoc.tar.gz -C /tmp/centaur
cd /tmp/centaur/writedoc-2.3-p1/
sudo ./install.sh
echo "Finished installing! "
echo "Tidying Files..."
cd ../
rm writedoc.tar.gz
rm -r writedoc-2.3-p1/
echo "Adding uninstall scripts..."
echo "sudo rm -f /usr/local/bin/writedoc" |
sudo tee -a /etc/centaur/packages/uninstall/writedoc-2.3-p1.centaur
echo "sudo rm -f /usr/local/share/man/man1/writedoc.1" |
sudo tee -a /etc/centaur/packages/uninstall/writedoc-2.3-p1.centaur
echo "sudo rm -rf /usr/local/share/writedoc" |
sudo tee -a /etc/centaur/packages/uninstall/writedoc-2.3-p1.centaur
echo "Finished!"We have all the necessary things to successfully install the program and uninstall data.
- User messages
- Downloading and extracting a tarball to
/tmp/centaur - Running an install script (you can always use other commands)
- Cleaning up files that are no long needed after installation
- Uninstall instructions are written
Cases of good practice:
-
sudois not used anywhere - Environment variables are used
- Use of multiline parsing to improve readability
Centaur Execution Nixes The AUR