Code Monkey home page Code Monkey logo

bis's Introduction

Bis (Build Install Script)

Bis is a wrapper for bash meant to help automate compilation and installation of software in a consistent way while remaining flexible and simple. It was originally written to replace use of rpmbuild in an environment that was not interested in actually creating package files. The is that bis would implement some of the needed features without its more distribution-oriented restrictions.

The basic usage of bis is bis build-script.bis where build-script.bis is a filename in the form of alternating (name, version) pairs delimited with dashes. Bis will:

  • Export several build-related bash functions, documented below.
  • Split the filename into tokens on hyphens (-)
  • Set $NAME to the first token and $VERSION to the second token. NAME{2,3} and VERSION{2,3} are set for additional tokens.
  • Invoke the script as a bash function with all of tokens passed as arguments ($@) so that the NAME and VERSION variables can be fixed manually if necessary.

Bis expects $INSTALL_ROOT and $SOURCES to be defined prior to script invocation. This means the tool invoking the script (eg Jenkins) can set INSTALL_ROOT based on whether it is a production build or not.

A simple bis script might look like this:

Filename: hello-0.0.1-generic.bis

SUMMARY="Hello, World"

#Set important variables based on environment and filename (including $INSTALL_DIR)
# also creates and cds to $WORKSPACE at $HOME/.bis/workspace/hello-0.0.1-generic
bis-init

# Clean and unpack source into workspace
# Determins $UNPACKPATH and cds to it
# $HOME/.bis/workspace/hello-0.0.1-generic/hello-0.0.1
bis-unpack

./configure --prefix=$INSTALL_DIR
make
make install

# Write a bis-install.txt and append to bis-install.log
bis-finish

Variables

Variables set to a default value, intended to be overridden by calling environment

  • INSTALL_ROOT - Root directory for all installations. Should be set in environment. ($HOME/opt)
  • SOURCES - Path to source repository. Should be set in environment. ($HOME/src)
  • WORKSPACE_ROOT - Path to build workspace directory. Source tarballs will be unpacked to this directory. ($HOME/.bis/workspace)

Set by bis before script is called.

  • FULLNAME - Full name of the file, without the .bis extension. Set by bis before invoking the script. (python-2.7.14-gcc-6.2.0)
  • WORKSPACE - Set by bis to $WORKSPACE_ROOT/$FULLNAME ($HOME/.bis/workspace/python-2.7.14-gcc-6.2.0)
  • NAME - Name of the application. Set by bis to the first token in filename. (python)
  • VERSION - Version of the application, the second token in the filename (2.7.14)
  • NAME2 - Name of compiler, etc. Third filename token (gcc)
  • VERSION2 - Version of compiler, etc. Fourth filename token. (6.2.0)

Set by bis-init.

  • SOURCE_FILENAME - The base filename of the source tarball. Set by bis-init to $NAME-$VERSION.$extension, where extension is determined by searching $SOURCES for supported archive formats. (python-2.7.14.tgz)
  • SOURCE - The full path to the source tarball. Set to $SOURCES/$SOURCE_FILENAME. ($HOME/src/python-2.7.14.tgz)
  • INSTALL_DIR - Install prefix for the application. Set by bis-init to $INSTALL_ROOT/$NAME/$VERSION ($HOME/opt/python/2.7.14)
  • UNPACKPATH - Inspects the $SOURCE archive to see if it extracts to a single directory. If the archive has multiple directories or files in its root, UNPACKPATH is set to WORKSPACE. ($HOME/.bis/workspace/python-2.7.14-gcc-6.2.0/Python-2.7.14)

Not set by anything, but may be used.

  • BUIlD_OWNER - used by bis-finish when writing bis-install.log
  • DESCRIPTION - used by bis-finish when writing bis-install.txt
  • SUMMARY - used by bis-finish when writing bis-install.txt

Functions

bis-description

bis-description <<<EOF
Description of the application
goes here.
EOF

Wrapper function to set $DESCRIPTION using HEREDOC syntax without messy with cat or pipes. Still kind of ugly, but it's just metadata.

bis-init

bis-init [no-cd-to-workspace]

Call this first, unless you need to override any of the values it sets. After setting environment variables, bis-init changes the working directory to $WORKSPACE, unless no-cd-to-workspace is passed.

bis-verify

Checks to see if important variables are defined, and that the source package exists.

bis-unpack

bis-unpack

Removes $UNPACKPATH if it exists, then decompresses and untars $SOURCE to $WORKSPACE.

When finished, changes working directory to $UNPACKPATH.

bis-clean

bis-clean [just-make-clean]

Does rm -rf $UNPACKPATH, unless just-make-clean is passed, in which case it cds to $UNPACKPATH and runs make clean.

bis-show-vars

bis-show-vars

Echo all variables with values to standard output.

bis-finish

bis-finish

Writes an info file and logfile to the $INSTALL_DIR.

bis-determine-unpackdir

bis-determine-unpackdir <archive-file>

Attempts to determine the directory the given archive file extracts to. If multiple files or directories are found in the root of the archive, this retuns nothing.

bis-set-unpack-path

bis-set-unpack-path

Sets $UNPACKPATH to $WORKSPACE/$(bis-determine-unpackdir $SOURCE).

bis's People

Contributors

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