Sync up userspace dmapi.h with kernel.
[xfstests-dev.git] / tools / srctest
1 #!/bin/sh -x
2
3 # Simple script which does the following:
4 #       o  Generates a src tarball from a WORKAREA
5 #       o  Copies it over to ~/test and unpacks it
6 #       o  Generates a src tarball from src tarball
7 #       o  Compares the build status' ... reports problems
8 #       o  removes ~/test
9
10
11 package="$1"
12 tmpdir="$HOME/test"
13
14 if [ -z "$package" ]
15 then
16         echo "srctest requires one argument - package name"
17         exit 1
18 fi
19
20 if [ -z "$WORKAREA" ]
21 then
22         echo "WORKAREA is not set -- aborting."
23         exit 1
24 fi
25
26 if [ -d $tmpdir ]
27 then
28         echo "$tmpdir exists already -- aborting."
29         exit 1
30 else
31         mkdir $tmpdir
32         if [ ! -d $tmpdir ]
33         then
34                 echo "Cannot create $tmpdir -- aborting."
35                 exit 1
36         fi
37 fi
38
39
40 # Pleasantries are now out of the way, lets proceed.
41 # NB: If something goes wrong we'll leave the unpacked
42 # source alone for consumption by a human.
43
44
45 _cleanup()
46 {
47         if [ $status -eq 0 ]
48         then
49                 rm -fr $tmpdir
50         else
51                 echo "Problem?  -- leaving $tmpdir for inspection"
52         fi
53 }
54
55 _buildme()
56 {
57         cd $1
58
59         if ./Makepkgs
60         then
61                 :
62         else
63                 echo Makepkgs thinks theres a problem in $1
64                 exit 1
65         fi
66
67         if [ ! -f build/$package-*.src.tar.gz ]
68         then
69                 echo Makepkgs failed to create build/package-*.src.tar.gz
70                 exit 1
71         fi
72 }
73
74 status=1
75 trap "_cleanup; exit \$status" 0 1 2 3 15
76
77 # first, build from the WORKAREA
78 _buildme $WORKAREA/cmd/$package
79
80 cd $tmpdir
81 gunzip < $WORKAREA/cmd/$package/build/$package-*.src.tar.gz | tar xf -
82
83 # now, cross check the src build
84 _buildme $tmpdir/$package-*
85
86 status=0