#!/bin/sh # dl-lp-chroot - download a chroot tarball from Launchpad # Copyright (C) 2010 Loïc Minier # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # SOFTWARE IN THE PUBLIC INTEREST, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the author shall not be used # in advertising or otherwise to promote the sale, use or other dealings in # this Software without prior written authorization from the author. # # depends: wget set -e self="$(basename "$0")" arch="`dpkg --print-architecture`" dist="`lsb_release -cs`" output_file="" usage() { echo "Usage: $self [--arch ] [--dist ] [-O output-file]" >&2 } die() { echo "$*" >&2 exit 1 } if ! which wget >/dev/null; then die "Please install wget" fi while [ $# -gt 0 ]; do case "$1" in --help) usage exit 0 ;; --arch) arch="$2" if [ -z "$arch" ]; then die "Empty arch argument" fi shift 2 ;; --dist) dist="$2" if [ -z "$dist" ]; then die "Empty dist argument" fi shift 2 ;; -O) output_file="$2" if [ -z "$output_file" ]; then die "Empty output file argument" fi shift 2 ;; *) die "Unknown argument $1" ;; esac done chroot_url="`wget -q -O - "https://launchpad.net/api/devel/ubuntu/$dist/$arch/chroot_url" | tr -d '"'`" exec wget ${output_file:+-O "$output_file"} "$chroot_url"