~ubuntu-branches/ubuntu/trusty/kde-l10n-he/trusty-proposed

« back to all changes in this revision

Viewing changes to debian/build-l10n.sh

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2014-03-19 12:36:07 UTC
  • mfrom: (1.12.38)
  • Revision ID: package-import@ubuntu.com-20140319123607-jhybk5q0cc9lecbf
Tags: 4:4.12.90-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
2
 
3
 
function mapKdeCodeToUbuntu {
4
 
  case `eval "expr \"\$"$1"\" "` in
5
 
    "be@latin" )
6
 
      eval "$1=\"belatin\"";;
7
 
    "ca@valencia" )
8
 
      eval "$1=\"ca-valencia\"";;
9
 
    "en_GB" )
10
 
      eval "$1=\"engb\"";;
11
 
    "pt_BR" )
12
 
      eval "$1=\"ptbr\"";;
13
 
    "sr@ijekavian" )
14
 
      eval "$1=\"srijekavian\"";;
15
 
    "sr@ijekavianlatin" )
16
 
      eval "$1=\"srijekavianlatin\"";;
17
 
    "sr@latin" )
18
 
      eval "$1=\"srlatin\"";;
19
 
    "uz@cyrillic" )
20
 
      eval "$1=\"uzcyrillic\"";;
21
 
    "zh_CN" )
22
 
      eval "$1=\"zhcn\"";;
23
 
    "zh_TW" )
24
 
      eval "$1=\"zhtw\"";;
25
 
  esac
26
 
}
27
 
 
28
 
function mapUbuntuNameToDep {
29
 
  case `eval "expr \"\$"$1"\" "` in
30
 
    "belatin" )
31
 
      eval "$1=\"be\"";;
32
 
    "ca-valencia" )
33
 
      eval "$1=\"ca\"";;
34
 
    "engb" )
35
 
      eval "$1=\"en\"";;
36
 
    "ptbr" )
37
 
      eval "$1=\"pt\"";;
38
 
    "srijekavian" )
39
 
      eval "$1=\"sr\"";;
40
 
    "srijekavianlatin" )
41
 
      eval "$1=\"sr\"";;
42
 
    "srlatin" )
43
 
      eval "$1=\"sr\"";;
44
 
    "uzcyrillic" )
45
 
      eval "$1=\"uz\"";;
46
 
    "zhcn" )
47
 
      eval "$1=\"zh-hans\"";;
48
 
    "zhtw" )
49
 
      eval "$1=\"zh-hant\"";;
50
 
  esac
51
 
}
52
 
 
53
 
function mapKdeCodeToIbusPkg {
54
 
  case `eval "expr \"\$"$1"\" "` in
55
 
    "ko" )
56
 
      eval "$1=\",ibus-hangul\"";;
57
 
    "ja" )
58
 
      eval "$1=\",ibus-anthy\"";;
59
 
    "zh_CN" )
60
 
      eval "$1=\",ibus-pinyin\"";;
61
 
    "zh_TW" )
62
 
      eval "$1=\",ibus-chewing\"";;
63
 
    * )
64
 
      eval "$1=\"\"";;
65
 
  esac
66
 
}
 
3
export COMMON_BRANCH="lp:~kubuntu-packagers/kubuntu-packaging/kubuntu-l10n-common"
 
4
export COMMON_DIR="common-l10n"
 
5
if [ ! -d $COMMON_DIR ]; then
 
6
    bzr co $COMMON_BRANCH $COMMON_DIR
 
7
else
 
8
    wd=`pwd`
 
9
    cd $COMMON_DIR
 
10
    bzr up
 
11
    cd $wd
 
12
fi
 
13
if [ ! -d $COMMON_DIR ]; then
 
14
    echo "failed to get kubuntu-l10n-common, cannot continue!"
 
15
    exit 1
 
16
fi
 
17
 
 
18
if ! source $COMMON_DIR/common ; then
 
19
    echo "could not source common functions!!"
 
20
    exit 1
 
21
fi
 
22
 
 
23
###################################
 
24
 
 
25
checkDependencies
 
26
cdMainDirectory "kde-l10n-common"
 
27
 
 
28
includeConfig
 
29
ensureBranchIsPushed
67
30
 
68
31
clean_dld=1
69
32
subset=""
70
33
 
71
 
