#!/bin/bash # Charlemagne Support Functions # # Douglas Thrift # # $Id$ # Copyright 2006 Douglas Thrift # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. function escape() { sed -e 's/\\/\\\\/g;s/\[/\\\[/g;s/\]/\\\]/g;s/\./\\./g;s/\*/\\\*/g;s/\^/\\\^/g;s/\$/\\\$/g' <<<"$@" } function setup_sources() { for ((index = 0; index != ${#sources[*]}; ++index)); do if grep -q '^.*://.*/' <<<${sources[$index]}; then source_files[$index]=`sed -e 's|^.*://.*/||' <<<${sources[$index]}` else source_files[$index]=${sources[$index]} fi done } function rpm_extract() { for rpm in $@; do set `od -j 104 -N 8 -t u1 $rpm` local il=$((256 * (256 * (256 * $2 + $3) + $4) + $5)) dl=$((256 * (256 * (256 * $6 + $7) + $8) + $9)) local sigsize=$((8 + 16 * $il + $dl)) local o=$((104 + $sigsize + (8 - ($sigsize % 8)) % 8 + 8)) set `od -j $o -N 8 -t u1 $rpm` local il=$((256 * (256 * (256 * $2 + $3) + $4) + $5)) dl=$((256 * (256 * (256 * $6 + $7) + $8) + $9)) local hdrsize=$((8 + 16 * $il + $dl)) local o=$(($o + $hdrsize)) dd if=$rpm ibs=$o skip=1 | bsdtar xvf - done } declare -a source_files