UP

What is UP
Login

What is UP

UpdatePro. No, just kidding. UP started as a set of scripts intended to maintain my collection of favourite software. The designated directories are updated with the latest mainstream versions. Ultimately all these scripts were wrapped in a single command for a more cohesive concept: Behold up command.

Unstructured repository

UP can work on any directory structure. You just need a getversion.sh script on directories you want to check for updates. For downloading updates you can optionally put a update.conf file. That's all.

getversion.sh

This script must query some resource/package's version on the internet. It must print the current mainstream version to stdout. Optionally it can print a second line with the date of release of such version.

The common pattern for this file is:

  wget -O- PACKAGEHOMEPAGE | DO-SOME-PARSING

For example:

  wget -O- PACKAGEHOMEPAGE | grep 'Last version:' | cut -f2

The typical getversion.sh script grabs a package's download page and parses with a oneliner using text processing tools like Cut, Grep, and more sophisticated tools like PUP html parser or Tijeras advanced cut clone.

There is also a github-version.sh utility which can be used in your getversion.sh script to lookup version of software hosted on github. For example:

  github-version.sh https://github.com/someuser/somerepo
  (this utility requires the PUP html parser)

update.conf

This optional file enables the 'update' functionality by declaring which files to download.

Each line can have the following forms:

  DESTDIR get URL [FILENAME]
  DESTDIR parse WEBPAGE URL_GLOB
  DESTDIR cmd SCRIPT

DESTDIR is the directory where such file should be stored. Set to '.' (dot directory) to download in the root or any other subdirectory.

DESTDIR and URL can refer to the $version variable.

The get mode declares a fixed url.

The parse mode allows to parse a webpage with a download url glob expression.

If the first two modes cant express a file you can declare a custom command. This must be a one line valid shell expression.

Examples:

  linux/ get http://myapp.com/download/$version.tgz
  win/ parse http://myapp.com/downloads <a href="*.exe">DOWNLOAD PROGRAM</a>
  mac/$version cmd wget -O- -q http://myapp.com/downloads.html | grep Download | cut -f2