summaryrefslogtreecommitdiffstats
path: root/remote
diff options
context:
space:
mode:
authorMichael Neves2012-09-28 15:33:50 +0200
committerMichael Neves2012-09-28 15:33:50 +0200
commit6cca2465d6dd99542ab95ba8cb07d1de21ea5fc8 (patch)
treecc3cf96c341c245c0e40191e145849d0b5f60232 /remote
parentsetup-tools (diff)
downloadtm-scripts-6cca2465d6dd99542ab95ba8cb07d1de21ea5fc8.tar.gz
tm-scripts-6cca2465d6dd99542ab95ba8cb07d1de21ea5fc8.tar.xz
tm-scripts-6cca2465d6dd99542ab95ba8cb07d1de21ea5fc8.zip
setup tools
Diffstat (limited to 'remote')
-rw-r--r--remote/setup-tools.sh113
1 files changed, 113 insertions, 0 deletions
diff --git a/remote/setup-tools.sh b/remote/setup-tools.sh
new file mode 100644
index 00000000..a2c63702
--- /dev/null
+++ b/remote/setup-tools.sh
@@ -0,0 +1,113 @@
+#!/bin/bash
+
+ROOT_DIR=$(readlink -f $(dirname $(readlink -f $0))/..)
+SELF=$(readlink -f $0)
+
+print_usage() {
+ echo "create tools for minilinux"
+ echo "Usage: $(basename $SELF) TOOL"
+}
+
+if [ "x$1" = "x" ]; then
+ print_usage
+ exit 0
+elif [ "x$(whoami)" != "xroot" ]; then
+ echo "ERROR: You need to have root rights to install packages."
+ exit 1
+fi
+
+#Create tools directory if not exists
+TOOL_DIR=$ROOT_DIR/openslx/tools
+INIT_DIR=$ROOT_DIR/openslx/initramfs
+
+read_config ()
+{
+ TOOL_CONFIG=$ROOT_DIR/config/setup-$tool.conf
+
+ if [ ! -e $TOOL_CONFIG ]; then
+ echo "ERROR: Config for specified tool not found."
+ exit 1
+ fi
+
+ . $TOOL_CONFIG
+}
+
+setup_git ()
+{
+ if [ ! -z "$GIT" ]; then
+ GIT_BIN=$(which git)
+ [ -z "$GIT_BIN" ] && echo "Installing git..." && apt-get install git
+ fi
+}
+
+fetch_source ()
+{
+# if [ -d $VERSION/ ]; then
+# read -p "$VERSION already exists and would be overwritten, continue anyway (y/n)?"
+# [ "$REPLY" == "n" ] && exit 1
+# fi
+
+ if [ ! -z "$GIT" ]; then
+ git clone $GIT $VERSION
+ elif [ ! -z "$URL" ]; then
+ wget $URL
+ tar xJf $VERSION.tar.xz
+ rm $VERSION.tar.xz
+ else
+ echo "Could not fetch source for $TOOL. No location specified."
+ fi
+}
+
+install_dependencies()
+{
+ apt-get install --force-yes $DEPS
+}
+
+build ()
+{
+ cd $VERSION
+ ./configure --disable-manpages
+ make
+ mkdir -p $TMP_DIR
+ DESTDIR=$DESTDIR make install
+}
+
+copyfileswithdependencies () {
+ cd $VERSION/tmp
+ COPYFILES_LIST="copyfiles.list"
+
+ for FILENAME in $REQUIRED_BINARIES
+ do
+ for f in $(find . -name $FILENAME -type f -executable); do [ $(file $f |grep -i Executable |grep -c ELF) -eq 1 ] && FILE=$f ; done
+ echo $FILE >> $COPYFILES_LIST
+ #fetch dependencies
+ for i in $(ldd $FILE |awk -F ">" '{print $2}'|awk '{print $1}'|grep ^/)
+ do
+ filename_base=$(basename $i | awk -F "." '{print $1}')
+ filename_path=$(dirname $i)
+ echo "$filename_path/$filename_base*" >> $COPYFILES_LIST
+ done
+ #copy to initramfsdir
+ tar -cpv $(cat $COPYFILES_LIST) | tar -xpv -C $INSTALL_DIR
+ done
+}
+
+main () {
+
+ setup_git
+
+ while (( "$#" )); do
+ tool=$1
+ read_config
+ install_dependencies
+ fetch_source
+ build
+ copyfileswithdependencies
+ shift
+ done
+
+}
+
+
+main $@
+