Skip to content

Commit

Permalink
Add a bash script that installs Madoko on Ubuntu Linux systems
Browse files Browse the repository at this point in the history
  • Loading branch information
jafingerhut committed Nov 6, 2018
1 parent 237bc9f commit 4f73073
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
7 changes: 7 additions & 0 deletions p4-16/psa/README.md
@@ -1,5 +1,12 @@
# Portable Switch Architecture

## Setup instructions

See the [README](../spec/README.md) for the P4_16 language
specification for instructions on installing software that enables you
to produce HTML and PDF versions of the PSA specification from its
Madoko source file.

## Spec release process
- increment version number in the document and commit
- merge to master and tag the commit with psa-version (e.g. psa-v0.9)
Expand Down
8 changes: 8 additions & 0 deletions p4-16/spec/README.md
Expand Up @@ -49,13 +49,21 @@ install them on a Mac using Font Book:
UtopiaStd-Regular.otf
luximr.ttf
```

### Linux

Follow the instruction below by hand, or for an Ubuntu 16.04 or 18.04
system, you may use the bash script
[`setup-for-ubuntu-linux.sh`](setup-for-ubuntu-linux.sh) to install
the necessary packages and fonts for you.

```
sudo apt-get install nodejs
sudo npm install madoko -g
make
```
In particular (on Ubuntu 16.04 at least), don't try `sudo apt-get install npm` because `npm` is already included and this will yield a bunch of confusing error messages from `apt-get`.

### Windows

You need to install miktex [http://miktex.org/], madoko
Expand Down
81 changes: 81 additions & 0 deletions p4-16/spec/setup-for-ubuntu-linux.sh
@@ -0,0 +1,81 @@
#! /bin/bash

echo "------------------------------------------------------------"
echo "Purpose of this script:"
echo ""
echo "On an Ubuntu 16.04 or 18.04 Linux system that has not had any"
echo "additional packages installed yet, install a set of packages"
echo "that are needed to successfully create the HTML and PDF versions"
echo "of these documents from their Madoko source files (files with"
echo "names that end with '.mdk'):"
echo ""
echo "+ The P4_16 language specification"
echo "+ The Portable Switch Architecture (PSA) specification"
echo ""
echo "While it would be nice if I could assure you that this script"
echo "will work on an Ubuntu system that already had many packages"
echo "installed, I do not know which Ubuntu packages might have"
echo "conflicts with each other."
echo "------------------------------------------------------------"

# This is where the application gnome-font-viewer copies font files
# when a user clicks the "Install" button.
FONT_INSTALL_DIR="${HOME}/.local/share/fonts"

warning() {
1>&2 echo "This script has only been tested on Ubuntu 16.04 and"
1>&2 echo "Ubuntu 18.04 so far."
}

lsb_release >& /dev/null
if [ $? != 0 ]
then
1>&2 echo "No 'lsb_release' found in your command path."
warning
exit 1
fi

DISTRIBUTOR_ID=`lsb_release -si`
UBUNTU_RELEASE=`lsb_release -sr`

if [ ${DISTRIBUTOR_ID} != "Ubuntu" -o ${UBUNTU_RELEASE} != "16.04" ]
then
warning
1>&2 echo ""
1>&2 echo "Here is what command 'lsb_release -a' shows this OS to be:"
lsb_release -a
exit 1
fi

set -ex

# Common packages to install on both Ubuntu 16.04 and 18.04
sudo apt-get install git curl make nodejs npm texlive-xetex dvipng

if [[ "${UBUNTU_RELEASE}" > "18" ]]
then
# Only needed for Ubuntu 18.04
sudo apt-get install texlive-science
else
# Only needed for Ubuntu 16.04
sudo apt-get install nodejs-legacy texlive-generic-extra texlive-math-extra
fi

# Common package to install on both Ubuntu 16.04 and 18.04
sudo npm install madoko -g

# After install of the packages above, this command often seems to
# help reduce the disk space used by a gigabyte or so.
sudo apt clean

# On a freshly installed Ubuntu 16.04 system, added about 1.3G to the
# used disk space, although temporarily went about 1 GB more than that
# before 'sudo apt clean'.

# On a freshly installed Ubuntu 18.04 system, added about 0.8G.

# Retrieve and install fonts
curl -fsSL -O https://raw.github.com/p4lang/p4-spec/gh-pages/fonts/UtopiaStd-Regular.otf
curl -fsSL -O https://raw.github.com/p4lang/p4-spec/gh-pages/fonts/luximr.ttf
mkdir -p "${FONT_INSTALL_DIR}"
/bin/mv UtopiaStd-Regular.otf luximr.ttf "${FONT_INSTALL_DIR}"

0 comments on commit 4f73073

Please sign in to comment.