Fixed segfault with 'cut -f 1 -d:' and added 'cut -s' suport.
[oweals/busybox.git] / install.sh
index 4a0b83254c36d518e11b64518bc8d218c637b222..65190f59d85b10ed6f1bd18c4c63f13b1c5505c2 100755 (executable)
@@ -1,17 +1,21 @@
 #!/bin/sh
 
-if [ "$1" == "" ]; then
-    echo "No installation directory.  aborting."
+set -e
+
+if [ "$1" = "" ]; then
+    echo "No installation directory, aborting."
     exit 1;
 fi
 
-h=`cat busybox.links`
+h=`sort busybox.links | uniq`
 
-mkdir -p $1/bin
 for i in $h ; do
-       mkdir -p $1/`echo $i | sed -e 's/\(^.*\/\)\(.*\)/\1/g' `
-       (cd $1/bin ; ln -s busybox `echo $i | sed -e 's/\(^.*\/\)\(.*\)/\2/g' ` )
+       echo "  $1$i -> /bin/busybox"
+       mkdir -p $1/`echo $i | sed -e 's/\/[^\/]*$//' `
+       ln -fs /bin/busybox $1$i
 done
 rm -f $1/bin/busybox
+mkdir -p $1/bin
 install -m 755 busybox $1/bin/busybox
 
+exit 0