summaryrefslogtreecommitdiffstats
path: root/chroot-scripts/pkg-builder.sh
diff options
context:
space:
mode:
Diffstat (limited to 'chroot-scripts/pkg-builder.sh')
-rwxr-xr-xchroot-scripts/pkg-builder.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/chroot-scripts/pkg-builder.sh b/chroot-scripts/pkg-builder.sh
new file mode 100755
index 0000000..d172860
--- /dev/null
+++ b/chroot-scripts/pkg-builder.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+if [ "$(readlink -f $0| xargs basename)" == "pkg-builder.sh" ]; then
+ echo "You shouldn't run this script directly."
+ exit 1
+fi
+
+### Variables #####
+CHROOT_DIR=/tmp/chroot
+PKG_DIR=/root/packages
+
+[ ! -d "$PKG_DIR/indices" ] && mkdir -p "$PKG_DIR/indices"
+
+copyfileswithdependencies () {
+ # Create $CHROOT_DIR
+ [ ! -d $CHROOT_DIR ] && mkdir $CHROOT_DIR
+ cd $CHROOT_DIR
+
+ # Copy $REQUIRED_CHROOT_FILES and shared library dependencies
+ # to chroot environment
+
+ [ -f "$PKG_DIR/indices/$PKG_NAME.files" ] && rm -f "$PKG_DIR/indices/$PKG_NAME.files"
+
+ for FILE in $REQUIRED_CHROOT_FILES
+ do
+ DIR=`dirname $FILE | cut -c2-`
+ [ ! -d $DIR ] && mkdir -p $DIR
+ cp $FILE `echo $FILE | cut -c2-`
+ echo $FILE | cut -c1- >> "$PKG_DIR/indices/$PKG_NAME.files"
+ for SHARED_LIBRARY in `ldd $FILE | awk '{print $3}' |grep ^/`
+ do
+ DIR=`dirname $SHARED_LIBRARY | cut -c2-`
+ [ ! -d $DIR ] && mkdir -p $DIR
+ [ ! -s "`echo $SHARED_LIBRARY | cut -c2-`" ] && \
+ [ ! "$(grep -l $SHARED_LIBRARY $PKG_DIR/indices/*| wc -l)" == "0" ] && \
+ cp $SHARED_LIBRARY `echo $SHARED_LIBRARY | cut -c2-` && \
+ echo $SHARED_LIBRARY | cut -c1- >> "$PKG_DIR/indices/$PKG_NAME.files"
+ done
+ done
+
+ #cp /lib/ld-* lib
+}