summaryrefslogtreecommitdiff
path: root/scripts/tothreaded
authorwimpie <wimpie>2004-04-02 16:49:47 (UTC)
committer wimpie <wimpie>2004-04-02 16:49:47 (UTC)
commit9e26c10c0dc97a0956d019166caf712955094764 (patch) (unidiff)
tree9bf4f33bd02185780070e178d25e24bdff4d6cd2 /scripts/tothreaded
parent2f2d702e37cc391dd547eaa7e2432d86285e546d (diff)
downloadopie-9e26c10c0dc97a0956d019166caf712955094764.zip
opie-9e26c10c0dc97a0956d019166caf712955094764.tar.gz
opie-9e26c10c0dc97a0956d019166caf712955094764.tar.bz2
ipkg-build mkipkg : speedup (avoid grepping over controlfile by loading into array)
SpeciapMTFiles tothreaded : convert control files to -mt.control
Diffstat (limited to 'scripts/tothreaded') (more/less context) (ignore whitespace changes)
-rwxr-xr-xscripts/tothreaded132
1 files changed, 132 insertions, 0 deletions
diff --git a/scripts/tothreaded b/scripts/tothreaded
new file mode 100755
index 0000000..d9f8488
--- a/dev/null
+++ b/scripts/tothreaded
@@ -0,0 +1,132 @@
1#!/bin/sh
2
3# PURPOSE :
4#
5# this script converts a non-threaded control file to a threaded one
6# by extending appropriate names with -mt as extension
7#
8# eg abc.control becoms abc-mt.control
9#
10
11#
12# make sure that the depends expression has enough spaces
13# expression can contian : , ( ) || &&
14#
15tokenize() {
16 sed "s/,/ & /g" | sed "s/)/ & /g" | sed "s/(/ & /g" | sed "s/|/ & /g" | sed "s/&/ & /g"
17}
18
19#
20# function converts package name to threaded equivalend IF the
21# package file HAS a threaded version
22#
23findthreadedequiv() {
24 local isin i
25 for i in $*
26 do
27 isin=`grep "^$i\$" "$ALLTHREADEDPKGSFILE"`
28 if [ -z "$isin" ]
29 then
30 # no threaded package
31 echo -n "$i "
32 else
33 # threaded package
34 echo -n "${isin}-mt "
35 fi
36 done
37 echo
38}
39
40#
41# signature of binary files
42# currently obsolete
43#
44# ISBINARY="*ELF*LSB*"
45
46usage() {
47 echo "Usage : tothreaded <controlfile> <ALLPackages file>"
48 exit 2
49}
50
51. scripts/SpecialMTFiles
52
53#
54# get the name of the controlfile to check for threading
55#
56if [ -z "$1" ]
57then
58 usage
59fi
60controlfile=$1
61shift
62
63case $controlfile in
64 *-mt.control)
65 #already threaded
66 echo $controlfile
67 exit 0;
68 ;;
69esac
70
71#
72# file containing list of all known threaded packages
73#
74if [ -z "$1" ]
75then
76 usage
77fi
78ALLTHREADEDPKGSFILE=$1
79shift
80
81#
82# strip out the name of the package
83#
84packagename=${controlfile##*/} # path
85packagename=${packagename%.control} # extension
86
87#
88# generate new control file
89#
90newcontrolfile=${controlfile/\.control/-mt\.control}
91
92#
93# read all lines in original control file
94#
95while read line
96do
97 case $line in
98 # convert some files to threaded equivalent
99 "Files:"*)
100 files=${line#Files:}
101 # thread-converted files
102 T_files=`ConvertSpecialFiles "$files"`
103 echo "Files: $T_files"
104 ;;
105 "Package: "*)
106 T_package=`findthreadedequiv ${line#Package: }`
107 echo "Package: ${T_package}"
108 ;;
109 "Depends: "*)
110 depends=`echo "${line#Depends: }" | tokenize`
111 T_depends=`findthreadedequiv ${depends}`
112 echo "Depends: $T_depends"
113 ;;
114 "Provides: "*)
115 T_provides=`findthreadedequiv ${line#Provides: }`
116 echo "Provides: $T_provides"
117 ;;
118 "Conflicts: "*)
119 conflicts=`echo "${line#Conflicts: }" | tokenize`
120 T_conflicts=`findthreadedequiv ${conflicts}`
121 echo "Conflicts: $T_conflicts"
122 ;;
123 *":"*)
124 echo "$line"
125 ;;
126 *) # al other lines
127 echo " $line"
128 ;;
129 esac
130done < $controlfile > $newcontrolfile
131
132echo $newcontrolfile