A simple, homebrew-like package manager for Ubuntu that automatically downloads, extracts, compiles, and manages packages locally.
- 📦 Download & Extract: Supports multiple archive formats (tar.gz, tar.bz2, tar.xz, zip, 7z).
- 🔍 Auto-Detection: Automatically detects project language and build system (Java, Go, Rust, C/C++, C#, Node.js, and more).
- 🔨 Auto-Compilation: Compiles C, C++, C#, and Java projects with the appropriate build tools (
make,cmake,dotnet,mvn,gradle). - 🛤️ Reliable PATH Management: Automatically keeps your
PATHin sync. After adding or removing packages,ubrewverifies that all installed packages are in yourPATHand removes any that are no longer installed. - 🔧 Automatic PATH Repair: The
verifycommand automatically adds missing package paths, removes orphaned entries, and interactively cleans up unused archives. - 🔒 Protected Configuration: Clearly marked sections in the
PATHfile prevent accidental manual edits. - 📝 Logging: Tracks all operations in a log file (
~/.ubrew/ubrew.log). - 💾 Archive Caching: Downloaded archives are cached to avoid re-downloading.
- 📦 Local Storage: All packages are stored in
~/local_packages/packageswith archives cached in~/local_packages/archives. - 🎯 Zero Manual Configuration: Everything is automatic after
init.
For basic functionality:
sudo apt-get update
sudo apt-get install -y curl wget unzip p7zip-fullFor language-specific compilation, install tools as needed:
For C/C++:
sudo apt-get install -y build-essential cmakeFor C#/.NET:
sudo apt-get install -y dotnet-sdkFor Java:
sudo apt-get install -y default-jdk maven gradle-
Make sure the script is executable:
chmod +x ubrew.sh
-
Initialize ubrew (this automatically adds it to your shell configuration):
./ubrew.sh init
-
Reload your shell for the changes to take effect:
exec $SHELL
That's it! The init command automatically adds ubrew to both ~/.bashrc and ~/.zshrc.
To later remove ubrew from your shell configuration:
./ubrew.sh uninitAll commands are run via the main ubrew.sh script. After initialization, you can call ubrew from any directory.
Initializes the ubrew environment.
./ubrew.sh initTo force re-initialization and clear all existing data (packages and archives), use the --force flag:
./ubrew.sh init --forceThis command:
- Creates the necessary directories (
~/.ubrew,~/local_packages/packages,~/local_packages/archives). - Automatically adds
ubrewto both~/.bashrcand~/.zshrc. - Configures the
PATHmanagement file. - Prompts you to reload your shell.
If ubrew is already initialized, the command will exit with a warning. Use the --force flag if you intend to start fresh.
Downloads, extracts, and compiles a package from a URL or a local file path.
# From a URL
./ubrew.sh add <URL>
# From a local file
./ubrew.sh add /path/to/archive.tar.gzAfter a successful installation, ubrew automatically runs a verification check to add the new package's binary directory to your PATH.
Examples:
- Go:
ubrew.sh add https://golang.org/dl/go1.17.5.linux-amd64.tar.gz - Java/Maven:
ubrew.sh add https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz - Node:
ubrew.sh add https://nodejs.org/dist/v16.13.1/node-v16.13.1-linux-x64.tar.gz
Removes a package.
./ubrew.sh remove <package_name>After removing the package, ubrew automatically runs a verification check to remove the package's directory from your PATH.
Lists all installed packages.
./ubrew.sh listTo see the full installation path for each package, use the -p flag:
./ubrew.sh list -pManually verifies the ubrew environment. This is the interactive version of the verification that runs automatically after add and remove.
./ubrew.sh verifyThis command performs the following actions:
- Adds Missing Paths: Scans all installed packages and adds
PATHentries for any that are missing. - Removes Orphaned Paths: Removes
PATHentries for packages that are no longer installed. - Cleans Orphaned Archives (Interactive): Prompts you to remove any downloaded archives for packages that are no longer installed.
Removes ubrew from your shell configuration files (.bashrc and .zshrc) automatically.
./ubrew.sh uninitThis does not remove the ~/local_packages or ~/.ubrew directories. You can remove them manually if you wish.
Displays the help message.
./ubrew.sh helpubrew detects the language or build system of a package by looking for specific files in the extracted directory:
- Java:
pom.xml(Maven) orbuild.gradle(Gradle) - Go:
go.mod - Rust:
Cargo.toml - Python:
setup.pyorpyproject.toml - Node.js:
package.json - C/C++:
Makefile,configurescript, orCMakeLists.txt - C#:
.csprojfiles
Based on the detected language, ubrew runs the appropriate build command:
- make:
make - cmake:
cmake .. && make - csharp:
dotnet build -c Release - java:
mvn clean package -DskipTestsorgradle build -x test
For other languages like Go, Python, or Node, no compilation step is taken, as they are typically pre-compiled or script-based.
ubrew manages all PATH exports in a single file: ~/.ubrew/path.conf. This file is sourced by your .bashrc or .zshrc.
The verify command ensures this file is always correct by:
- Finding all installed packages in
~/local_packages/packages. - Checking if each one has a corresponding
export PATHline inpath.conf. - Adding lines for missing packages and removing lines for uninstalled ones.
The binary directory is inferred (bin, target, or the root of the package).
This project is licensed under the MIT License.