diff options
| author | Michael Neves | 2012-12-18 16:37:38 +0100 |
|---|---|---|
| committer | Michael Neves | 2012-12-18 16:37:38 +0100 |
| commit | 4e50488f299ecc21d7c6f086140b318ce9ceb7f1 (patch) | |
| tree | 8687807fa8a33af935a3fe949b450139cfd72ecc /remote/setup-tools.sh | |
| parent | setuptools all tools argument added (diff) | |
| parent | aufs, squashfs modules for stage3.1 if needed (diff) | |
| download | tm-scripts-4e50488f299ecc21d7c6f086140b318ce9ceb7f1.tar.gz tm-scripts-4e50488f299ecc21d7c6f086140b318ce9ceb7f1.tar.xz tm-scripts-4e50488f299ecc21d7c6f086140b318ce9ceb7f1.zip | |
Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts
Diffstat (limited to 'remote/setup-tools.sh')
| -rwxr-xr-x | remote/setup-tools.sh | 81 |
1 files changed, 40 insertions, 41 deletions
diff --git a/remote/setup-tools.sh b/remote/setup-tools.sh index 03b5101e..639ec14f 100755 --- a/remote/setup-tools.sh +++ b/remote/setup-tools.sh @@ -5,7 +5,7 @@ SELF=$(readlink -f $0) print_usage() { echo "create tools for minilinux" - echo "Usage: $(basename $SELF) TOOL" + echo "Usage: $(basename ${SELF}) TOOL" } if [ "x$1" = "x" ]; then @@ -17,73 +17,72 @@ elif [ "x$(whoami)" != "xroot" ]; then fi #Create tools directory if not exists -TOOL_DIR=$ROOT_DIR/tools -INIT_DIR=$ROOT_DIR/stage3.2 +TOOL_DIR=${ROOT_DIR}/tools +INIT_DIR=${ROOT_DIR}/stage3.2 setup_git () { - if [ ! -z "$GIT" ]; then + if [ ! -z "${GIT}" ]; then GIT_BIN=$(which git) - [ -z "$GIT_BIN" ] && echo "Installing git..." && apt-get install git + [ -z "${GIT_BIN}" ] && echo "Installing git..." && apt-get install git fi } read_config () { - TOOL_CONFIG=$TOOL_DIR/$TOOL/$TOOL.conf + TOOL_CONFIG=${TOOL_DIR}/${TOOL}/${TOOL}.conf - if [ ! -e $TOOL_CONFIG ]; then + if [ ! -e ${TOOL_CONFIG} ]; then echo "ERROR: Config for specified tool not found." exit 1 fi - . $TOOL_CONFIG + . ${TOOL_CONFIG} } read_build () { - BUILD_SCRIPT=$TOOL_DIR/$TOOL/$TOOL.build + BUILD_SCRIPT=${TOOL_DIR}/${TOOL}/${TOOL}.build - if [ ! -e $BUILD_SCRIPT ]; then + if [ ! -e ${BUILD_SCRIPT} ]; then echo "ERROR: Build script for specified tool not found." exit 1 fi - . $BUILD_SCRIPT + . ${BUILD_SCRIPT} } copyfileswithdependencies () { - [ ! -d build ] && echo "No build directory for $TOOL found." && return + [ ! -d build ] && echo "No build directory for ${TOOL} found." && return cd build COPYFILES_LIST="list_wanted_stage3.2" - [ -e $COPYFILES_LIST ] && rm $COPYFILES_LIST + [ -e ${COPYFILES_LIST} ] && rm ${COPYFILES_LIST} - for FILENAME in $REQUIRED_BINARIES + for FILENAME in ${REQUIRED_BINARIES} do - for f in $(find . -name $FILENAME -type f -executable) + for f in $(find . -name ${FILENAME} -type f -executable) do [ $(file $f |grep -c ELF) -eq 1 ] && FILE=$f done - echo "Found $FILENAME at $FILE. Searching libraries..." - echo $FILE >> $COPYFILES_LIST + echo "Found ${FILENAME} at ${FILE}. Searching libraries..." + echo ${FILE} >> ${COPYFILES_LIST} # fetch dependencies # quick fix to exclude libc*, else it copies unneeded libs... - for i in $(ldd $FILE |awk '{print $1 $2 $3}'|grep -v ld-linux|grep -v libc.so*|grep -v linux-gate) + for i in $(ldd ${FILE} |awk '{print $1 $2 $3}'|grep -v ld-linux|grep -v libc.so*|grep -v linux-gate) do arrIN=(${i//=>/ }) echo "--------------------------------------------------------" echo "Searching ${arrIN[0]} under $(pwd)..." LOCAL_MATCHES=$(find . -name $(echo ${arrIN[0]}|awk -F "." '{print $1}').*) - if [ "x$LOCAL_MATCHES" != "x" ]; + if [ "x${LOCAL_MATCHES}" != "x" ]; then - for llib in $LOCAL_MATCHES; + for llib in ${LOCAL_MATCHES}; do - echo "Copying $llib" - echo $llib >> $COPYFILES_LIST - #[ -L $llib ] && echo $(readlink -f $llib) >> $COPYFILES_LIST + echo "Copying ${llib}" + echo ${llib} >> ${COPYFILES_LIST} done else echo "Did not found ${arrIN[0]} in $(pwd)" @@ -91,31 +90,31 @@ copyfileswithdependencies () then echo -n "Trying ${arrIN[1]} ..." echo " found! Copying." - echo ${arrIN[1]} >> $COPYFILES_LIST - [ -L ${arrIN[1]} ] && echo $(readlink -f ${arrIN[1]}) >> $COPYFILES_LIST + echo ${arrIN[1]} >> ${COPYFILES_LIST} + [ -L ${arrIN[1]} ] && echo $(readlink -f ${arrIN[1]}) >> ${COPYFILES_LIST} fi fi done - echo "Copied $FILENAME." + echo "Copied ${FILENAME}." echo "-----------------------------------------------------------------" done - for LIB in $REQUIRED_LIBRARIES + for LIB in ${REQUIRED_LIBRARIES} do - for LOCATION in $(find . -name $LIB*) + for LOCATION in $(find . -name ${LIB}*) do - echo $LOCATION >> $COPYFILES_LIST + echo ${LOCATION} >> ${COPYFILES_LIST} done done echo "Copying required directories and files from config file..." - for ENTRY in $REQUIRED_DIRECTORIES $REQUIRED_FILES + for ENTRY in ${REQUIRED_DIRECTORIES} ${REQUIRED_FILES} do - echo ".$ENTRY" >> $COPYFILES_LIST + echo ".${ENTRY}" >> ${COPYFILES_LIST} done #copy to initramfsdir - tar -cpv $(cat $COPYFILES_LIST|sort -u) | tar -xpv -C $INIT_DIR &>/dev/null + tar -cpv $(cat ${COPYFILES_LIST}|sort -u) | tar -xpv -C ${INIT_DIR} &>/dev/null unset REQUIRED_BINARIES unset REQUIRED_LIBRARIES unset REQUIRED_DIRECTORIES @@ -124,20 +123,20 @@ copyfileswithdependencies () get_basic_libs () { - [ ! -d $INIT_DIR ] && mkdir $INIT_DIR + [ ! -d ${INIT_DIR} ] && mkdir ${INIT_DIR} # copy libc and ld-linux separatly - echo "Looking for libc and ld-linux used for $SHELL..." + echo "Looking for libc and ld-linux used for ${SHELL}..." BASICLIBS="" - for i in $(ldd $SHELL) + for i in $(ldd ${SHELL}) do if [ $(echo $i | grep '^/' | grep -c ld) -eq 1 -o $(echo $i | grep '^/' | grep -c libc.so) -eq 1 ]; then echo "Found basic lib at: $i" - BASICLIBS="$BASICLIBS $i $(readlink -f "$i")" + BASICLIBS="${BASICLIBS} $i $(readlink -f "$i")" fi done - tar -cpv $BASICLIBS | tar -xpv -C $INIT_DIR &>/dev/null + tar -cpv ${BASICLIBS} | tar -xpv -C ${INIT_DIR} &>/dev/null echo "Basic libs copied." } @@ -149,12 +148,12 @@ main () { fi get_basic_libs - cd $TOOL_DIR + cd ${TOOL_DIR} while (( "$#" )); do TOOL=$1 - if [ -d $TOOL ]; + if [ -d ${TOOL} ]; then - cd $TOOL + cd ${TOOL} read_config read_build setup_git @@ -163,7 +162,7 @@ main () { build copyfileswithdependencies post_copy - cd $TOOL_DIR + cd ${TOOL_DIR} else echo "Tool directory not found." fi |
