Skip to content

4. Centaur files

Chiron edited this page Feb 22, 2026 · 5 revisions

What are they?

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).

Features

  • 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

Creating .centaur files

Rules

There are a couple of things that you need to remember when writing .centaur files:

Each command is separated by a blank line

# Do this:
mkdir example_dir

cd emable_dir

Two adjacent lines will be concatenated together

# 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.

Each line has a character limit a 250 characters

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.

Comments (#)

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 console

Naming

Please follow this standard:

[Package Name]-[Package Version].centaur

# For example:
writedoc-2.3-p1.centaur

Root permissions

Centaur 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.

Recommendations

Steps for installing

Downloading source code

  • Preferably download a tarball with wget, you could use git clone but wget is 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.gz

installs the writedoc v2.3-p1 tarball to /tmp/centaur/writedoc.tar.gz

Compiling and Installing

  • No specific software, do whatever

Cleaning up files

  • Use rm with minimal permissions. Example:
rm writedoc.tar.gz
rm -r writedoc-2.3-p1/

Deletes the tarball and extracted directory.

Adding uninstall instructions

  • Please use echo -e "...\n" | tee -a .... Due to the way the .centaur files are passed it is more readable than using cat.

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 $UNINSTALL

Writes 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.

Printing to Stdout

  • Use echo

Example:

echo "Finished installing!"

It's a good idea to let the user what is going on.

Example

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:

  • sudo is not used anywhere
  • Environment variables are used
  • Use of multiline parsing to improve readability

Clone this wiki locally