if [ ! -x /usr/bin/bzr-buildpackage ]; then
72
 
  echo "bzr-buildpackage needs to be installed to build kde-l10n packages"
73
 
  exit 1
74
 
fi
75
 
 
76
34
for arg in "$@"
77
35
do
78
36
    case "$arg" in
79
37
    -ncd)
80
 
      clean_dld=0
81
 
      ;;
 
38
        clean_dld=0
 
39
        ;;
82
40
    *)
83
 
      subset="$subset $arg"
 
41
        subset="$subset $arg"
84
42
    esac
85
43
done
86
44
 
87
 
WDIR=`pwd`
88
 
case ${WDIR##*/} in
89
 
  "debian" )
90
 
    cd ..;;
91
 
  "build" )
92
 
    cd ..;;
93
 
  "kde-l10n-common" )
94
 
    ;;
95
 
esac
96
 
 
97
 
if ! source debian/config-l10n ; then
98
 
    echo "could not source config!!"
99
 
    exit 1
100
 
fi
101
 
 
102
45
if [ -e build ]; then
103
 
  echo "A already existing build/ directory was found, which indicates that there was a build done earlier."
104
 
  echo "Note: you can also run this script with -ncd to preserve only the tar.xz files from build/."
105
 
  echo "Do you REALLY REALLY want to mess with the current build dir? (y/n)"
106
 
  read -e reply
107
 
  if [[ $reply != "y" ]]; then
108
 
    echo "bye!"
109
 
    exit 0
110
 
  fi
 
46
    echo "A already existing build/ directory was found, which indicates that there was a build done earlier."
 
47
    echo "Note: you can also run this script with -ncd to preserve only the tar.xz files from build/."
 
48
    echo "Do you REALLY REALLY want to mess with the current build dir? (y/n)"
 
49
    read -e reply
 
50
    if [[ $reply != "y" ]]; then
 
51
        echo "bye!"
 
52
        exit 0
 
53
    fi
111
54
fi
112
55
 
 
56
exportDirectories
 
57
 
113
58
# clean build dir
114
59
if [ $clean_dld -eq 0 ]; then
115
 
  find build/* -maxdepth 0 | grep -v build-area | xargs rm -rfv
116
 
  find build/build-area/* -maxdepth 0 | grep -v ".tar.xz" | xargs rm -rfv
 
60
    find $BUILD_DIR/* -maxdepth 0 | grep -v build-area | xargs rm -rfv
 
61
    find $BUILD_AREA_DIR//* -maxdepth 0 | grep -v ".tar.xz" | xargs rm -rfv
117
62
else
118
 
  rm -rvf build
119
 
  mkdir build
120
 
fi
121
 
 
122
 
cd build
123
 
WDIR=`pwd`
124
 
 
125
 
BOILERPLATE="# ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !#\n# DO NOT EVEN THINK ABOUT CHANGING THIS FILE DIRECTLY! ! ! !\n# PLEASE USE THE BZR BRANCH AS SEEN IN debian\/control\n# MAKE YOUR CHANGES THERE AND THEN RUN debian\/build-l10n.sh\n# kthxbai :)\n################################################################################\n################################################################################\n################################################################################\n################################################################################"
126
 
 
127
 
if [[ `bzr revno` != `bzr revno ${BRANCH}` ]]; then
128
 
  echo "For one reason or another the parent branch does not match the local one, please ensure they match, or all is going down the drain."
129
 
  echo "Most importantly: YOU MUST PUSH TO THE PARENT BRANCH BEFORE BUILDING THE PACKAGES!!!"
130
 
  echo "Leaving you alone in the cold."
131
 
  exit 1
132
 
fi
133
 
 
134
 
mkdir build-area
 
63
    purgeBuildDirectory
 
64
fi
 
65
 
 
66
# Safe even with a partial clean up.
 
67
initBuildDirectory
 
68
 
 
69
cd $BUILD_DIR
 
70
CO=common
135
71
bzr branch $BRANCH $CO
136
 
bzr branch $LANG_PACK_BRANCH $CO-langpack
137
72
 
138
73
cd $CO
139
74
VERSION=`dpkg-parsechangelog | sed -ne 's/^Version: \(\([0-9]\+\):\)\?\(.*\)-.*/\3/p'`
 
