Specify our local m4 directory to aclocal.
[minipack.git] / tools / mpk-unpack
blob9d733eece474de733d80b929afa2e06395ac2aec
1 # mpk-unpack - unpacks source code
2 # This file is part of Minipack - an automated build tool.
4 # Copyright (C) 2008 Cesar Strauss
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 unpack_source()
22   : ${source_package_type:=tar.gz}
23   : ${source:=$name-$version.$source_package_type}
24   : ${top_srcdir:=$name-$version}
26   buildroot=$builddir/$name-$version-$release
27   
28   if [ -d $buildroot/$top_srcdir ]; then
29     exit 0
30   fi
31   
32   sourcename=$sourcedir/$source
33   if [ ! -e $sourcename ]; then
34     $mpk source $pkg
35     if [ ! -e $sourcename ]; then
36       echo >&2 "$(basename $0) unpack: Could not find source for $pkg"
37       exit 1
38     fi
39   fi
41   mkdir -p $buildroot
42   cd $buildroot
44   case $source_package_type in
45     tar.*)
46       tar -xf $sourcename ;;
47     zip)
48       unzip $sourcename ;;
49   esac
51   if [ $? != 0 ]; then
52     echo >&2 "$(basename $0) unpack: Failed to unpack $sourcename"
53     exit 1
54   fi
55   
56   cd ${top_srcdir}
57   
58   pkg_patchdir=$patchdir/$name
59   
60   if [ -d $pkg_patchdir ]; then
61     patches=`find $pkg_patchdir -name '*.patch' | sort`
62     for p in $patches; do
63       patch -p1 -i "$p"
64       if [ $? != 0 ]; then
65         echo >&2 "$(basename $0) unpack: Failed apply patches for $sourcename"
66         exit 1
67       fi
68     done
69   fi
71   export ACLOCAL="aclocal -I $resultdir/share/aclocal"  
73   src_prep
75   if [ $? != 0 ]; then
76     echo >&2 "$(basename $0) unpack: Failed to prepare build directory for $sourcename"
77     exit 1
78   fi
79   
82 src_prep()
84   do_prep
87 do_prep()
89   :
92 pkg=$1
94 if [ -z "$pkg" ]; then
95   echo "Usage: $(basename $0) unpack package-name ..."
96   exit 1
99 recipe=$(get_recipe_name $pkg) || exit 1
101 . $recipe
103 unpack_source