3 # repack_release.sh - repack sdcc Linux, Mac OS X and Windows
4 # snapshot build source, binary and doc packages into a sdcc
7 # Copyright (c) 2009-2012 Borut Razem
9 # This file is part of SDCC.
11 # This software is provided 'as-is', without any express or implied
12 # warranty. In no event will the authors be held liable for any damages
13 # arising from the use of this software.
15 # Permission is granted to anyone to use this software for any purpose,
16 # including commercial applications, and to alter it and redistribute it
17 # freely, subject to the following restrictions:
19 # 1. The origin of this software must not be misrepresented; you must not
20 # claim that you wrote the original software. If you use this software
21 # in a product, an acknowledgment in the product documentation would be
22 # appreciated but is not required.
23 # 2. Altered source versions must be plainly marked as such, and must not be
24 # misrepresented as being the original software.
25 # 3. This notice may not be removed or altered from any source distribution.
28 # borut.razem@gmail.com
31 # ./repack_release.sh -dl -pr -ul 20090314 5413 2.9.0-rc1
34 # Uncomment next line to debug this script
37 function fatal_error
()
39 echo "repack_release: $1" 1>&2
46 echo "Usage: repack_release.sh [-h] [--help] [-dl] [-pr] [-ul] <date> <revision> <version>" 1>&2
47 echo "Repack sdcc Linux, Mac OS X and Windows snapshot build source," 1>&2
48 echo "binary and doc packages into a sdcc release package." 1>&2
50 echo " -dl download before processing" 1>&2
51 echo " -pr process packages" 1>&2
52 echo " -ul upload after processing" 1>&2
53 echo " <none> download, process and upload" 1>&2
54 echo " -h --help print this usage and exit" 1>&2
55 echo "Arguments:" 1>&2
56 echo " <date> package date in YYYMMDD format, for example 20090314" 1>&2
57 echo " <revision> svn revision number, for example 5413" 1>&2
58 echo " <version> package version number, for example 2.9.0-rc1" 1>&2
65 local date=$1 revision
=$2
71 fatal_error
"Cannot cd to dl!"
74 wget https
://sourceforge.net
/projects
/sdcc
/files
/snapshot_builds
/sdcc-src
/sdcc-src-
${date}-${revision}.
tar.bz2
&& \
75 wget https
://sourceforge.net
/projects
/sdcc
/files
/snapshot_builds
/docs
/sdcc-doc-
${date}-${revision}.
tar.bz2
&& \
76 wget https
://sourceforge.net
/projects
/sdcc
/files
/snapshot_builds
/docs
/sdcc-doc-
${date}-${revision}.
zip && \
77 # wget http://sourceforge.net/projects/sdcc/files/snapshot_builds/i386-unknown-linux2.5/sdcc-snapshot-i386-unknown-linux2.5-${date}-${revision}.tar.bz2 && \
78 wget https
://sourceforge.net
/projects
/sdcc
/files
/snapshot_builds
/amd64-unknown-linux2.5
/sdcc-snapshot-amd64-unknown-linux2.5
-${date}-${revision}.
tar.bz2
&& \
79 wget https
://sourceforge.net
/projects
/sdcc
/files
/snapshot_builds
/i586-mingw32msvc
/sdcc-snapshot-i586-mingw32msvc-
${date}-${revision}.
zip && \
80 wget https
://sourceforge.net
/projects
/sdcc
/files
/snapshot_builds
/x86_64-w64-mingw32
/sdcc-snapshot-x86_64-w64-mingw32-
${date}-${revision}.
zip && \
81 wget https
://sourceforge.net
/projects
/sdcc
/files
/snapshot_builds
/x86_64-apple-macosx
/sdcc-snapshot-x86_64-apple-macosx-
${date}-${revision}.
tar.bz2 \
82 ) || fatal_error
"Cannot download snapshot build packages!"
84 # a rename is required when another snapshot is taken as the source for the release
85 # mv sdcc-snapshot-i386_universal-apple-macosx-${date}-${revision}.tar.bz2 sdcc-snapshot-universal-apple-macosx-${date}-${revision}.tar.bz2
94 local bin_pkg
=$1 doc_pkg
=$2
96 if [ -z "$(expr $(basename $bin_pkg) : 'sdcc-snapshot-\([^-]*-[^-]*-[^-]*\)-.*\.tar\.bz2')" ]
98 fatal_error
"$bin_pkg is not a sdcc binary package!"
103 fatal_error
"Directory sdcc already exists!"
106 tar -xjvf ${bin_pkg} || fatal_error
"Cannot unpack $bin_pkg!"
108 # remove unneeded directories produced by sdbinutils
109 rm -rf .
/sdcc
/include
112 rm -rf .
/sdcc
/share
/doc
113 rm -rf .
/sdcc
/share
/sdcc
/doc
115 tar -xjvf ${doc_pkg} -C .
/sdcc
/share
/sdcc || fatal_error
"Cannot unpack $doc_pkg!"
123 cp .
/sdcc
/share
/sdcc
/doc
/INSTALL.txt .
/sdcc
124 cp .
/sdcc
/share
/sdcc
/doc
/README.txt .
/sdcc
129 tar -cjvf ul
/sdcc-
${ver}-${arch}.tar.bz2 sdcc-${ver} || fatal_error "Cannot pack ul/sdcc-${ver}-${arch}.
tar.bz2
!"
130 mv sdcc-${ver} ${arch}
134 function repack_src()
136 local date=$1 revision=$2 ver=$3
139 tar -xjvf dl/sdcc-src-${date}-${revision}.tar.bz2 && \
140 mv sdcc sdcc-${ver} && \
141 tar -cjvf ul/sdcc-src-${ver}.tar.bz2 sdcc-${ver} && \
142 mv sdcc-${ver} sdcc-src-${ver} \
143 ) || fatal_error "Cannot repack the
source package
!"
147 function repack_win()
149 local date=$1 revision=$2 ver=$3 arch=$4
151 snapshot=../sdcc-src-${ver}
152 ver_maj=$(expr $ver : '\([0-9]*\)\.')
153 ver_min=$(expr $ver : '[0-9]*\.\([0-9]*\)\.')
154 ver_rev=$(expr $ver : '[0-9]*\.[0-9]*\.\([0-9]*\)')
156 if [[ ${arch} == *64* ]]
165 # - unpack WIN32 mingw daily snapshot sdcc-snapshot-i586-mingw32msvc-yyyymmdd-rrrr.zip
166 # to a clean directory (the option to create directories should be enabled).
167 # A sub directory sdcc is created (referenced as PKGDIR in continuation).
168 unzip dl/sdcc-snapshot-${arch}-${date}-${revision}.zip
172 fatal_error "Cannot
cd to sdcc
!"
174 # - remove the PKGDIR/doc/ directory
177 # - unpack sdcc-doc-yyyymmdd-rrrr.zip to the PKGDIR/doc directory
178 unzip ../dl/sdcc-doc-${date}-${revision}.zip
180 # - copy files sdcc/support/scripts/sdcc.ico and sdcc/support/scripts/sdcc.nsi
181 # (this file) from the sdcc Subversion snapshot to the PKGDIR directory
182 cp ${snapshot}/support/scripts/sdcc.nsi ${snapshot}/support/scripts/sdcc.ico .
184 # - copy file COPYING and COPYING3 from the sdcc Subversion snapshot to the PKGDIR directory,
185 # rename it to COPYING.txt and COPYING3.txt and convert it to DOS format:
186 cp ${snapshot}/COPYING COPYING.txt
188 cp ${snapshot}/sdas/COPYING3 COPYING3.txt
190 cp ${snapshot}/ChangeLog doc/ChangeLog.txt
191 todos doc/ChangeLog.txt
192 cp ${snapshot}/doc/README.txt doc/README.txt
195 # - run NSIS installer from PKGDIR directory:
196 # Define -DWIN64 if creating a 64bit package.
197 makensis -DFULL_DOC -DVER_MAJOR=${ver_maj} -DVER_MINOR=${ver_min} -DVER_REVISION=${ver_rev} -DVER_BUILD=${revision} ${win} sdcc.nsi
199 # - A setup file setup.exe is created in PKGDIR directory.
200 # Rename it to sdcc-x.x.x-setup.exe and upload it
201 # to sdcc download repository at sourceforge.net
202 cp setup.exe ../ul/sdcc-${ver}-${setup}.exe
215 raw_ver=$(expr $ver : '\([0-9]*\.[0-9]*\.[0-9]*\)')
217 echo uploading ul/sdcc-src-${ver}.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc/${raw_ver}/
218 rsync -v --progress -e ssh ul/sdcc-src-${ver}.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc/${raw_ver}/
220 echo uploading ul/sdcc-doc-${ver}.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-doc/${raw_ver}/
221 rsync -v --progress -e ssh ul/sdcc-doc-${ver}.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-doc/${raw_ver}/
223 echo uploading ul/sdcc-doc-${ver}.zip ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-doc/${raw_ver}/
224 rsync -v --progress -e ssh ul/sdcc-doc-${ver}.zip ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-doc/${raw_ver}/
226 echo uploading ul/sdcc-${ver}-setup.exe ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-win32/${raw_ver}/
227 rsync -v --progress -e ssh ul/sdcc-${ver}-setup.exe ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-win32/${raw_ver}/
229 echo uploading ul/sdcc-${ver}-x64-setup.exe ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-win64/${raw_ver}/
230 rsync -v --progress -e ssh ul/sdcc-${ver}-x64-setup.exe ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-win64/${raw_ver}/
232 # echo uploading ul/sdcc-${ver}-i386-unknown-linux2.5.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-linux-x86/${raw_ver}/
233 # rsync -v --progress -e ssh ul/sdcc-${ver}-i386-unknown-linux2.5.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-linux-x86/${raw_ver}/
235 echo uploading ul/sdcc-${ver}-amd64-unknown-linux2.5.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-linux-amd64/${raw_ver}/
236 rsync -v --progress -e ssh ul/sdcc-${ver}-amd64-unknown-linux2.5.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-linux-amd64/${raw_ver}/
238 echo uploading ul/sdcc-${ver}-x86_64-apple-macosx.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-macosx-amd64/${raw_ver}/
239 rsync -v --progress -e ssh ul/sdcc-${ver}-x86_64-apple-macosx.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-macosx-amd64/${raw_ver}/
249 -dl) dl=1; has_opts=1; shift;;
250 -pr) pr=1; has_opts=1; shift;;
251 -ul) ul=1; has_opts=1; shift;;
252 -h|--help) usage; exit 0;;
253 -*) echo "Unknown option
$arg!"; usage; exit 1;;
263 test -z "$has_opts" && dl=1 && pr=1 && ul=1
271 # download the snapshots
272 test -n "$dl" && download ${date} ${revision}
277 repack_src ${date} ${revision} ${ver}
279 # repack the documentation
280 cp dl/sdcc-doc-${date}-${revision}.tar.bz2 ul/sdcc-doc-${ver}.tar.bz2
281 cp dl/sdcc-doc-${date}-${revision}.zip ul/sdcc-doc-${ver}.zip
283 # repack the *nix-like binaries
284 for arch in amd64-unknown-linux2.5 x86_64-apple-macosx
286 unpack dl/sdcc-snapshot-${arch}-${date}-${revision}.tar.bz2 dl/sdcc-doc-${date}-${revision}.tar.bz2
290 # repack the windows binaries
291 repack_win ${date} ${revision} ${ver} i586-mingw32msvc
292 repack_win ${date} ${revision} ${ver} x86_64-w64-mingw32
295 # upload the release packages
296 test -n "$ul" && upload ${ver} sdcc-builder