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 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
|
#! /bin/bash
# repack_release.sh - repack sdcc Linux, Mac OS X and Windows
# snapshot build source, binary and doc packages into a sdcc
# release package.
#
# Copyright (c) 2009-2012 Borut Razem
#
# This file is part of SDCC.
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
#
# Borut Razem
# borut.razem@gmail.com
# Example:
# ./repack_release.sh -dl -pr -ul 20090314 5413 2.9.0-rc1
# Uncomment next line to debug this script
#set -vx
function fatal_error()
{
echo "repack_release: $1" 1>&2
exit 1;
}
function usage()
{
echo "Usage: repack_release.sh [-h] [--help] [-dl] [-pr] [-ul] <date> <revision> <version>" 1>&2
echo "Repack sdcc Linux, Mac OS X and Windows snapshot build source," 1>&2
echo "binary and doc packages into a sdcc release package." 1>&2
echo "Options:" 1>&2
echo " -dl download before processing" 1>&2
echo " -pr process packages" 1>&2
echo " -ul upload after processing" 1>&2
echo " <none> download, process and upload" 1>&2
echo " -h --help print this usage and exit" 1>&2
echo "Arguments:" 1>&2
echo " <date> package date in YYYMMDD format, for example 20090314" 1>&2
echo " <revision> svn revision number, for example 5413" 1>&2
echo " <version> package version number, for example 2.9.0-rc1" 1>&2
exit 1;
}
function download()
{
local date=$1 revision=$2
mkdir -p dl
if ! pushd dl
then
fatal_error "Cannot cd to dl!"
else
( \
wget https://sourceforge.net/projects/sdcc/files/snapshot_builds/sdcc-src/sdcc-src-${date}-${revision}.tar.bz2 && \
wget https://sourceforge.net/projects/sdcc/files/snapshot_builds/docs/sdcc-doc-${date}-${revision}.tar.bz2 && \
wget https://sourceforge.net/projects/sdcc/files/snapshot_builds/docs/sdcc-doc-${date}-${revision}.zip && \
# wget http://sourceforge.net/projects/sdcc/files/snapshot_builds/i386-unknown-linux2.5/sdcc-snapshot-i386-unknown-linux2.5-${date}-${revision}.tar.bz2 && \
wget https://sourceforge.net/projects/sdcc/files/snapshot_builds/amd64-unknown-linux2.5/sdcc-snapshot-amd64-unknown-linux2.5-${date}-${revision}.tar.bz2 && \
wget https://sourceforge.net/projects/sdcc/files/snapshot_builds/i586-mingw32msvc/sdcc-snapshot-i586-mingw32msvc-${date}-${revision}.zip && \
wget https://sourceforge.net/projects/sdcc/files/snapshot_builds/x86_64-w64-mingw32/sdcc-snapshot-x86_64-w64-mingw32-${date}-${revision}.zip && \
wget https://sourceforge.net/projects/sdcc/files/snapshot_builds/x86_64-apple-macosx/sdcc-snapshot-x86_64-apple-macosx-${date}-${revision}.tar.bz2 \
) || fatal_error "Cannot download snapshot build packages!"
# a rename is required when another snapshot is taken as the source for the release
# mv sdcc-snapshot-i386_universal-apple-macosx-${date}-${revision}.tar.bz2 sdcc-snapshot-universal-apple-macosx-${date}-${revision}.tar.bz2
popd
fi
}
function unpack()
{
local bin_pkg=$1 doc_pkg=$2
if [ -z "$(expr $(basename $bin_pkg) : 'sdcc-snapshot-\([^-]*-[^-]*-[^-]*\)-.*\.tar\.bz2')" ]
then
fatal_error "$bin_pkg is not a sdcc binary package!"
fi
if [ -d sdcc ]
then
fatal_error "Directory sdcc already exists!"
fi
tar -xjvf ${bin_pkg} || fatal_error "Cannot unpack $bin_pkg!"
# remove unneeded directories produced by sdbinutils
rm -rf ./sdcc/include
rm -rf ./sdcc/lib
rm -rf ./sdcc/share/doc
rm -rf ./sdcc/share/sdcc/doc
tar -xjvf ${doc_pkg} -C ./sdcc/share/sdcc || fatal_error "Cannot unpack $doc_pkg!"
}
function pack()
{
local arch=$1 ver=$2
cp ./sdcc/share/sdcc/doc/INSTALL.txt ./sdcc
cp ./sdcc/share/sdcc/doc/README.txt ./sdcc
mkdir -p ul
mv sdcc sdcc-${ver}
tar -cjvf ul/sdcc-${ver}-${arch}.tar.bz2 sdcc-${ver} || fatal_error "Cannot pack ul/sdcc-${ver}-${arch}.tar.bz2!"
mv sdcc-${ver} ${arch}
}
function repack_src()
{
local date=$1 revision=$2 ver=$3
( \
tar -xjvf dl/sdcc-src-${date}-${revision}.tar.bz2 && \
mv sdcc sdcc-${ver} && \
tar -cjvf ul/sdcc-src-${ver}.tar.bz2 sdcc-${ver} && \
mv sdcc-${ver} sdcc-src-${ver} \
) || fatal_error "Cannot repack the source package!"
}
function repack_win()
{
local date=$1 revision=$2 ver=$3 arch=$4
snapshot=../sdcc-src-${ver}
ver_maj=$(expr $ver : '\([0-9]*\)\.')
ver_min=$(expr $ver : '[0-9]*\.\([0-9]*\)\.')
ver_rev=$(expr $ver : '[0-9]*\.[0-9]*\.\([0-9]*\)')
if [[ ${arch} == *64* ]]
then
win="-DWIN64"
setup="x64-setup"
else
win=
setup="setup"
fi
# - unpack WIN32 mingw daily snapshot sdcc-snapshot-i586-mingw32msvc-yyyymmdd-rrrr.zip
# to a clean directory (the option to create directories should be enabled).
# A sub directory sdcc is created (referenced as PKGDIR in continuation).
unzip dl/sdcc-snapshot-${arch}-${date}-${revision}.zip
if ! pushd sdcc
then
fatal_error "Cannot cd to sdcc!"
else
# - remove the PKGDIR/doc/ directory
rm -rf doc/
# - unpack sdcc-doc-yyyymmdd-rrrr.zip to the PKGDIR/doc directory
unzip ../dl/sdcc-doc-${date}-${revision}.zip
# - copy files sdcc/support/scripts/sdcc.ico and sdcc/support/scripts/sdcc.nsi
# (this file) from the sdcc Subversion snapshot to the PKGDIR directory
cp ${snapshot}/support/scripts/sdcc.nsi ${snapshot}/support/scripts/sdcc.ico .
# - copy file COPYING and COPYING3 from the sdcc Subversion snapshot to the PKGDIR directory,
# rename it to COPYING.txt and COPYING3.txt and convert it to DOS format:
cp ${snapshot}/COPYING COPYING.txt
todos COPYING.txt
cp ${snapshot}/sdas/COPYING3 COPYING3.txt
todos COPYING3.txt
cp ${snapshot}/ChangeLog doc/ChangeLog.txt
todos doc/ChangeLog.txt
cp ${snapshot}/doc/README.txt doc/README.txt
todos doc/README.txt
# - run NSIS installer from PKGDIR directory:
# Define -DWIN64 if creating a 64bit package.
makensis -DFULL_DOC -DVER_MAJOR=${ver_maj} -DVER_MINOR=${ver_min} -DVER_REVISION=${ver_rev} -DVER_BUILD=${revision} ${win} sdcc.nsi
# - A setup file setup.exe is created in PKGDIR directory.
# Rename it to sdcc-x.x.x-setup.exe and upload it
# to sdcc download repository at sourceforge.net
cp setup.exe ../ul/sdcc-${ver}-${setup}.exe
popd
mv sdcc ${arch}
fi
}
function upload()
{
local ver=$1 user=$2
raw_ver=$(expr $ver : '\([0-9]*\.[0-9]*\.[0-9]*\)')
echo uploading ul/sdcc-src-${ver}.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc/${raw_ver}/
rsync -v --progress -e ssh ul/sdcc-src-${ver}.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc/${raw_ver}/
echo uploading ul/sdcc-doc-${ver}.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-doc/${raw_ver}/
rsync -v --progress -e ssh ul/sdcc-doc-${ver}.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-doc/${raw_ver}/
echo uploading ul/sdcc-doc-${ver}.zip ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-doc/${raw_ver}/
rsync -v --progress -e ssh ul/sdcc-doc-${ver}.zip ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-doc/${raw_ver}/
echo uploading ul/sdcc-${ver}-setup.exe ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-win32/${raw_ver}/
rsync -v --progress -e ssh ul/sdcc-${ver}-setup.exe ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-win32/${raw_ver}/
echo uploading ul/sdcc-${ver}-x64-setup.exe ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-win64/${raw_ver}/
rsync -v --progress -e ssh ul/sdcc-${ver}-x64-setup.exe ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-win64/${raw_ver}/
# echo uploading ul/sdcc-${ver}-i386-unknown-linux2.5.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-linux-x86/${raw_ver}/
# 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}/
echo uploading ul/sdcc-${ver}-amd64-unknown-linux2.5.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-linux-amd64/${raw_ver}/
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}/
echo uploading ul/sdcc-${ver}-x86_64-apple-macosx.tar.bz2 ${user}@web.sourceforge.net:/home/pfs/project/sdcc/sdcc-macosx-amd64/${raw_ver}/
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}/
}
# main procedure
{
while [ -n "$1" ]
do
case "$1"
in
-dl) dl=1; has_opts=1; shift;;
-pr) pr=1; has_opts=1; shift;;
-ul) ul=1; has_opts=1; shift;;
-h|--help) usage; exit 0;;
-*) echo "Unknown option $arg!"; usage; exit 1;;
*) break;;
esac
done
if [ $# != 3 ]
then
usage
fi
test -z "$has_opts" && dl=1 && pr=1 && ul=1
date=$1
revision=$2
ver=$3
mkdir -p ul
# download the snapshots
test -n "$dl" && download ${date} ${revision}
if [ -n "$pr" ]
then
# repack the sources
repack_src ${date} ${revision} ${ver}
# repack the documentation
cp dl/sdcc-doc-${date}-${revision}.tar.bz2 ul/sdcc-doc-${ver}.tar.bz2
cp dl/sdcc-doc-${date}-${revision}.zip ul/sdcc-doc-${ver}.zip
# repack the *nix-like binaries
for arch in amd64-unknown-linux2.5 x86_64-apple-macosx
do
unpack dl/sdcc-snapshot-${arch}-${date}-${revision}.tar.bz2 dl/sdcc-doc-${date}-${revision}.tar.bz2
pack ${arch} ${ver}
done
# repack the windows binaries
repack_win ${date} ${revision} ${ver} i586-mingw32msvc
repack_win ${date} ${revision} ${ver} x86_64-w64-mingw32
fi
# upload the release packages
test -n "$ul" && upload ${ver} sdcc-builder
exit 0
}
|