/[soft]/multiarch-utils/branches/1/mkmultiarch
ViewVC logotype

Contents of /multiarch-utils/branches/1/mkmultiarch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1638 - (show annotations) (download)
Thu Jun 2 20:45:36 2011 UTC (12 years, 10 months ago) by dmorgan
File size: 2542 byte(s)
Branch for updates
1 #!/bin/bash
2 #---------------------------------------------------------------
3 # Module : multiarch-utils
4 # File : mkmultiarch
5 # Version : $Id: mkmultiarch 156134 2005-08-07 14:29:26Z gbeauchesne $
6 # Author : Gwenole Beauchesne
7 # Created On : Wed Jan 12 10:54:10 CET 2005
8 #---------------------------------------------------------------
9
10 usage="Usage: $0 <binaries|includes> <file1> [<file2> ...]"
11 mplat=`multiarch-platform`
12 type=$1
13 case $type in
14 binaries|includes) shift;;
15 *) echo $usage; exit 1;;
16 esac
17
18 function error() {
19 echo ${1+"$@"} > /dev/stderr
20 exit 1
21 }
22
23 # read link on one level only
24 function read_link_1() {
25 perl -e 'print readlink(shift)' $1
26 }
27
28 function dispatch_binaries() {
29 local file=$1
30 local bindir=`dirname $file`
31 local archbindir=$bindir/$mplat
32 [[ -d $archbindir ]] || mkdir -p $archbindir
33 if [[ -L $file ]]; then
34 link=`read_link_1 $file`
35 case $link in
36 /*)
37 mv $file $archbindir/
38 ;;
39 ../*)
40 ln -s ../$link $archbindir/${file##*/}
41 rm -f $file
42 ;;
43 esac
44 elif [[ -f $file ]]; then
45 mv $file $archbindir/
46 else
47 error "Unsupported file type for $file"
48 fi
49 ln -s /usr/bin/multiarch-dispatch $file
50 }
51
52 function dispatch_includes() {
53 local file=$1
54 local incdir=`dirname $file`
55
56 # handle circular inclusions
57 local tag=$incdir/.multiarch-processing.${file##*/}
58 [[ -f "$tag" ]] && return
59 touch $tag
60
61 # sanity checks, extract path parts
62 echo $file | grep -q '/include/' || error "Unsupported includedir $incdir"
63 local prefix=`echo $incdir | sed -n '/\(.*\/include\)\/.*/s//\1/p'`
64 [[ -z "$prefix" ]] && prefix="$incdir"
65 local suffix=`echo $incdir | sed -n '/.*\/include\/\(.*\)/s//\1/p'`
66 [[ -n "$suffix" ]] && suffix="$suffix/"
67
68 # dispatch nested includes expected in local directory
69 sed -n '/^#[ \t]*include[ \t]*"\([^"][^"]*\)".*/s//\1/p' $file | \
70 while read localfile; do
71 [[ -f "$incdir/$localfile" ]] && dispatch_includes $incdir/$localfile
72 done
73
74 # dispatch selected include file, provided it's not already dispatched
75 grep -q _MULTIARCH_HEADER $file || {
76 local archincdir=$prefix/$mplat/$suffix
77 [[ -d $archincdir ]] || mkdir -p $archincdir
78 mv $file $archincdir/
79 cat > $file << EOF
80 #define _MULTIARCH_HEADER $suffix${file##*/}
81 #include <multiarch-dispatch.h>
82 EOF
83 }
84
85 # done with this file
86 rm -f $tag
87 }
88
89 while [[ $# -gt 0 ]]; do
90 file=$1
91 shift 1
92 [[ -f $file ]] || error "$file does not exist!"
93 dispatch_$type $file
94 done

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.30