75
echo $VERSION
140
76
if [[ ${VERSION} =~ (.*)([abcdefghijklmnopqrstuvwxyz]) ]]; then
141
 
  KDEVERSION=${BASH_REMATCH[1]}
 
77
    echo "match"
 
78
    KDEVERSION=${BASH_REMATCH[1]}
142
79
else
143
 
  KDEVERSION=$VERSION
 
80
    KDEVERSION=$VERSION
144
81
fi
145
 
cd $WDIR
 
82
cd $BUILD_DIR
146
83
 
147
84
cd build-area
148
85
 
149
86
# only download tars if we actually removed them
150
87
if [ $clean_dld -ne 0 ]; then
151
 
  if [[ "$subset" == "" ]]; then
152
 
    # get all
153
 
    $GET/${TYPE}/${KDEVERSION}/src/kde-l10n/kde-l10n-*.tar.xz .
154
 
  else
155
 
    # only get subset
156
 
    for pkg in $subset; do
157
 
      $GET/${TYPE}/${KDEVERSION}/src/kde-l10n/kde-l10n-$pkg-*.tar.xz .
158
 
    done
159
 
  fi
 
88
    if [[ "$subset" == "" ]]; then
 
89
        # get all
 
90
        $REMOTE_GET_BASE/${TYPE}/${KDEVERSION}/src/kde-l10n/kde-l10n-*.tar.xz .
 
91
    else
 
92
        # only get subset
 
93
        for pkg in $subset; do
 
94
            $REMOTE_GET_BASE/${TYPE}/${KDEVERSION}/src/kde-l10n/kde-l10n-$pkg-*.tar.xz .
 
95
        done
 
96
    fi
160
97
fi
161
98
 
162
99
for tfile in `ls kde-l10n-*.tar.xz`; do
163
 
  cd $WDIR
164
 
  cd build-area
165
 
 
166
 
  if [[ $tfile =~ kde-l10n-(.*)-$KDEVERSION.tar.xz ]]; then
167
 
    kdecode=${BASH_REMATCH[1]}
168
 
 
169
 
    # set mappings
170
 
    ubuntucode=$kdecode
171
 
    mapKdeCodeToUbuntu ubuntucode
172
 
 
173
 
    ubuntudep=$ubuntucode
174
 
    mapUbuntuNameToDep ubuntudep
175
 
    
176
 
    inputmethodpkg=$kdecode
177
 
    mapKdeCodeToIbusPkg inputmethodpkg
178
 
 
179
 
    # remove any left overs from previous runs
180
 
    rm -r kde-l10n-${ubuntucode}_${VERSION}.orig.tar.xz
181
 
 
182
 
    ln -s $tfile kde-l10n-${ubuntucode}_${VERSION}.orig.tar.xz
183
 
    tar xf kde-l10n-${ubuntucode}_${VERSION}.orig.tar.xz
184
 
 
185
 
    i=0
186
 
    while read line; do
187
 
      ((i++))
188
 
      if [ $i -eq 2 ]; then
189
 
        kdename=`echo "$line" | cut -f2 -d=`
190
 
        break
191
 
      fi
192
 
    done < kde-l10n-$kdecode-$KDEVERSION/messages/entry.desktop
193
 
    rm -rf kde-l10n-$kdecode-$KDEVERSION
194
 
 
195
 
##############################
196
 
    cd $WDIR
197
 
 
 
100
    cd $BUILD_DIR
 
101
 
 
102
    if [[ $tfile =~ kde-l10n-(.*)-$KDEVERSION.tar.xz ]]; then
 
103
        exportCodeMappings ${BASH_REMATCH[1]}
 
104
 
 
105
        ### TODO inputmethodpkg
 
106
 
 
107
        cd $BUILD_AREA_DIR
 
108
 
 
109
        # Remove any left overs from previous runs.
 
110
        rm -r kde-l10n-${UBUNTUCODE}_${VERSION}.orig.tar.xz
 
111
 
 
112
        ln -s $tfile kde-l10n-${UBUNTUCODE}_${VERSION}.orig.tar.xz
 
113
        tar xf kde-l10n-${UBUNTUCODE}_${VERSION}.orig.tar.xz
 
114
 
 
115
        # Read the spelled out name of the language from the desktop file
 
116
        # e.g. 'German' for 'de'. This will be used to substitute Description
 
117
        # fields in the debian/control file.
 
118
        ### TODO: probably should be a function
 
