Magellan Linux

Diff of /smage/trunk/include/alx.sminc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1661 by niro, Sat Jan 22 23:14:38 2011 UTC revision 2065 by niro, Wed May 11 21:05:56 2011 UTC
# Line 1  Line 1 
1  # $Header: /alx-cvs/smage/include/alx.sminc,v 1.3 2006/04/03 20:04:47 niro Exp $  # $Id$
2  # alx functions  # alx specific functions
3    
4  # to build a stripped down package version  # some global includes
5  # you must call 'package_all_targets' in src_install().  sminclude cleanutils mtools
 # be sure you have the strip-target-alx() function defined,  
 # get stuff stripped from the package.  
 #  
 # the dev version will be always build when including this file  
 #  
 # The only way to change the bevavior is to set ALX_PKGTYPE  
 #  ALX_PKGTYPE=only-alx-dev -> means that *only* the alx-dev package gets build  
 #  ALX_PKGTYPE=only-alx     -> means that *only* the stripped alx package gets build  
 #  
   
 # all targets for alx  
 MAGE_TARGETS="alx_dev alx_livecd alx"  
   
 # overrides  
 [[ ${ALX_PKGTYPE} = only-alx-dev ]] && MAGE_TARGETS="alx_dev"  
 [[ ${ALX_PKGTYPE} = only-alx-livecd ]] && MAGE_TARGETS="alx_livecd"  
 [[ ${ALX_PKGTYPE} = only-alx ]] && MAGE_TARGETS="alx"  
   
 # dummy functions, should be overrided in smage  
 alx_dev_pkgbuild() { return 0; }  
 alx_livecd_pkgbuild() { return 0; }  
 alx_pkgbuild() { return 0; }  
