d51f8050cd
Script changes to download content by layer. Valid options are 'all', 'compiler', 'distro', 'flock'. Current .lst and yum files under directory centos-mirror-tools are relocated. Generic package dependencies are relocated to centos-mirror-tools/config/<os>/<layer>/ . Lst entries for compilable content have been relocated to other git repos by prior updates. i.e. those that list tarballs or srpms to be compiled within that repo. The original .lst files are deleted to make it easier to identify new content during development. Layer 'all' builds all layers in a single workspace. The lst files are identical to current content, minus the src.rpm and tarball entries. Other layers get only a subset of packages download. The minimum required to build the layer. The 'flock' layer will have additional content to satisfy the run time requirements as well as the build time requirements. An upper layer does not need to list rpms known to be provided by a lower layer. Instead the config file 'required_layer_pkgs.cfg' lists urls for lst files for lower layer build outputs. These build outputs are generated and published by cengn for each layer. A second layer config file, 'required_layer_iso_inc.cfg' lists image.inc files for lower layer builds. These build outputs are generated and published by cengn for each layer, summarizing the image.inc files found in individual git repos. Image.inc files inform the build-iso process, listing rpms that that provide services and commands that need to be included in the iso. The transitive list of required rpms need not be listed. Finally the layer config should include a yum.repos.d directory in which supplementary yum repos are defined to pick up cengn built content from lower layers. To allow a designer to do cross-layer building using local sources rather than those provided by CENGN, there are several options. The designer can modify the urls for lower layer build outputs, as found in the .cfg and .repo files within the config directory 'stx-tools/centos-mirror-tools/config/<distro>/<layer-to-build>' directly within the git. Substitute urls can use the file:/// syntax. Just be sure to remove these changes before submitting. Alternatively new args have been added to download_mirror.sh, generate-cgcs-centos-repo.sh and commands that override the normal config. The easiest to use is a command argurement that substitutes a new config directory, replacing stx-tools/centos-mirror-tools/config. The intent is for the designer to do a recursive copy of that directory into a side location. make his changes there, outside of git, and provide the path to that directory as an extra arguement to download_mirror.sh and generate-cgcs-centos-repo.sh. e.g. For simplicity I'll only list the 'extra' arguements download_mirror.sh -C <my-config-dir> \ -l <layer> \ ... generate-cgcs-centos-repo.sh --config-dir=<my-config-dir> \ --layer=<layer> \ ... populate_downloads.sh --config-dir=<my-config-dir> \ --layer=<layer> \ ... These arguements can also be suplied via the environment. For the purpose of containerized builds, these arguements should be defined in your localrc. e.g. export STX_CONFIG_DIR=<my-config-dir> export LAYER=<layer> The final alternative is to override things at a more granular level, replacing a single lst file of image.inc file. Here you can replace a single line found in a required_layer_pkgs.cfg or required_layer_iso_inc.cfg file. e.g. We are doing a flock build and want to modify the content picked up from the distro layer's rt build, and that content delivers a service we want in the iso. For simplicity I'll only list the 'extra' arguments ./download_mirror.sh -l flock \ -L distro,rt,file:///<my-distro-workspace>/rt/rpmbuild/RPMS/rpm.lst \ -I distro,std,file:///<my-distro-workspace>/rt/image.inc \ ... generate-cgcs-centos-repo.sh --layer=flock \ --layer-pkg-url=distro,rt,file:///<my-distro-workspace>/rt/rpmbuild/RPMS/rpm.lst \ --layer-inc-url=distro,std,file:////<my-distro-workspace>/rt/image.inc \ ... NOTE: The triplet syntax for a package list url is <lower-layer>,<build-type>,<url-to-rpm.lst> lower-layer: 'compiler', 'distro' build-type: 'std', 'rt', 'installer' Also if 'file:///' syntax is used, a matching change is made to the yum *.repo file. This assumes that the rpm.lst is co-resident with repodata directory, as is the norm for our build outputs. NOTE: The triplet syntax for a image inc url is <lower-layer>,<include-type>,<url-to-image.inc> lower-layer: 'compiler', 'distro' build-type: 'std', 'dev' A typical user is likely only working in the flock layer on the master branch. He should be content to use the compiler and distro layer outputs from cengn. His workflow looks like ... 1, sync code for flock layer $ repo init -u https://opendev.org/starlingx/manifest.git -b master -m flock.xml $ repo sync 2, download rpms for flock layer, and populate a local mirror $ LOCAL_MIRROR=/import/mirrors/starlingx $ cd stx-tools/centos-mirror-tools $ ./download_mirror.sh -n -g -c yum.conf.sample -S -l flock $ cp -r output/stx-r1/CentOS/pike/* $LOCAL_MIRROR/ 3, Prepare a virtual repo and downloads directory for building $ cd ../toCOPY $ ./generate-cgcs-centos-repo.sh --layer=flock $LOCAL_MIRROR $ ./populate_downloads.sh --layer=flock $LOCAL_MIRROR 4, rpm package and iso building $ build-pkgs && build-iso && build-helm-charts.sh Building all layers in a single workspace is still supported, and looks identical to the previous workflow. 1, sync code $ repo init -u https://opendev.org/starlingx/manifest.git -b master $ repo sync 2, download rpms for flock layer, and populate a local mirror $ LOCAL_MIRROR=/import/mirrors/starlingx $ cd stx-tools/centos-mirror-tools $ ./download_mirror.sh -n -g -c yum.conf.sample -S $ cp -r output/stx-r1/CentOS/pike/* $LOCAL_MIRROR/ 3, create repo named "StxCentos7Distro" for building $ cd ../toCOPY $ generate-cgcs-centos-repo.sh $LOCAL_MIRROR $ populate_downloads.sh $LOCAL_MIRROR 4, rpm package and iso building $ build-pkgs && build-iso && build-helm-charts.sh Only a cross-layer developer should setup two or three copies of the building environment, one per layer. We suggest you use seperate shells for each layer, as the various paths (MY_REPO, MY_WORKSPACE ...) need to be unique, Shell 1, compiler layer $ LOCAL_MIRROR=/import/mirrors/starlingx $ LOCAL_CONFIG=<some-dir>/config $ MY_REPO_ROOT_DIR=<some-dir>/layer-compiler $ MY_REPO=$MY_REPO_ROOT_DIR/cgcs-root $ MY_WORKSPACE=$MY_REPO_ROOT_DIR/workspace ... $ mkdir -p $MY_REPO_ROOT_DIR $ cd $MY_REPO_ROOT_DIR $ repo init -u https://opendev.org/starlingx/manifest.git -b master -m compiler.xml $ cd stx-tools/centos-mirror-tools $ cp -r config/* $LOCAL_CONFIG ... edit urls in *.cfg and *.repo files under $LOCAL_CONFIG ... $ ./download_mirror.sh -n -g -c yum.conf.sample -S -C $LOCAL_CONFIG -l compiler $ cp -r output/stx-r1/CentOS/pike/* $LOCAL_MIRROR/ $ cd ../toCOPY $ ./generate-cgcs-centos-repo.sh --config-dir=$LOCAL_CONFIG --layer=compiler $LOCAL_MIRROR $ ./populate_downloads.sh --config-dir=$LOCAL_CONFIG --layer=flock $LOCAL_MIRROR $ build-pkgs Shell 2, distro layer $ LOCAL_MIRROR=/import/mirrors/starlingx $ LOCAL_CONFIG=<some-dir>/config $ MY_REPO_ROOT_DIR=<some-dir>/layer-distro $ MY_REPO=$MY_REPO_ROOT_DIR/cgcs-root $ MY_WORKSPACE=$MY_REPO_ROOT_DIR/workspace ... $ mkdir -p $MY_REPO_ROOT_DIR $ cd $MY_REPO_ROOT_DIR $ repo init -u https://opendev.org/starlingx/manifest.git -b master -m distro.xml $ repo sync $ cd stx-tools/centos-mirror-tools $ ./download_mirror.sh -n -g -c yum.conf.sample -S -C $LOCAL_CONFIG -l distro $ cp -r output/stx-r1/CentOS/pike/* $LOCAL_MIRROR/ $ cd ../toCOPY $ ./generate-cgcs-centos-repo.sh --config-dir=$LOCAL_CONFIG --layer=distro $LOCAL_MIRROR $ ./populate_downloads.sh --config-dir=$LOCAL_CONFIG --layer=flock $LOCAL_MIRROR $ build-pkgs Shell 3, flock layer $ LOCAL_MIRROR=/import/mirrors/starlingx $ LOCAL_CONFIG=<some-dir>/config $ MY_REPO_ROOT_DIR=<some-dir>/layer-flock $ MY_REPO=$MY_REPO_ROOT_DIR/cgcs-root $ MY_WORKSPACE=$MY_REPO_ROOT_DIR/workspace ... $ mkdir -p $MY_REPO_ROOT_DIR $ cd $MY_REPO_ROOT_DIR $ repo init -u https://opendev.org/starlingx/manifest.git -b master -m flock.xml $ repo sync $ cd stx-tools/centos-mirror-tools $ ./download_mirror.sh -n -g -c yum.conf.sample -S -C $LOCAL_CONFIG -l flock $ cp -r output/stx-r1/CentOS/pike/* $LOCAL_MIRROR/ $ cd ../toCOPY $ ./generate-cgcs-centos-repo.sh --config-dir=$LOCAL_CONFIG --layer=flock $LOCAL_MIRROR $ ./populate_downloads.sh --config-dir=$LOCAL_CONFIG --layer=flock $LOCAL_MIRROR $ build-pkgs && build-iso && build-helm-charts.sh Story: 2006166 Task: 37103 Depends-On: https://review.opendev.org/698756 Depends-On: https://review.opendev.org/700819 Depends-On: https://review.opendev.org/700821 Change-Id: I088020b81f08656e50aa29b5584bbc1dd1378f12 Signed-off-by: Scott Little <scott.little@windriver.com>
454 lines
15 KiB
Bash
Executable File
454 lines
15 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# Copyright (C) 2019 Intel Corporation
|
|
#
|
|
|
|
# The build of StarlingX relies, besides RPM Binaries and Sources, in this
|
|
# repository which is a collection of packages in the form of Tar Compressed
|
|
# files and 3 RPMs obtained from a Tar Compressed file. This script and a text
|
|
# file containing a list of packages enable their download and the creation
|
|
# of the repository based in common and specific requirements dictated
|
|
# by the StarlingX building system recipes.
|
|
|
|
# input files:
|
|
# The file tarball-dl.lst contains the list of packages and artifacts for
|
|
# building this sub-mirror.
|
|
tarball_file=""
|
|
|
|
set -x
|
|
DL_TARBALL_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )"
|
|
|
|
source $DL_TARBALL_DIR/url_utils.sh
|
|
source $DL_TARBALL_DIR/utils.sh
|
|
|
|
usage () {
|
|
echo "$0 [-D <distro>] [-s|-S|-u|-U] [-h] <path_to_tarball_dl.lst>"
|
|
}
|
|
|
|
# Permitted values of dl_source
|
|
dl_from_stx_mirror="stx_mirror"
|
|
dl_from_upstream="upstream"
|
|
dl_from_stx_then_upstream="$dl_from_stx_mirror $dl_from_upstream"
|
|
dl_from_upstream_then_stx="$dl_from_upstream $dl_from_stx_mirror"
|
|
|
|
# Download from what source?
|
|
# dl_from_stx_mirror = StarlingX mirror only
|
|
# dl_from_upstream = Original upstream source only
|
|
# dl_from_stx_then_upstream = Either source, STX prefered (default)"
|
|
# dl_from_upstream_then_stx = Either source, UPSTREAM prefered"
|
|
dl_source="$dl_from_stx_then_upstream"
|
|
dl_flag=""
|
|
|
|
distro="centos"
|
|
|
|
MULTIPLE_DL_FLAG_ERROR_MSG="Error: Please use only one of: -s,-S,-u,-U"
|
|
|
|
multiple_dl_flag_check () {
|
|
if [ "$dl_flag" != "" ]; then
|
|
echo "$MULTIPLE_DL_FLAG_ERROR_MSG"
|
|
usage
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Parse out optional arguments
|
|
while getopts "D:hsSuU" o; do
|
|
case "${o}" in
|
|
D)
|
|
distro="${OPTARG}"
|
|
;;
|
|
|
|
s)
|
|
# Download from StarlingX mirror only. Do not use upstream sources.
|
|
multiple_dl_flag_check
|
|
dl_source="$dl_from_stx_mirror"
|
|
dl_flag="-s"
|
|
;;
|
|
S)
|
|
# Download from StarlingX mirror only. Do not use upstream sources.
|
|
multiple_dl_flag_check
|
|
dl_source="$dl_from_stx_then_upstream"
|
|
dl_flag="-S"
|
|
;;
|
|
u)
|
|
# Download from upstream only. Do not use StarlingX mirror.
|
|
multiple_dl_flag_check
|
|
dl_source="$dl_from_upstream"
|
|
dl_flag="-u"
|
|
;;
|
|
U)
|
|
# Download from upstream only. Do not use StarlingX mirror.
|
|
multiple_dl_flag_check
|
|
dl_source="$dl_from_upstream_then_stx"
|
|
dl_flag="-U"
|
|
;;
|
|
h)
|
|
# Help
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
shift $((OPTIND-1))
|
|
tarball_file="${1}"
|
|
shift
|
|
|
|
|
|
if [ ! -e $tarball_file ]; then
|
|
echo "$tarball_file does not exist, please have a check!"
|
|
exit -1
|
|
fi
|
|
|
|
# The 2 categories we can divide the list of packages in the output directory:
|
|
# - General hosted under "downloads" output directory.
|
|
# - Puppet hosted under "downloads/puppet" output directory.
|
|
# to be populated under $MY_REPO/addons/wr-cgcs/layers/cgcs/downloads/puppet
|
|
|
|
export DL_MIRROR_LOG_DIR="${DL_MIRROR_LOG_DIR:-./logs}"
|
|
export DL_MIRROR_OUTPUT_DIR="${DL_MIRROR_OUTPUT_DIR:-./output/stx-r1/CentOS/pike}"
|
|
|
|
logs_dir="${DL_MIRROR_LOG_DIR}"
|
|
output_log="$logs_dir/log_download_tarball_missing.txt"
|
|
output_path="${DL_MIRROR_OUTPUT_DIR}"
|
|
output_tarball=$output_path/downloads
|
|
output_puppet=$output_tarball/puppet
|
|
|
|
mkdir -p $output_tarball
|
|
mkdir -p $output_puppet
|
|
if [ ! -d "$logs_dir" ]; then
|
|
mkdir "$logs_dir"
|
|
fi
|
|
|
|
is_tarball() {
|
|
local tarball_name="$1"
|
|
local mime_type
|
|
local types=("gzip" "x-bzip2" "x-rpm" "x-xz" "x-gzip" "x-tar")
|
|
local FOUND=1
|
|
|
|
mime_type=$(file --mime-type -b $tarball_name | cut -d "/" -f 2)
|
|
for t in "${types[@]}"; do
|
|
if [ "$mime_type" == "$t" ]; then
|
|
FOUND=0
|
|
break;
|
|
fi
|
|
done
|
|
return $FOUND
|
|
}
|
|
|
|
# Download function using wget command
|
|
|
|
download_package() {
|
|
local tarball_name="$1"
|
|
local upstream_url="$2"
|
|
local stx_url=""
|
|
local url=""
|
|
local rc=1
|
|
|
|
stx_url="$(url_to_stx_mirror_url "$upstream_url" "$distro")"
|
|
|
|
for dl_src in $dl_source; do
|
|
case $dl_src in
|
|
$dl_from_stx_mirror)
|
|
url="$stx_url"
|
|
;;
|
|
$dl_from_upstream)
|
|
url="$upstream_url"
|
|
;;
|
|
*)
|
|
echo "Error: Unknown dl_source '$dl_src'"
|
|
continue
|
|
;;
|
|
esac
|
|
|
|
wget --spider "$url"
|
|
if [ $? != 0 ]; then
|
|
echo "Warning: '$url' is broken"
|
|
else
|
|
wget -q -t 5 --wait=15 -O "$tarball_name" "$url"
|
|
if [ $? -eq 0 ]; then
|
|
if is_tarball "$tarball_name"; then
|
|
echo "Ok: $download_path"
|
|
rc=0
|
|
break
|
|
else
|
|
echo "Warning: File from '$url' is not a tarball"
|
|
\rm "$tarball_name"
|
|
rc=1
|
|
fi
|
|
else
|
|
echo "Warning: failed to download '$url'"
|
|
continue
|
|
fi
|
|
fi
|
|
done
|
|
|
|
if [ $rc != 0 ]; then
|
|
echo "Error: failed to download '$upstream_url'"
|
|
echo "$upstream_url" > "$output_log"
|
|
fi
|
|
|
|
return $rc
|
|
}
|
|
|
|
# This script will iterate over the tarball.lst text file and execute specific
|
|
# tasks based on the name of the package:
|
|
|
|
error_count=0;
|
|
|
|
for line in $(cat $tarball_file); do
|
|
|
|
# A line from the text file starting with "#" character is ignored
|
|
|
|
if [[ "$line" =~ ^'#' ]]; then
|
|
echo "Skip $line"
|
|
continue
|
|
fi
|
|
|
|
# The text file contains 3 columns separated by a character "#"
|
|
# - Column 1, name of package including extensions as it is referenced
|
|
# by the build system recipe, character "!" at the beginning of the name package
|
|
# denotes special handling is required tarball_name=`echo $line | cut -d"#" -f1-1`
|
|
# - Column 2, name of the directory path after it is decompressed as it is
|
|
# referenced in the build system recipe.
|
|
# - Column 3, the URL for the file or git to download
|
|
# - Column 4, download method, one of
|
|
# http - download a simple file
|
|
# http_filelist - download multiple files by appending a list of subpaths
|
|
# to the base url. Tar up the lot.
|
|
# http_script - download a simple file, run script whos output is a tarball
|
|
# git - download a git, checkout branch and tar it up
|
|
# git_script - download a git, checkout branch, run script whos output is a tarball
|
|
#
|
|
# - Column 5, utility field
|
|
# If method is git or git_script, this is a branch,tag,sha we need to checkout
|
|
# If method is http_filelist, this is the path to a file containing subpaths.
|
|
# Subpaths are appended to the urls and downloaded.
|
|
# Otherwise unused
|
|
# - Column 6, Path to script.
|
|
# Not yet supported.
|
|
# Intent is to run this script to produce the final tarball, replacing
|
|
# all the special case code currently embedded in this script.
|
|
|
|
tarball_name=$(echo $line | cut -d"#" -f1-1)
|
|
directory_name=$(echo $line | cut -d"#" -f2-2)
|
|
tarball_url=$(echo $line | cut -d"#" -f3-3)
|
|
method=$(echo $line | cut -d"#" -f4-4)
|
|
util=$(echo $line | cut -d"#" -f5-5)
|
|
script=$(echo $line | cut -d"#" -f6-6)
|
|
|
|
# Remove leading '!' if present
|
|
tarball_name="${tarball_name//!/}"
|
|
|
|
# - For the General category and the Puppet category:
|
|
# - Packages have a common process: download, decompressed,
|
|
# change the directory path and compressed.
|
|
|
|
if [[ "$line" =~ ^pupp* ]]; then
|
|
download_path=$output_puppet/$tarball_name
|
|
download_directory=$output_puppet
|
|
else
|
|
download_path=$output_tarball/$tarball_name
|
|
download_directory=$output_tarball
|
|
fi
|
|
|
|
if [ -e $download_path ]; then
|
|
echo "Already have $download_path"
|
|
continue
|
|
fi
|
|
|
|
# We have 6 packages from the text file starting with the character "!":
|
|
# they require special handling besides the common process: remove directory,
|
|
# remove text from some files, clone a git repository, etc.
|
|
|
|
if [[ "$line" =~ ^'!' ]]; then
|
|
echo $tarball_name
|
|
pushd $output_tarball > /dev/null
|
|
if [ "$tarball_name" = "integrity-kmod-e6aef069.tar.gz" ]; then
|
|
download_package "$tarball_name" "$tarball_url"
|
|
if [ $? -ne 0 ]; then
|
|
error_count=$((error_count + 1))
|
|
popd > /dev/null # pushd $output_tarball
|
|
continue
|
|
fi
|
|
|
|
tar xf "$tarball_name"
|
|
rm "$tarball_name"
|
|
mv linux-tpmdd-e6aef06/security/integrity/ $directory_name
|
|
tar czvf $tarball_name $directory_name
|
|
rm -rf linux-tpmdd-e6aef06
|
|
elif [ "$tarball_name" = "mariadb-10.1.28.tar.gz" ]; then
|
|
download_package "$tarball_name" "$tarball_url"
|
|
if [ $? -ne 0 ]; then
|
|
error_count=$((error_count + 1))
|
|
popd > /dev/null # pushd $output_tarball
|
|
continue
|
|
fi
|
|
|
|
mkdir $directory_name
|
|
tar xf $tarball_name --strip-components 1 -C $directory_name
|
|
rm $tarball_name
|
|
pushd $directory_name > /dev/null
|
|
rm -rf storage/tokudb
|
|
rm ./man/tokuft_logdump.1 ./man/tokuftdump.1
|
|
sed -e s/tokuft_logdump.1//g -i man/CMakeLists.txt
|
|
sed -e s/tokuftdump.1//g -i man/CMakeLists.txt
|
|
popd > /dev/null
|
|
tar czvf $tarball_name $directory_name
|
|
rm -rf $directory_name
|
|
popd > /dev/null # pushd $directory_name
|
|
elif [[ "$tarball_name" = 'MLNX_OFED_SRC-4.5-1.0.1.0.tgz' ]]; then
|
|
srpm_path="${directory_name}/SRPMS/"
|
|
download_package "$tarball_name" "$tarball_url"
|
|
if [ $? -ne 0 ]; then
|
|
error_count=$((error_count + 1))
|
|
popd > /dev/null # pushd $output_tarball
|
|
continue
|
|
fi
|
|
|
|
tar -xf "$tarball_name"
|
|
cp "${srpm_path}/mlnx-ofa_kernel-4.5-OFED.4.5.1.0.1.1.gb4fdfac.src.rpm" .
|
|
cp "${srpm_path}/rdma-core-45mlnx1-1.45101.src.rpm" .
|
|
cp "${srpm_path}/libibverbs-41mlnx1-OFED.4.5.0.1.0.45101.src.rpm" .
|
|
# Don't delete the original MLNX_OFED_LINUX tarball.
|
|
# We don't use it, but it will prevent re-downloading this file.
|
|
# rm -f "$tarball_name"
|
|
|
|
rm -rf "$directory_name"
|
|
elif [ "$tarball_name" = "qat1.7.l.4.5.0-00034.tar.gz" ]; then
|
|
download_package "$tarball_name" "$tarball_url"
|
|
if [ $? -ne 0 ]; then
|
|
error_count=$((error_count + 1))
|
|
popd > /dev/null # pushd $output_tarball
|
|
continue
|
|
fi
|
|
|
|
elif [ "$tarball_name" = "tpm-kmod-e6aef069.tar.gz" ]; then
|
|
download_package "$tarball_name" "$tarball_url"
|
|
if [ $? -ne 0 ]; then
|
|
error_count=$((error_count + 1))
|
|
popd > /dev/null # pushd $output_tarball
|
|
continue
|
|
fi
|
|
|
|
tar xf "$tarball_name"
|
|
rm "$tarball_name"
|
|
mv linux-tpmdd-e6aef06/drivers/char/tpm $directory_name
|
|
tar czvf $tarball_name $directory_name
|
|
rm -rf linux-tpmdd-e6aef06
|
|
rm -rf $directory_name
|
|
elif [ "$tarball_name" = "tss2-930.tar.gz" ]; then
|
|
dest_dir=ibmtpm20tss-tss
|
|
for dl_src in $dl_source; do
|
|
case $dl_src in
|
|
$dl_from_stx_mirror)
|
|
url="$(url_to_stx_mirror_url "$tarball_url" "$distro")"
|
|
;;
|
|
$dl_from_upstream)
|
|
url="$tarball_url"
|
|
;;
|
|
*)
|
|
echo "Error: Unknown dl_source '$dl_src'"
|
|
continue
|
|
;;
|
|
esac
|
|
|
|
git clone $url $dest_dir
|
|
if [ $? -eq 0 ]; then
|
|
# Success
|
|
break
|
|
else
|
|
echo "Warning: Failed to git clone from '$url'"
|
|
continue
|
|
fi
|
|
done
|
|
|
|
if [ ! -d $dest_dir ]; then
|
|
echo "Error: Failed to git clone from '$tarball_url'"
|
|
echo "$tarball_url" > "$output_log"
|
|
error_count=$((error_count + 1))
|
|
popd > /dev/null # pushd $output_tarball
|
|
continue
|
|
fi
|
|
|
|
pushd $dest_dir > /dev/null
|
|
branch=$util
|
|
git checkout $branch
|
|
rm -rf .git
|
|
popd > /dev/null
|
|
mv ibmtpm20tss-tss $directory_name
|
|
tar czvf $tarball_name $directory_name
|
|
rm -rf $directory_name
|
|
popd > /dev/null # pushd $dest_dir
|
|
fi
|
|
popd > /dev/null # pushd $output_tarball
|
|
continue
|
|
fi
|
|
|
|
if [ -e $download_path ]; then
|
|
echo "Already have $download_path"
|
|
continue
|
|
fi
|
|
|
|
for dl_src in $dl_source; do
|
|
case $dl_src in
|
|
$dl_from_stx_mirror)
|
|
url="$(url_to_stx_mirror_url "$tarball_url" "$distro")"
|
|
;;
|
|
$dl_from_upstream)
|
|
url="$tarball_url"
|
|
;;
|
|
*)
|
|
echo "Error: Unknown dl_source '$dl_src'"
|
|
continue
|
|
;;
|
|
esac
|
|
|
|
download_cmd="wget -q -t 5 --wait=15 $url -O $download_path"
|
|
|
|
if $download_cmd ; then
|
|
if ! is_tarball "$download_path"; then
|
|
echo "Warning: file from $url is not a tarball."
|
|
\rm "$download_path"
|
|
continue
|
|
fi
|
|
echo "Ok: $download_path"
|
|
pushd $download_directory > /dev/null
|
|
directory_name_original=$(tar -tf $tarball_name | head -1 | cut -f1 -d"/")
|
|
if [ "$directory_name" != "$directory_name_original" ]; then
|
|
mkdir -p $directory_name
|
|
tar xf $tarball_name --strip-components 1 -C $directory_name
|
|
tar -czf $tarball_name $directory_name
|
|
rm -r $directory_name
|
|
fi
|
|
popd > /dev/null
|
|
break
|
|
else
|
|
echo "Warning: Failed to download $url" 1>&2
|
|
continue
|
|
fi
|
|
done
|
|
|
|
if [ ! -e $download_path ]; then
|
|
echo "Error: Failed to download $tarball_url" 1>&2
|
|
echo "$tarball_url" > "$output_log"
|
|
error_count=$((error_count + 1))
|
|
fi
|
|
done
|
|
|
|
# End of file
|
|
|
|
if [ $error_count -ne 0 ]; then
|
|
echo ""
|
|
echo "Encountered $error_count errors"
|
|
exit 1
|
|
fi
|
|
|
|
exit 0
|