Fix bug for deps and redeps bug (it ignore higher versions checking)
[tools/build.git] / build-recipe
1 #
2 # recipe specific functions for the build script
3 #
4 ################################################################
5 #
6 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2 or 3 as
10 # published by the Free Software Foundation.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program (see the file COPYING); if not, write to the
19 # Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 #
22 ################################################################
23
24
25 KIWI_PARAMETERS=
26
27 for i in spec dsc kiwi arch preinstallimage mock livebuild debootstrap; do
28     . "$BUILD_DIR/build-recipe-$i"
29 done
30
31 recipe_setup() {
32     recipe_setup_$BUILDTYPE "$@"
33 }
34
35 recipe_prepare() {
36     recipe_prepare_$BUILDTYPE "$@"
37 }
38
39 recipe_build() {
40     recipe_build_$BUILDTYPE "$@"
41 }
42
43 recipe_resultdirs () {
44     recipe_resultdirs_$BUILDTYPE "$@"
45 }
46
47 recipe_parse_options() {
48     case ${PARAM/#--/-} in
49       -stage)
50         needarg
51         BUILD_RPM_BUILD_STAGE="$ARG"
52         shift
53         ;;
54       -kiwi-parameter)
55         test -z "$ARG" && ARG="$1"
56         needarg
57         KIWI_PARAMETERS="$KIWI_PARAMETERS $ARG"
58         shift
59         ;;
60       -*)
61         return 1
62         ;;
63     esac
64     nextargs=("$@")
65     return 0
66 }
67
68 recipe_set_buildtype() {
69     BUILDTYPE=
70     case ${RECIPEFILE##_service:*:} in
71         *.spec|*.src.rpm) BUILDTYPE=spec ;;
72         *.dsc) BUILDTYPE=dsc ;;
73         *.kiwi) BUILDTYPE=kiwi ;;
74         PKGBUILD) BUILDTYPE=arch ;;
75         _preinstallimage) BUILDTYPE=preinstallimage ;;
76         *.livebuild) BUILDTYPE=livebuild ;;
77     esac
78     if test -z "$BUILDTYPE" ; then
79        echo "I don't know how to build $RECIPEFILE"
80        cleanup_and_exit 1
81     fi
82     # we can't query right after vm startup, so we put the BUILDENGINE in the build.data
83     if test -z "$RUNNING_IN_VM" ; then
84         BUILDENGINE=
85         if test -n "$BUILD_DIST" ; then
86             BUILDENGINE=`queryconfig buildengine --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH"`
87             test "$BUILDENGINE" = UNDEFINED && BUILDENGINE=
88         fi
89     fi
90     if test "$BUILDENGINE" = mock -a "$BUILDTYPE" = spec ; then
91         BUILDTYPE=mock
92     fi
93     if test "$BUILDENGINE" = debootstrap -a "$BUILDTYPE" = dsc ; then
94         BUILDTYPE=debootstrap
95     fi
96 }
97
98 # expands all directories into files
99 expand_recipe_directories() {
100     local f t ff found types
101     if test -z "$RECIPEFILES" ; then
102         set -- "`pwd`"
103     else
104         set -- "${RECIPEFILES[@]}"
105     fi
106     RECIPEFILES=()
107     for f in "$@" ; do
108         if test "$f" = "${f#/}" ; then
109             f="`pwd`/$f"
110         fi
111         if test -d "$f" ; then
112             if test -z "$types" ; then
113                 if test -n "$BUILD_DIST" ; then
114                     case $(queryconfig --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH" type) in
115                         dsc) types=".dsc" ;;
116                         kiwi) types=".kiwi" ;;
117                         arch) types="PKGBUILD" ;;
118                         livebuild) types=".livebuild" ;;
119                     esac
120                 fi
121                 types="$types .spec .dsc PKGBUILD .kiwi .src.rpm .nosrc.rpm"
122             fi
123             for t in $types ; do
124                 found=
125                 for ff in "$f"/*$t ; do
126                     test -f "$ff" || continue
127                     RECIPEFILES=("${RECIPEFILES[@]}" "$ff")
128                     found=true
129                 done
130                 test -n "$found" && break
131             done
132         else
133             RECIPEFILES[${#RECIPEFILES[@]}]="$f"
134         fi
135     done
136     if test -z "$RECIPEFILES" ; then
137         echo "no recipe files found in $@. exit..."
138         cleanup_and_exit 1
139     fi
140 }