Code Monkey home page Code Monkey logo

bash-aptfile's Introduction

bash-aptfile

a simple method of defining apt-get dependencies for an application

requirements

  • apt-get
  • dpkg

installation

# 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

usage

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"

# install a package from a download url
package_from_url "google-chrome-stable" "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"

# 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
[NEW] package google-chrome-stable
๐Ÿš€ 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.

aptfile primitives

You can use any of the following primitives when creating your service's aptfile:

update

Runs apt-get update:

update

package

Installs a single package:

package "git-core"

package_from_url

Installs a single package from a url:

package_from_url "google-chrome-stable" "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"

packagelist

Installs a multiple packages in one apt call:

packagelist "git-core" "gitsome"

repository

Installs an aptitude repository via add-apt-repository:

repository "deb http://us.archive.ubuntu.com/ubuntu/ saucy universe multiverse"
repository "ppa:mozillateam/firefox-next"

repository_file

Installs an aptitude repository in /etc/apt/sources.list.d:

# Add the exact line to /etc/apt/sources.list.d/google-chrome.list
repository_file "google-chrome" "deb http://dl.google.com/linux/chrome/deb/ stable main"
# without 'deb', suite (defaults to lsb_release -sc) and components (defaults to 'main') are added
# All three lines do the same (on xenial)
repository_file "git-lfs.list" "deb https://packagecloud.io/github/git-lfs/ubuntu/ xenial main"
repository_file "git-lfs.list" "https://packagecloud.io/github/git-lfs/ubuntu/ main"
repository_file "git-lfs.list" "https://packagecloud.io/github/git-lfs/ubuntu/"

ppa

The preferred method for installing a ppa as it properly handles not re-running add-apt-repository:

ppa "mozillateam/firefox-next"

debconf_selection

Allows you to set a debconf selection:

debconf_selection "mysql mysql-server/root_password password root"

helper functions

These helper functions can be used inside your custom aptfile.

log_fail

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"

log_info

Outputs a message to stdout.

log_info "๐Ÿš€ ALL GOOD TO GO"

bash-aptfile's People

Contributors

5nafu avatar ad7six avatar josegonzalez avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.