1#!/bin/bash 2 3########################################################################## 4# Copyright (c) 2010, ETH Zurich. 5# All rights reserved. 6# 7# This file is distributed under the terms in the attached LICENSE file. 8# If you do not find this file, copies can be found by writing to: 9# ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. 10########################################################################## 11 12# exit immediately on error 13set -e 14 15# grab arguments 16SRCDIR="$1" 17ARCHIVE="$2" 18shift 2 19 20TMPDIR=$(mktemp -d) 21 22for src in $*; do 23 # construct destination file name relative to archive dir 24 # $SRCDIR/foo/bar/baz.txt -> skb/bar/baz.txt 25 dst=${src#$SRCDIR/} 26 dst=${dst/icparc_solvers/lib} 27 dst=${dst/Kernel/} 28 dst=skb/$dst 29 30 # ensure target directory exists 31 mkdir -p $TMPDIR/$(dirname $dst) 32 33 # copy to target and add to list 34 cp $src $TMPDIR/$dst 35 echo $dst >> $TMPDIR/files 36done 37 38# run cpio in the temp dir 39cd $TMPDIR 40cpio -o -H crc -O ramfs.cpio < files 41cd "$OLDPWD" 42 43# compress it 44gzip $TMPDIR/ramfs.cpio 45 46# move it to the right place 47mv $TMPDIR/ramfs.cpio.gz $ARCHIVE 48 49# clean up 50rm -rf $TMPDIR 51