119
        i=0
 
120
        while read line; do
 
121
            ((i++))
 
122
            if [ $i -eq 2 ]; then
 
123
                export KDENAME=`echo "$line" | cut -f2 -d=`
 
124
                break
 
125
            fi
 
126
        done < kde-l10n-$KDECODE-$KDEVERSION/messages/entry.desktop
 
127
        rm -rf kde-l10n-$KDECODE-$KDEVERSION
 
128
    else
 
129
        echo "!!! SKIPPING $tfile BECAUSE THE VERSION COULD NOT BE PARSED!!!"
 
130
        continue
 
131
    fi
 
132
 
 
133
    inputmethodpkg=$KDECODE
 
134
    kdeCodeToIBusPackage inputmethodpkg
 
135
    export ADDITIONALDEPS="$inputmethodpkg"
 
136
 
 
137
    cd $BUILD_DIR
198
138
    bzr branch $CO kde-l10n-$kdecode
199
139
 
200
140
    cd kde-l10n-$kdecode/debian/
201
 
    for dfile in `ls`; do
202
 
      sed -i "s/he/$ubuntudep/g" $dfile
203
 
      sed -i "s/he/$ubuntucode/g" $dfile
204
 
      sed -i "s/he/$kdecode/g" $dfile
205
 
      sed -i "s/Hebrew/$kdename/g" $dfile
206
 
      if [ -z "$inputmethodpkg" ]; then
207
 
      else
208
 
      fi
209
 
      sed -i "s/# ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !#
210
 
# DO NOT EVEN THINK ABOUT CHANGING THIS FILE DIRECTLY! ! ! !
211
 
# PLEASE USE THE BZR BRANCH AS SEEN IN debian/control
212
 
# MAKE YOUR CHANGES THERE AND THEN RUN debian/build-l10n.sh
213
 
# kthxbai :)
214
 
################################################################################
215
 
################################################################################
216
 
################################################################################
217
 
################################################################################/$BOILERPLATE/g" $dfile
 
141
    for debian_file in `ls`; do
 
142
        gsubDebianFile $debian_file
218
143
    done
219
144
 
220
145
    bzr-buildpackage -S --builder "dpkg-buildpackage -S -us -uc"
221
146
    cd ../..
222
 
 
223
 
    bzr branch $CO-langpack language-pack-kde-$ubuntudep
224
 
 
225
 
    cd language-pack-kde-$ubuntudep/debian/
226
 
    for dfile in `ls`; do
227
 
      sed -i "s/he/$ubuntudep/g" $dfile
228
 
      sed -i "s/he/$ubuntucode/g" $dfile
229
 
      sed -i "s/he/$kdecode/g" $dfile
230
 
      sed -i "s/Hebrew/$kdename/g" $dfile
231
 
      sed -i "s/# ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !#
232
 
# DO NOT EVEN THINK ABOUT CHANGING THIS FILE DIRECTLY! ! ! !
233
 
# PLEASE USE THE BZR BRANCH AS SEEN IN debian/control
234
 
# MAKE YOUR CHANGES THERE AND THEN RUN debian/build-l10n.sh
235
 
# kthxbai :)
236
 
################################################################################
237
 
################################################################################
238
 
################################################################################
239
 
################################################################################/$BOILERPLATE/g" $dfile
240
 
    done
241
 
 
242
 
    CALLIGRA=`apt-cache policy calligra-l10n-${kdecode}`
243
 
    if [[ -n $CALLIGRA ]]; then 
244
 
        sed -i "s/^Depends:.*/&, calligra-l10n-${kdecode}/" control
245
 
    fi
246
 
 
247
 
    if [[ $ubuntudep != $kdecode ]]; then
248
 
        echo $ubuntudep NOT $kdecode
249
 
        sed -i "s/^Depends:.*/&, kde-l10n-${ubuntucode}/" control
250
 
 
251
 
        CALLIGRA=`apt-cache policy calligra-l10n-${ubuntucode}`
252
 
        if [[ -n $CALLIGRA ]]; then 
253
 
           sed -i "s/^Depends:.*/&, calligra-l10n-${ubuntucode}/" control
254
 
        fi
255
 
    fi
256
 
 
257
 
    bzr-buildpackage -S --builder "dpkg-buildpackage -S -us -uc"
258
 
  fi
259
147
done