a simple method of defining apt-get dependencies for an application
- apt-get
- dpkg
# curl all the things!
curl -o /usr/local/bin/aptfile https://raw.githubusercontent.com/seatgeek/bash-aptfile/master/bin/aptfile
chmod +x /usr/local/bin/aptfile
You can also create a debian package via docker using make
with the provided Dockerfile
. The debian package is made via the wonders of fpm
:
git clone https://github.com/seatgeek/bash-aptfile.git
cd bash-aptfile
make deb
# sudo all the things!
sudo dpkg -i *.deb
Create an aptfile
in the base of your project:
#!/usr/bin/env aptfile
# ^ note the above shebang
# trigger an apt-get update
update
# install some packages
package "build-essential"
package "git-core"
package "software-properties-common"
# install a ppa
ppa "fkrull/deadsnakes-python2.7"
# install a few more packages from that ppa
package "python2.7"
package "python-pip"
package "python-dev"
# setup some debian configuration
debconf_selection "mysql mysql-server/root_password password root"
debconf_selection "mysql mysql-server/root_password_again password root"
# install another package
package "mysql-server"
# you can also execute arbitrary bash
echo "🚀 ALL GOOD TO GO"
Now you can run it:
# aptfile *does not* use sudo by default!
sudo aptfile
# enable bash tracing
TRACE=1 sudo -E aptfile
# you can also execute a specific aptfile
sudo aptfile path/to/your/aptfile
# or make the file executable and run it directly
chmod +x path/to/your/aptfile
sudo ./aptfile
And you'll see the following lovely output:
Running update
[NEW] package build-essential
[NEW] package git-core
[NEW] package software-properties-common
[NEW] ppa fkrull/deadsnakes-python2.7
[NEW] package python2.7
[NEW] package python-pip
[NEW] package python-dev
[OK] set debconf line: mysql mysql-server/root_password password root
[OK] set debconf line: mysql mysql-server/root_password_again password root
[NEW] package mysql-server
🚀 ALL GOOD TO GO
Note that aptfile
runs uses --force-confnew
- it will forcibly use the package's version of a conf file if a conflict is found.
You can use any of the following primitives when creating your service's aptfile:
Runs apt-get update:
update
Installs a single package:
package "git-core"
Installs an aptitude repository via add-apt-repository
:
repository "deb http://us.archive.ubuntu.com/ubuntu/ saucy universe multiverse"
repository "ppa:mozillateam/firefox-next"
The preferred method for installing a ppa as it properly handles not re-running add-apt-repository
:
ppa "mozillateam/firefox-next"
Allows you to set a debconf selection:
debconf_selection "mysql mysql-server/root_password password root"
These helper functions can be used inside your custom aptfile.
Logs a message to standard error and exits. If this is called, the full output from the dpkg calls will be output as well for further inspection.
log_fail "Unable to find the proper package version"
Outputs a message to stdout.
log_info "🚀 ALL GOOD TO GO"