~vcs-imports/parcellite/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Copyright (C) 2011-2013 by rickyrockrat <gpib at rickyrockrat dot net>
#
# This file is part of Parcellite.
#
# Parcellite is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Parcellite is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

PURL="https://parcellite.svn.sourceforge.net"
BURL="$PURL/svnroot/parcellite"

# description
check_err () {
  if [ $? -ne 0 ]; then
		echo "$1 Failed. Abort"
		exit 1
	fi
}
# Make sure we are checked in.
check_local () {
  echo "$FUNCNAME"
  M=$(svn st|grep -c "^M")
  if [ "$M" != "0" ]; then
    echo "local is not up to date"
    if [ $1 -eq 1 ]; then
      return
    fi
    exit 1
  fi
}
# Ask user what version
ask_version () {
  echo "$FUNCNAME"
  if [ -n "$tag" ]; then
    return
  fi
  echo "Tag to operate on (copy to or build deb from)?"
  read tag
  turl="$BURL/tags/$tag"
  tdir="parcellite-$tag"
  CODIR="$ASVN/test.$tag"
  debdir="parcellite_$tag"
}
# Copy the trunk to tag
svn_cp_to_tag () {
  echo "$FUNCNAME"
  ask_version
  E=$(svn ls $turl --depth empty 2>&1|grep -c "non-exist")
  if [ "$E" = "0" ]; then
    echo "$turl exists."
    exit 1
  fi
  if [ -e "$CODIR" ]; then
    echo "$CODIR exists. Refusing to overwrite."
    exit 1
  fi
  echo "Description for tag?"
  read desc
  echo "Contacting $PURL for svn cp"
  svn cp -m"$desc" $BURL/trunk $turl
  check_err "svn copy"
}
#Check to be sure we have the correct directory orientation
set_svn_local (){
  echo "$FUNCNAME"
  S=$(grep -c "$BURL" "$CDIR/.svn/entries")
  if [ "$S" = "0" ]; then	
    echo "$CDIR does not appear to be a working local copy"
	  exit 1
  fi
 ASVN=$(dirname "$CDIR")
 if [ -e "$ASVN/.svn" ]; then
   echo "directory '$ASVN should NOT be under svn"
   exit 1
 fi
}
# make check out dir and and check out tag
test_tag_co () {
  echo "$FUNCNAME"
  mkdir -p "$CODIR"
  check_err "mkdir co"
  cd "$CODIR"
  if [ -e $tdir/.svn ] ; then
    echo "$CODIR/$tag alread exists. Not re-checking out"
    return
  fi
  echo "performing svn co $turl"
  svn co "$turl"
  check_err "svn co"
  mv $tag $tdir
  check_err "mv svn co dir"
  cd $tdir
  check_err "cd $tdir"
  rm svnversion.sh
  check_err "rm svnver"
  sed -i "s/\(AC_INIT.*\)m4_.*)\(.*rickyrockrat.*\)/\1[$tag]\2/" configure.ac
  check_err "update configure.ac"
  ./autogen.sh
}
# Make the tarball
make_tarball () {
  echo "$FUNCNAME"
  cd "$CODIR"
  check_err "cd $CODIR"
  tar --exclude .svn -czf $tdir.tar.gz $tdir
  check_err "tar -c"
}
# test the tar ball
test_tarball() {
  echo "$FUNCNAME"
  cd "$CODIR"
  check_err "cd dir"
  mkdir tar_test
  check_err "mkdir tar_test"
  cd tar_test
  tar -xzf ../$tdir.tar.gz
  check_err "untar"
  cd "$tdir"
  check_err "cd tardir"
  ./configure
  check_err "config"
  make
  check_err "make"
}
# build the deb package files
# the arg is configure options passed to the deb build, i.e.
# --enable-appindicator=no
build_deb () {
  echo "$FUNCNAME"
  cd "$CODIR/tar_test/$tdir"
  check_err "cd tar_test" 
  ./build-debpkg.sh ../../$tdir.tar.gz "$1"
  check_err "build deb"
  cd ..
  mv *.deb ..
}
# set our absolute path (or try to)
set_abs_path () {
  CDIR=$(dirname $0)
  T=$(dirname $CDIR)
  if [ "$T" = "$CDIR" ]; then # ./ invocation
    CDIR=$(pwd)
  fi
  echo "Using '$CDIR'"
}
# build the ppa & send it to launchpad
setup_ppa (){
 echo "$FUNCNAME"
 cd "$CODIR"
 check_err "CD $CODIR"
 mkdir -p ppa/t/debian
 cp -a $tdir ppa/$debdir
 cd ppa
 check_err "mkdir/cd ppa"
 tar --exclude .svn -czf $debdir.orig.tar.gz $debdir
 check_err "tar for ppa"
 cp $debdir/deb/* t/debian
 echo "What series does this apply to? (i.e. precise/natty,etc)"
 read SERIES
#build changelog
 echo "parcellite (${tag}-1ppa1) $SERIES; urgency=low" > t/debian/changelog
 cat $debdir/ChangeLog |while read line; do 
  if [ $(echo "$line"|grep -c V1.0.2rc5) -gt 0 ]; 
    then break 
  else 
    echo "$line"| sed 's!^.*+!  - !;s!^V!  * V!'|grep -v Changes>> t/debian/changelog
  fi 
 done
 DATE=$(date -R)
 echo " -- Doug Springer <gpib@rickyrockrat.net>  $DATE" >> t/debian/changelog
# setup control
 sed -i 's!ADD_ARCH_HERE!any!' t/debian/control
#build rules
 echo "#!/usr/bin/make -f" > t/debian/rules
 echo "# -*- makefile -*-">> t/debian/rules
 echo "# Uncomment this to turn on verbose mode.">> t/debian/rules
 echo "#export DH_VERBOSE=1">> t/debian/rules
 echo " ">> t/debian/rules
 echo "%:">> t/debian/rules
 echo -n -e '\t'>> t/debian/rules
 echo 'dh $@ '>> t/debian/rules
 echo "DEB_CONFIGURE_EXTRA_FLAGS += --enable-appindicator=yes">> t/debian/rules
 cd t
 gpg --list-keys
 echo "Which key? 2048R/ABCDEF12 - just need the ABC part"
 read KEYID
 debuild -S -sa "-k $KEYID"
 check_err "debuild"
 cd ..
 dput ppa:rickyrockrat/ppa ${debdir}-1ppa1_source.changes
 check_err "dput"
}
# show the links for the user to copy.
show_links () {
echo "Source Forge Links"
echo "The source can be <a href=\"http://sourceforge.net/projects/parcellite/files/parcellite/parcellite-$tag/parcellite-$tag.tar.gz/download\">downloaded here</a>."
echo "<a href=\"http://sourceforge.net/projects/parcellite/files/parcellite/parcellite-$tag/parcellite_$tag-1_i386.deb/download\">i386</a>"
echo "<a href=\"http://sourceforge.net/projects/parcellite/files/parcellite/parcellite-$tag/parcellite_$tag-1_amd64.deb/download\">amd64</a>."
}