File snap.sh of Package rustc-stage0

#!/bin/bash
#
# Script to update shapshot urls from src/snapshot.txt file
#
# Copyright (2015) Michal Vyskocil <michal.vyskocil@opensuse.org>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

set -e

die() {
    echo ${@} >&2
    exit 1
}

STATIC_URL="http://static.rust-lang.org/stage0-snapshots/rust-stage0"

RUSTC_DIR=${1}
[[ -n ${RUSTC_DIR} ]] || die "Need to specify rustc source dir"
[[ -d ${RUSTC_DIR} ]] || die "Can't find RUSTC_DIR '${RUSTC_DIR}'"
[[ -f rustc.spec ]] || die "Can't find rustc.spec"
[[ -f ${RUSTC_DIR}/src/snapshots.txt ]] || die "Can't find '${RUSTC_DIR}/src/snapshots.txt '"

# read the date and hash from the first line
read -r foo DATE HASH <<< $( head -n1 ${RUSTC_DIR}/src/snapshots.txt )

# Source1, x86_64
read -r ARCH LONG_HASH <<< $(grep -m1 'linux-x86_64' ${RUSTC_DIR}/src/snapshots.txt)
sed -i -e "s@Source1:.*@Source1:        ${STATIC_URL}-${DATE}-${HASH}-${ARCH}-${LONG_HASH}.tar.bz2@" rustc.spec

# Source2, i386
read -r ARCH LONG_HASH <<< $(grep -m1 'linux-i386' ${RUSTC_DIR}/src/snapshots.txt)
sed -i -e "s@Source2:.*@Source2:        ${STATIC_URL}-${DATE}-${HASH}-${ARCH}-${LONG_HASH}.tar.bz2@" rustc.spec
openSUSE Build Service is sponsored by