<commit_before>#!/bin/bash

# Stable idempotent part of my config: it rarely changes, and even if it changes
# you can run the script again with no harmful side-effects.

#### HELPERS ####

download_atom ()
{
    local source='/tmp/atom.deb';
    wget -q -O $source https://atom.io/download/deb
}

install_atom ()
{
    local source='/tmp/atom.deb';
    sudo dpkg -i $source;
    rm $source
}

download_docker_ssh ()
{
    local source='/tmp/docker_ssh.tar.gz';
    wget -q -O $source \
         https://github.com/phusion/baseimage-docker/archive/master.tar.gz
}

install_docker_ssh ()
{
    local source='/tmp/docker_ssh.tar.gz';
    tar xzf $source;
    sudo baseimage-docker-master/install-tools.sh;
    rm -rf $source baseimage-docker-master
}

download_font_noto () {
    local source='/tmp/Noto.zip';
    wget -q -O $source https://www.google.com/get/noto/pkgs/Noto.zip
}

install_font_noto ()
{
    local source='/tmp/Noto.zip';
    local target='/usr/share/fonts/Noto';
    sudo rm -rf $target;
    sudo unzip $source -d $target;
    rm $source
}

download_font_powerline ()
{
    local target='/usr/share/fonts/powerline-fonts';
    if [ -d $target ]; then
        ( cd $target; sudo git pull );
    else
        sudo git clone -q --depth 1 \
             https://github.com/Lokaltog/powerline-fonts.git \
             $target;
    fi
}

install_font_powerline () { true; }

download_font_source_code_pro ()
{
    local source='/tmp/source-code-pro.tgz';
    wget -q -O $source \
         https://github.com/adobe-fonts/source-code-pro/archive/1.017R.tar.gz
}

install_font_source_code_pro ()
{
    local source='/tmp/source-code-pro.tgz';
    local target='/usr/share/fonts/source-code-pro';
    sudo rm -rf $target;
    sudo mkdir -p $target;
    sudo tar --strip-components 2 --wildcards -C $target -zxvf $source '*/OTF/*.otf';
    rm $source
}

download_font_source_sans_pro ()
{
    local source='/tmp/source-sans-pro.tgz';
    wget -q -O $source \
         https://github.com/adobe-fonts/source-sans-pro/archive/2.010R-ro/1.065R-it.tar.gz
}

install_font_source_sans_pro ()
{
    local source='/tmp/source-sans-pro.tgz';
    local target='/usr/share/fonts/source-sans-pro';
    sudo rm -rf $target;
    sudo mkdir -p $target;
    sudo tar --strip-components 2 --wildcards -C $target -zxvf $source '*/OTF/*.otf';
    rm $source
}

download_font_source_serif_pro ()
{
    local source='/tmp/source-serif-pro.tgz';
    wget -q -O $source \
         https://github.com/adobe-fonts/source-serif-pro/archive/1.014R.tar.gz
}

install_font_source_serif_pro ()
{
    local source='/tmp/source-serif-pro.tgz';
    local target='/usr/share/fonts/source-serif-pro';
    sudo rm -rf $target;
    sudo mkdir -p $target;
    sudo tar --strip-components 2 --wildcards -C $target -zxvf $source '*/OTF/*.otf';
    rm $source
}

download_lmutil ()
{
    local source='/tmp/lmutil.tgz';
    wget -q -O $source \
         https://www.hex-rays.com/products/ida/support/flexlm/lmutil-x64_lsb-11.12.1.0v6.tar.gz
}

install_lmutil ()
{
    local source='/tmp/lmutil.tgz';
    local target='/usr/local/bin';
    sudo tar -C $target -zxvf $source
}

#### SANITY CHECK ####

# don't bother updating yet
pkill -f /usr/bin/update-manager

#### AUTOPILOT ####

# start custom downloads
download_atom &
download_docker_ssh &
download_font_noto &
download_font_powerline &
download_font_source_code_pro &
download_font_source_sans_pro &
download_font_source_serif_pro &
download_lmutil &

# pull docker baseimage in background (specifically leave out sudo)
docker pull phusion/baseimage:latest > /dev/null &

# uninstall some useless stuff here
# (does not seem productive: leave empty)

# dist-upgrade
sudo apt-get update
sudo apt-get dist-upgrade -y

# apt-file, good to cache (do these two together to avoid dialog box)
sudo apt-get install -y apt-file
sudo apt-file update > /dev/null &

# tier 1: bap + ida + llvm (just building tools) + qira (just exo-docker)
sudo apt-get install -y \
     libgmp-dev                `#zarith` \
     libncurses5-dev           `#ocamlfind` \
     llvm \
     m4                        `#ocamlfind` \
     ocaml \
     opam \
     `#end`
sudo apt-get install -y \
     libqtgui4:i386 \
     `#end`
sudo apt-get install -y \
     cmake \
     ninja-build \
     `#end`
sudo apt-get install -y \
     google-chrome-stable \
     socat \
     `#end`

# tier 2: good stuff that everyone should want in my opinion
sudo apt-get install -y \
     aptitude \
     augeas-tools \
     bash-doc                  `#info bash` \
     curl \
     emacs24 \
     emacs24-el \
     font-manager \
     git \
     git-svn \
     htop \
     kdiff3-qt \
     libxml2-utils             `#xmllint` \
     mercurial \
     moreutils                 `#sponge` \
     mosh \
     ncdu \
     nmap \<commit_msg>lmutil needs lsb to run<commit_after>#!/bin/bash

# Stable idempotent part of my config: it rarely changes, and even if it changes
# you can run the script again with no harmful side-effects.

#### HELPERS ####

