summaryrefslogtreecommitdiffstats
path: root/packaging/dxs2tgz
blob: edbef50f0452d0a548df13617d3e353a03877881 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
#
# This script transforms the dxs project files to debians
# binary package format .deb

DEBUG=0
# This function makes the directory of this script to the present working directory
# It is called within precheck()
# Does also work when called by symbolic links (even for nested links). 
goto_script_dir()
{
  [ $DEBUG -ge 2 ] && echo "Aufgerufen wurde $0, checking if it is a link"
  calleddetails=`ls -l $0` # get the file flags (e.g. lrwxrwxrwx)
  [ $DEBUG -ge 2 ] && echo $calleddetails
  
  calleddir=${0%/*}  # Strip the filename from path
  [ $DEBUG -ge 2 ] && echo "Wechsele ins Verzeichnis des aufgerufenen scripts/links ($calleddir)"
  cd $calleddir
 
  while index=`expr index "$calleddetails" "l"`; 
        [ $index -eq 1 ]; do

    [ $DEBUG -ge 2 ] && echo "It is a link"
    target=`echo $calleddetails | awk '{print $NF}'`
    [ $DEBUG -ge 2 ] && echo "The target of the link is: $target"
    hasslash=`expr index "$target" "/"`
    if [ $hasslash -ne 0 ]; then 
        targetpath=${target%/*} # extract the pathname
        [ $DEBUG -ge 2 ] && echo "Following link to $targetpath"
        cd $targetpath
    else
        [ $DEBUG -ge 2 ] && echo "It is in the same directory as the link"
    fi
    targetfile=`basename $target`
    [ $DEBUG -ge 2 ] && echo "The target file of the link is: $targetfile"
    calleddetails=`ls -l $targetfile` # get the file flags (e.g. lrwxrwxrwx)
    [ $DEBUG -ge 2 ] && echo $calleddetails
  done
  [ $DEBUG -ge 2 ] && pwd

}
dpkg_deb=`which dpkg-deb`
if [ -z "$dpkg_deb" ];then 
    echo "You need the program dpkg-deb (contained in package dpkg) to build a debian package"
    exit
fi

goto_script_dir
#Create Temporary working directory
mkdir -p /tmp/ld$$/dxs
mkdir -p /tmp/ld$$/man/
cp default_files/*.1 /tmp/ld$$/man/
gzip /tmp/ld$$/man/*
cp default_files/*install.sh /tmp/ld$$/

#Goto project root
pushd .. > /dev/null
#copy all relevant file to a tar archive (can't use xargs with cp)
find -type f| grep -v /\.svn | grep -v \#.*\# | grep ^\./in | grep -v ~$ | xargs tar rf /tmp/ld$$/dxs/tmp.tar
#extract it
pushd /tmp/ld$$/dxs > /dev/null
tar xf tmp.tar
rm tmp.tar

#Create the package
pushd /tmp/ld$$/ > /dev/null
find -type f |xargs tar rf dxs.tar
gzip dxs.tar
popd > /dev/null

#And bring the package back to the dir of this script
popd > /dev/null
popd > /dev/null
mv /tmp/ld$$/dxs.tar.gz ./dxs.tgz
rm -rf /tmp/ld$$
echo "Written './dxs.tgz'"