-
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).
A skeleton file is included in this repo and also availiable at /etc/centaur/packages/skeleton.centaur for you to get started.
- Mostly Bash (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
- Currently only one liners are supported. This means for loops etc.. must be kept to one line.
- Comments in the middle of a line
There are three main elements of a .centaur file:
- Meta block - This contains information about dependencies and how a package should be installed
- Install block - This is the bash that is run to install the package
- Uninstall block - This is the bash that is run to uninstall the package
All together it looks like this:
[meta]
# metadata in here
[/meta]
[install]
# install bash in here
[/install]
[uninstall]
# uninstall bash in here
[/uninstall]To make a comment use #. Comments starting in the middle of the line are not currently supported.
There are a couple of things to keep in mind when writing .centaur files:
The meta block MUST show what dependencies need to be installed (even if there are none!):
[meta]
dependencies = "foo bar"
[/meta]The variable dependencies stores a string where each package is separated by a space (" ")
Only the dependencies variable is required, however it is good practice to include some other data:
[meta]
dependencies = "foo bar"
name = "package"
version = "0.1"While name and version are ignored by the parser, it is still helpful to include.
Anything can technically be added in the meta block, it is just ignored if it is not recognised.
All dependencies required should be added to the top of the file. Dependencies and install commands should be separated by a line starting with =. e.g.
Please 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.
- 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:
[meta]
name = "writedoc"
version = "2.3-p1"
dependencies = "example"
[/meta]
[install]
echo "Downloading..."
wget https://github.com/Chiron8/writedoc/archive/refs/tags/v2.3-p1.tar.gz -O /tmp/centaur/writedoc.tar.gz
echo "Installing..."
tar -xf /tmp/centaur/writedoc.tar.gz -C /tmp/centaur
cd /tmp/centaur/writedoc-2.3-p1/
./install.sh
echo "Finished installing! "
echo "Tidying Files..."
cd ../
rm writedoc.tar.gz
rm -r writedoc-2.3-p1/
echo "Finished!"
[/install]
[uninstall]
echo "Uninstalling..."
rm /usr/local/bin/writedoc
rm /usr/local/share/man/man1/writedoc.1
rm -r /usr/local/share/writedoc
echo "Finished!"
[/uninstall]We have all the necessary things to successfully install the program and uninstall data.
- 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:
- User messages
-
sudois not used anywhere -
nameandversionare included in the metadata
Centaur Execution Nixes The AUR