download_atom ()
{
    local source='/tmp/atom.deb';
    wget -q -O $source https://atom.io/download/deb
}

install_atom ()
{
    local source='/tmp/atom.deb';
    sudo dpkg -i $source;
    rm $source
}

download_docker_ssh ()
{
    local source='/tmp/docker_ssh.tar.gz';
    wget -q -O $source \
         https://github.com/phusion/baseimage-docker/archive/master.tar.gz
}

install_docker_ssh ()
{
    local source='/tmp/docker_ssh.tar.gz';
    tar xzf $source;
    sudo baseimage-docker-master/install-tools.sh;
    rm -rf $source baseimage-docker-master
}

download_font_noto () {
    local source='/tmp/Noto.zip';
    wget -q -O $source https://www.google.com/get/noto/pkgs/Noto.zip
}

install_font_noto ()
{
    local source='/tmp/Noto.zip';
    local target='/usr/share/fonts/Noto';
    sudo rm -rf $target;
    sudo unzip $source -d $target;
    rm $source
}

download_font_powerline ()
{
    local target='/usr/share/fonts/powerline-fonts';
    if [ -d $target ]; then
        ( cd $target; sudo git pull );
    else
        sudo git clone -q --depth 1 \
             https://github.com/Lokaltog/powerline-fonts.git \
             $target;
    fi
}

install_font_powerline () { true; }

download_font_source_code_pro ()
{
    local source='/tmp/source-code-pro.tgz';
    wget -q -O $source \
         https://github.com/adobe-fonts/source-code-pro/archive/1.017R.tar.gz
}

install_font_source_code_pro ()
{
    local source='/tmp/source-code-pro.tgz';
    local target='/usr/share/fonts/source-code-pro';
    sudo rm -rf $target;
    sudo mkdir -p $target;
    sudo tar --strip-components 2 --wildcards -C $target -zxvf $source '*/OTF/*.otf';
    rm $source
}

download_font_source_sans_pro ()
{
    local source='/tmp/source-sans-pro.tgz';
    wget -q -O $source \
         https://github.com/adobe-fonts/source-sans-pro/archive/2.010R-ro/1.065R-it.tar.gz
}

install_font_source_sans_pro ()
{
    local source='/tmp/source-sans-pro.tgz';
    local target='/usr/share/fonts/source-sans-pro';
    sudo rm -rf $target;
    sudo mkdir -p $target;
    sudo tar --strip-components 2 --wildcards -C $target -zxvf $source '*/OTF/*.otf';
    rm $source
}

download_font_source_serif_pro ()
{
    local source='/tmp/source-serif-pro.tgz';
    wget -q -O $source \
         https://github.com/adobe-fonts/source-serif-pro/archive/1.014R.tar.gz
}

install_font_source_serif_pro ()
{
    local source='/tmp/source-serif-pro.tgz';
    local target='/usr/share/fonts/source-serif-pro';
    sudo rm -rf $target;
    sudo mkdir -p $target;
    sudo tar --strip-components 2 --wildcards -C $target -zxvf $source '*/OTF/*.otf';
    rm $source
}

download_lmutil ()
{
    local source='/tmp/lmutil.tgz';
    wget -q -O $source \
         https://www.hex-rays.com/products/ida/support/flexlm/lmutil-x64_lsb-11.12.1.0v6.tar.gz
}

install_lmutil ()
{
    local source='/tmp/lmutil.tgz';
    local target='/usr/local/bin';
    sudo tar -C $target -zxvf $source
}

#### SANITY CHECK ####

# don't bother updating yet
pkill -f /usr/bin/update-manager

#### AUTOPILOT ####

# start custom downloads
download_atom &
download_docker_ssh &
download_font_noto &
download_font_powerline &
download_font_source_code_pro &
download_font_source_sans_pro &
download_font_source_serif_pro &
download_lmutil &

# pull docker baseimage in background (specifically leave out sudo)
docker pull phusion/baseimage:latest > /dev/null &

# uninstall some useless stuff here
# (does not seem productive: leave empty)

# dist-upgrade
sudo apt-get update
sudo apt-get dist-upgrade -y

# apt-file, good to cache (do these two together to avoid dialog box)
sudo apt-get install -y apt-file
sudo apt-file update > /dev/null &

# tier 1: bap + ida + llvm (just building tools) + qira (just exo-docker)
sudo apt-get install -y \
     libgmp-dev                `#zarith` \
     libncurses5-dev           `#ocamlfind` \
     llvm \
     m4                        `#ocamlfind` \
     ocaml \
     opam \
     `#end`
sudo apt-get install -y \
     libqtgui4:i386 \
     `#end`
sudo apt-get install -y \
     cmake \
     ninja-build \
     `#end`
sudo apt-get install -y \
     google-chrome-stable \
     socat \
     `#end`

# tier 2: good stuff that everyone should want in my opinion
sudo apt-get install -y \
     aptitude \
     augeas-tools \
     bash-doc                  `#info bash` \
     curl \
     emacs24 \
     emacs24-el \
     font-manager \
     git \
     git-svn \
     htop \
     kdiff3-qt \
     libxml2-utils             `#xmllint` \
     lsb \                     `#lmutil` \
     mercurial \
     moreutils                 `#sponge` \
     mosh \
     ncdu \
     nmap \
{'fraction_non_alphanumeric': 0.1363871368007445, 'fraction_numerical': 0.008892565401716472, 'mean_word_length': 2.3865546218487395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 16, 'lorem ipsum': 0, 'www.': 4, 'xml': 4}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '147163', 'n_tokens_mistral': 3680, 'n_tokens_neox': 3455, 'n_words': 774}