6    
7    # all deprecated mage-targets
8    DEPRECATED_MAGE_TARGETS="alx_dev alx_livecd alx"
9    
10  # checks if compilation should be against alx  # variable to save pname
11  target_alx_dev()  _PNAME="${PNAME}"
12    
13    SPECIAL_VARS="${SPECIAL_VARS} DEPRECATED_MAGE_TARGETS REMOVE_DEPRECATED_MAGE_TARGETS _PNAME"
14    SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} alx_postinstall"
15    
16    alx_postinstall()
17  {  {
18   local i   local target
19    
20     case ${REMOVE_DEPRECATED_MAGE_TARGETS} in
21     1|yes|true|TRUE)
22     for target in ${DEPRECATED_MAGE_TARGETS}
23     do
24     if [[ ! -z $(magequery -n ${_PNAME}-${target}) ]]
25     then
26     echo "removing deprecated mage-target '${_PNAME}-${target}'"
27     mage uninstall ${_PNAME}-${target} || die
28     fi
29     done
30     ;;
31     esac
32    }
33    
34    # injects files to given path (defaults to /usr/bin)
35    # mcinjectfile file {/path/to/dest}
36    mcinjectfile()
37    {
38     local file
39     local dest
40    
41   if [ -n "${MAGE_TARGETS}" ]   [[ -z $1 ]] && die "No etc file given"
42    
43     file="${SMAGENAME%/*}/alx/files/$1"
44     dest="$2"
45     if [[ -z $2 ]]
46   then   then
47   for i in ${MAGE_TARGETS}   dest=/usr/bin
48   do   install -d ${BINDIR}/${dest} || die
49   [[ ${i} = alx_dev ]] && return 0   fi
50    
51   # alx-dev will always build when building target alx,   # install our configfile
52   # so target alx ist also allowed to be alx-dev   install -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die
53   [[ ${i} = alx ]] && return 0  }
54    
55   # same for alx_livecd  # injects executables to given path
56   [[ ${i} = alx_livecd ]] && return 0  # mcinjectexec exec {/path/to/dest}
57   done  mcinjectexec()
58    {
59     local file
60     local dest
61    
62     [[ -z $1 ]] && die "No etc file given"
63    
64     file="${SMAGENAME%/*}/alx/files/$1"
65     dest="$2"
66     if [[ -z $2 ]]
67     then
68     dest=/usr/bin
69     install -d ${BINDIR}/${dest} || die
70   fi   fi
71    
72   # nothing match, we are *not* on alx linux   # install our configfile
73   return 1   install -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die
74  }  }
75    
76  # check if compilation should be against stripped down alx for livecds  # injects a patch to the sourcecode
77  target_alx_livecd()  # - basically the same like mpatch() but uses patches from ${SMAGENAME%/*}/mcore/files
78    # mcinjectpatch patch
79    mcinjectpatch()
80  {  {
81   if [ -n "${MAGE_TARGETS}" ]   local PATCHOPTS
82     local PATCHFILE
83     local i
84    
85     PATCHOPTS=$1
86     PATCHFILE=$2
87    
88     if [[ -z $2 ]]
89   then   then
90   for i in ${MAGE_TARGETS}   PATCHFILE=$1
91    
92     ## patch level auto-detection, get patch level
93     for ((i=0; i < 10; i++))
94   do   do
95   [[ ${i} = alx_livecd ]] && return 0   patch --dry-run -Np${i} -i ${SMAGENAME%/*}/alx/files/${PATCHFILE} > /dev/null
96     if [[ $? = 0 ]]
97     then
98     PATCHOPTS="-Np${i}"
99     break
100     fi
101   done   done
102   fi   fi
103    
104   # nothing match, we are *not* on alx linux   echo -e "${COLBLUE}*** ${COLGREEN}Applying ALX patch '${PATCHFILE}'${COLDEFAULT}"
105   return 1   patch "${PATCHOPTS}" -i ${SMAGENAME%/*}/alx/files/${PATCHFILE}
106  }  }
107    
108  # check if compilation should be against stripped down alx  #############################
109  target_alx()  ##### compile functions ####
110    #############################
111    
112    # respect multilib!
113    if [[ -z $(typeset -f oldconfigure) ]]
114    then
115     alx_old_mconfigure=alx_old$(typeset -f mconfigure)
116    else
117     alx_old_mconfigure=alx_old$(typeset -f oldmconfigure)
118    fi
119    eval ${alx_old_mconfigure}
120    mconfigure()
121  {  {
122   if [ -n "${MAGE_TARGETS}" ]   local myconf
123     local configurefile
124    
125     # get configure instructions from smage dir
126     if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.cfg ]]
127   then   then
128   for i in ${MAGE_TARGETS}   # version specific configure files
129     configurefile=${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.cfg
130     elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.cfg ]]
131     then
132     # generic configure files for a package
133     configurefile=${SMAGENAME%/*}/alx/${PNAME}.cfg
134     else
135     configurefile=""
136     fi
137    
138     # now read the content
139     if [[ -f ${configurefile} ]]
140     then
141     echo -e "${COLBLUE}*** ${COLGREEN}Using configure info from ${configurefile}${COLDEFAULT}"
142     local line
143     while read line
144   do   do
145   [[ ${i} = alx ]] && return 0   # ignore empty and commeted lines
146   done   case "${line}" in
147     \#*|"") continue ;;
148     esac
149    
150     echo -e "     adding ${COLGREEN}${line}${COLDEFAULT} to ALX_CONFIGURE_OPTS"
151     ALX_CONFIGURE_OPTS+=" ${line}"
152     done < ${configurefile}
153   fi   fi
154    
155   # nothing match, we are *not* on alx linux   alx_oldmconfigure --disable-nls ${myconf} $@ ${ALX_CONFIGURE_OPTS} || die
  return 1  
156  }  }
157    
158    # get custom mcore functions
159    if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom ]]
160    then
161     echo -e "${COLBLUE}*** ${COLGREEN}Using custom build info from ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom${COLDEFAULT}"
162     source ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom
163    elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.custom ]]
164    then
165     echo -e "${COLBLUE}*** ${COLGREEN}Using custom build info from ${SMAGENAME%/*}/alx/${PNAME}.custom${COLDEFAULT}"
166     source ${SMAGENAME%/*}/alx/${PNAME}.custom
167    fi
168    
169    export_inherits alx postinstall

Legend:
Removed from v.1661  
changed lines
  Added in v.2065