Create a gist now

Instantly share code, notes, and snippets.

@Frenzie /README.md
Last active Aug 29, 2015

What would you like to do?
Automated Otter package creation

Auto-packaging Otter

Dependencies

  • virtualbox4.2+
  • vagrant

Usage

  • Install dependencies, for example sudo apt install virtualbox vagrant
  • mkdir otter-jessie64 in the same directory as the scripts
  • Run vagrant up. This will take a while. You'll get a nice collection of Debian source package and 64-bit binary.
  • Run vagrant provision to update stuff. But first clean manually.
  • Run BUILD_DEB_ARGS='-s ~beta' vagrant provision to customize the version.

To-do

  • Vagrant VMs for multiple platforms
  • General improvements
#!/usr/bin/env bash
# i386 dependencies
i386=pbuilder
apt-get update
#takes a long time
#apt-get dist-upgrade -y
echo "Installing dependencies..."
apt-get install -y \
git \
build-essential devscripts ccache \
cmake qtbase5-dev libqt5webkit5-dev qtdeclarative5-dev qtscript5-dev qt5-default qtmultimedia5-dev\
${i386}
# create or update pbuilder stuff
# the first time this'll take a while
if ! pbuilder --update --distribution jessie --architecture i386; then
pbuilder --create --distribution jessie --architecture i386
fi
#!/usr/bin/env bash
## build-otter-deb.sh
# Given the right prerequisites, this script will automatically create Otter
# DEB files.
version=0.1
help="You probably shouldn't be using this if you need help. Sorry. :-)"
echo_help() {
echo "${help}"
exit 1
}
echo_version() {
echo "${version_info}"
exit 1
}
## Process flags
# Thanks to http://stackoverflow.com/a/9899366
# This shows how to handle combined short options along with
# other long and short options. It does so by splitting them
# apart (e.g. 'tar -xvzf ...' -> 'tar -x -v -z -f ...')
while test $# -gt 0
do
case $1 in
# Normal option processing
-h | --help)
# usage and help
echo_help
;;
-v | --version)
# version info
echo_version
;;
-s | --suffix)
if [ -z "$2" ]; then
echo_error "$1 requires a DEB version suffix."
else
VERSION_SUFFIX=$2
shift
fi
;;
# ...
# Special cases
--)
break
;;
--*)
# error unknown (long) option $1
echo_error "unknown (long) option $1"
;;
-?)
# error unknown (short) option $1
echo_error "unknown (short) option $1"
;;
# FUN STUFF HERE:
# Split apart combined short options
-*)
split=$1
shift
set -- "$(echo "$split" | cut -c 2- | sed 's/./-& /g')" "$@"
continue
;;
# Done with options
*)
break
;;
esac
# for testing purposes:
echo "testing $1"
shift
done
cd otter-build
if cd otter >/dev/null; then
git pull
else
git clone https://github.com/Emdek/otter.git
cd otter
fi
DATE=$(date -u +%Y%m%d)
OTTER_VERSION_MAIN=$(grep OTTER_VERSION_MAIN CMakeLists.txt | grep -Eo "([0-9].?)*" | grep -Eo "[^\"]*")
OTTER_VERSION_CONTEXT=$(grep OTTER_VERSION_CONTEXT CMakeLists.txt | grep -Eo "\"([^\"]*)\"" | grep -Eo "[^\"]*")
OTTER_GIT_REVISION=$(git rev-parse --short HEAD)
CPACK_DEBIAN_PACKAGE_SECTION=$(grep CPACK_DEBIAN_PACKAGE_SECTION CMakeLists.txt | grep -Eo "\"([^\"]*)\"" | grep -Eo "[^\"]*")
if [ -n "${VERSION_SUFFIX}" ]; then
OTTER_VERSION=${OTTER_VERSION_MAIN}${VERSION_SUFFIX}
else
OTTER_VERSION=${OTTER_VERSION_MAIN}+${DATE}~git${OTTER_GIT_REVISION}
fi
# Needs something like -1 at the end
OTTER_VERSION_DEBIAN=${OTTER_VERSION}-1
echo $OTTER_VERSION
OTTER_BUILD_DIR=otter-browser-${OTTER_VERSION}
cd ..
cp -r otter ${OTTER_BUILD_DIR}
mv ${OTTER_BUILD_DIR}/packaging/debian ${OTTER_BUILD_DIR}/debian
#rm -r ${OTTER_BUILD_DIR}/packaging
# make changes to packaging
cd ${OTTER_BUILD_DIR}
# change empty message to something more meaningful?
debchange "" --newversion ${OTTER_VERSION_DEBIAN}
# Sanity checks
# Just output warning(s); don't attempt to autofix
SECTION_CHECK="Section: ${CPACK_DEBIAN_PACKAGE_SECTION}"
if ! $(grep "${SECTION_CHECK}" debian/control); then
echo "Expected '${SECTION_CHECK}' but got '$(grep "Section:" debian/control )'"
fi
cd ..
# create source tarballs
tar cfJ otter-browser_${OTTER_VERSION_DEBIAN}.debian.tar.xz -C ${OTTER_BUILD_DIR} debian
tar cfJ otter-browser_${OTTER_VERSION}.orig.tar.xz ${OTTER_BUILD_DIR}
cd ${OTTER_BUILD_DIR}
# unsigned build
debuild -us -uc
# signed build
#debuild -S
cd ..
# Build for i386
pbuilder --build otter-browser_${OTTER_VERSION_DEBIAN}.dsc
cp /var/cache/pbuilder/result/otter-browser_${OTTER_VERSION_DEBIAN}* ./
# figure out cross-compile stuff or run a separate VM?
#debuild -ai386
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Documentation at vagrantup.com.
config.vm.box = "debian/jessie64"
config.vm.box_url = "https://downloads.sourceforge.net/project/vagrantboxjessie/debian80.box"
config.vm.synced_folder "otter-jessie64", "/home/vagrant/otter-build"
config.vm.provision :shell, :path => "bootstrap.sh"
# Call with: BUILD_DEB_ARGS='-s test' vagrant provision
config.vm.provision :shell, :path => "build-otter-deb.sh", args: ENV['BUILD_DEB_ARGS']
config.vm.provider "virtualbox" do |v|
v.cpus = 2
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment