-
Notifications
You must be signed in to change notification settings - Fork 5
/
mkdist
executable file
·199 lines (181 loc) · 9.01 KB
/
mkdist
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
#!/bin/sh
#
# Simple script for setting up an iFit distribution package.
#
# usage: mkdist 'dist-name'
#
# This command creates a distributable version of the current project.
# It assembles a ZIP with the source code.
# When 'mcc' is present, it triggers a stand-alone build and creates a ZIP.
# When 'dpkg-deb' is present it creates a Debian package after 'mcc'.
#
# example: mkdist 1.4
#
# requires: chroot, dpkg-deb, debootstrap
# optional: mcc (Matlab) to create binary standalone as zip and debian
# rpl to replace strings in files (apt-get install rpl)
# Version: $Revision$
# define version and symbols that will be replaced in many places
IFIT_TARNAME=ifit
IFIT_NAME=iFit
MONTH=`date +"%b"`
DAY=`date +"%d"`
YEAR=`date +"%Y"`
IFIT_DATE="$MONTH. $DAY, $YEAR"
if [ "y$1" = "y" ]; then
IFIT_VERSION="$YEAR.$MONTH.$DAY"
else
IFIT_VERSION=$1
fi
IFIT_STRING="$IFIT_NAME $IFIT_VERSION - $MONTH. $DAY, $YEAR"
IFIT_COPYING="(c) E. Farhi, Y. Debab and P. Willendrup 2007-2019. License: EUPL."
MATLAB=/opt/MATLAB/R2010a/bin/matlab
# alternative: this solves the readline crash with accent-characters at prompt.
# but requires the v90 MCR, which is 1.6 Gb, instead of 460 Mb with 2010a !
#MATLAB=/opt/MATLAB/R2015b/bin/matlab
# Create temporary workdir:
PW=`pwd`
TMPDIR=$PWD/..
DIST=$TMPDIR/$IFIT_TARNAME-$IFIT_VERSION
echo "Creating the temporary $DIST"
# Copy current PW checkout to DIST, and replace links with their targets
rm -rf $DIST
cp -rpL $PW $DIST
# Go in DIST, clean up CVS/SVN information
cd $DIST
echo "Clean up CVS/SVN info and temporary files"
find . -name CVS -exec rm -rf \{\} \; 2> /dev/null
find . -name .CVS -exec rm -rf \{\} \; 2> /dev/null
find . -name .git -exec rm -rf \{\} \; 2> /dev/null
find . -name CVSROOT -exec rm -rf \{\} \; 2> /dev/null
find . -name svn -exec rm -rf \{\} \; 2> /dev/null
find . -name .svn -exec rm -rf \{\} \; 2> /dev/null
find . -name "*~" -exec rm -rf \{\} \; 2> /dev/null
find . -name .AppleDouble -exec rm -rf \{\} \; 2> /dev/null
find . -name .AppleDB -exec rm -rf \{\} \; 2> /dev/null
find . -name .AppleDesktop -exec rm -rf \{\} \; 2> /dev/null
find . -name .DS_Store -exec rm -rf \{\} \; 2> /dev/null
rm mkdist
# we keep the MeX files as some users may not have C compilers installed (e.g. Windows 64 bit)
# rm Loaders/looktxt.mex*
# Update version and date
if [ -x `which rpl` ]
then
echo "Update revision/date/authors with rpl ..."
rpl -R -d -x'.m' -x'.html' -x'.md' -x'.txt' '@IFIT_VERSION@' "$IFIT_VERSION" .
rpl -R -d -x'.m' -x'.html' -x'.md' -x'.txt' '@IFIT_NAME@' "$IFIT_NAME" .
rpl -R -d -x'.m' -x'.html' -x'.md' -x'.txt' '@IFIT_TARNAME@' "$IFIT_TARNAME" .
rpl -R -d -x'.m' -x'.html' -x'.md' -x'.txt' '@IFIT_DATE@' "$IFIT_DATE" .
rpl -R -d -x'.m' -x'.html' -x'.md' -x'.txt' '@IFIT_COPYING@' "$IFIT_COPYING" .
rpl -R -i -d -x'.m' -x'.html' -x'.md' -x'.txt' '$Date$' "$IFIT_DATE" .
rpl -R -i -d -x'.m' -x'.html' -x'.md' -x'.txt' '$Revision$' "$IFIT_VERSION" .
rpl -R -i -d -x'.m' -x'.html' -x'.md' -x'.txt' '$Version$' "$IFIT_VERSION" .
rpl -R -i -d -x'.m' -x'.html' -x'.md' -x'.txt' '$Author$' "$IFIT_COPYING" .
fi
echo "Update revision/date/authors with sed (partial) ..."
for file in README.md Objects/@iData/version.m Docs/index.html Docs/Install.html Applications/standalone/deb/control Applications/standalone/deb/debcreate
do
sed 's/@IFIT_VERSION@/'$IFIT_VERSION'/' $file > $file.tmp
sed 's/@IFIT_NAME@/'$IFIT_NAME'/' $file.tmp > $file
sed 's/@IFIT_TARNAME@/'$IFIT_TARNAME'/' $file > $file.tmp
sed 's/@IFIT_DATE@/'$IFIT_DATE'/' $file.tmp > $file
sed 's/@IFIT_COPYING@/'$IFIT_COPYING'/' $file > $file.tmp
sed 's/$Date$/'$IFIT_DATE'/' $file.tmp > $file
sed 's/$Revision$/'$IFIT_VERSION'/' $file > $file.tmp
sed 's/$Version$/'$IFIT_VERSION'/' $file.tmp > $file
sed 's/$Author$/'$IFIT_COPYING'/' $file > $file.tmp
cp $file.tmp $file
rm $file.tmp
done
# find . -name "*.txt" -print0 | xargs -0 sed -i '' -e 's/foo/bar/g'
# detect architecture
arch=`uname -m`
if [ "$arch" = 'x86_64' ]; then
ARCH=amd64
else
ARCH=i386
fi
# create techdoc with m2html
$MATLAB -nodesktop -nosplash -r "addpath(genpath('$TMPDIR/$IFIT_TARNAME-$IFIT_VERSION')); m2html('mFiles',{'Libraries','Objects','Scripts','Applications','Tests'},'htmldir','Docs/techdoc','recursive','on','source','off','ignoredDir','private','graph','off'); exit"
cd $TMPDIR
# Create tar archive SRC
rm $PW/../$IFIT_TARNAME-$IFIT_VERSION-src.zip
zip -r $PW/../$IFIT_TARNAME-$IFIT_VERSION-src.zip $IFIT_TARNAME-$IFIT_VERSION
if [ -x `which mcc` ]
then
echo create the standalone version into $TMPDIR/$IFIT_TARNAME-$IFIT_VERSION-$ARCH
$MATLAB -nodesktop -nosplash -r "addpath(genpath('$TMPDIR/$IFIT_TARNAME-$IFIT_VERSION')); ifitdeploy('$TMPDIR/$IFIT_TARNAME-$IFIT_VERSION-$ARCH'); exit"
cd $TMPDIR
zip -r $IFIT_TARNAME-$IFIT_VERSION-$ARCH.zip $IFIT_TARNAME-$IFIT_VERSION-$ARCH
fi
if [ -e $TMPDIR/$IFIT_TARNAME-$IFIT_VERSION-$ARCH ]
then
cd $TMPDIR
echo converting $TMPDIR/$IFIT_TARNAME-$IFIT_VERSION-$ARCH into Debian package.
if [ -e /etc/debian_version ]
then
if [ -e build-chroot-$ARCH ]
then
BUILDDIR="build-chroot-$ARCH/build/$IFIT_TARNAME-$IFIT_VERSION"
echo Proceeding to $ARCH .deb build
echo from $TMPDIR/$IFIT_TARNAME-$IFIT_VERSION-$ARCH
echo into $BUILDDIR
# First, clean up in case of previous iFit installs in the chroot
sudo rm -rf ${BUILDDIR}
# install package in build location
sudo mkdir -p ${BUILDDIR}/DEBIAN
sudo mkdir -p ${BUILDDIR}/usr/local/bin
sudo mkdir -p ${BUILDDIR}/usr/local/$IFIT_TARNAME
sudo mkdir -p ${BUILDDIR}/usr/share/applications
sudo mkdir -p ${BUILDDIR}/usr/share/doc/$IFIT_TARNAME
sudo mkdir -p ${BUILDDIR}/usr/share/icons/$IFIT_TARNAME
sudo mkdir -p ${BUILDDIR}/usr/share/pixmaps
sudo cp -r $IFIT_TARNAME-$IFIT_VERSION-$ARCH/* ${BUILDDIR}/usr/local/$IFIT_TARNAME
sudo cp -r $IFIT_TARNAME-$IFIT_VERSION/Docs/* ${BUILDDIR}/usr/share/doc/$IFIT_TARNAME/
sudo cp $IFIT_TARNAME-$IFIT_VERSION/COPYING ${BUILDDIR}/usr/share/doc/$IFIT_TARNAME/copyright
sudo cp $IFIT_TARNAME-$IFIT_VERSION/README.md ${BUILDDIR}/usr/share/doc/$IFIT_TARNAME/
sudo cp $IFIT_TARNAME-$IFIT_VERSION/Applications/standalone/ifit.desktop \
${BUILDDIR}/usr/share/applications/
sudo cp $IFIT_TARNAME-$IFIT_VERSION/Applications/standalone/ResLibCal.desktop \
${BUILDDIR}/usr/share/applications/
sudo cp $IFIT_TARNAME-$IFIT_VERSION/Applications/standalone/miFit.desktop \
${BUILDDIR}/usr/share/applications/
sudo cp $IFIT_TARNAME-$IFIT_VERSION/Applications/standalone/sqw_phonons.desktop \
${BUILDDIR}/usr/share/applications/
sudo cp $IFIT_TARNAME-$IFIT_VERSION/Applications/standalone/pyfit.desktop \
${BUILDDIR}/usr/share/applications/
sudo cp $IFIT_TARNAME-$IFIT_VERSION/Applications/standalone/iFit-logo.png \
${BUILDDIR}/usr/share/pixmaps/
sudo cp $IFIT_TARNAME-$IFIT_VERSION/Applications/standalone/ResLibCal-logo.png \
${BUILDDIR}/usr/share/pixmaps/
sudo cp $IFIT_TARNAME-$IFIT_VERSION/Applications/standalone/SqwPhonons-logo.png \
${BUILDDIR}/usr/share/pixmaps/
sudo cp $IFIT_TARNAME-$IFIT_VERSION/Applications/standalone/deb/* \
${BUILDDIR}/DEBIAN
sudo cp $IFIT_TARNAME-$IFIT_VERSION/Applications/standalone/icons/*.png \
${BUILDDIR}/usr/share/icons/$IFIT_TARNAME/
# sudo chroot build-chroot-$ARCH apt-get update
sudo cp $IFIT_TARNAME-$IFIT_VERSION/Applications/standalone/deb/debcreate build-chroot-$ARCH/root/debcreate
sudo chmod u+x build-chroot-$ARCH/root/debcreate
sudo chroot build-chroot-$ARCH /root/debcreate $IFIT_VERSION $ARCH
echo
echo Build packages created:
echo
cp build-chroot-$ARCH/build/*deb .
ls -lf $IFIT_TARNAME-$IFIT_VERSION*.* $IFIT_TARNAME-$IFIT_VERSION*.*
echo
else
echo Can not find build-chroot-$ARCH
echo You need a chroot environment based on debootstrap in e.g. build-chroot-$ARCH before building the $ARCH deb package - create using something like
echo sudo debootstrap --arch $ARCH precise build-chroot-$ARCH
fi # build chroot present
else
echo This is not a Debian based system...
fi # debian
else
echo Can not find $TMPDIR/$IFIT_TARNAME-$IFIT_VERSION-$ARCH
fi # $ARCH build
echo "========================================================================="
echo "mkdist: Distro creation for $IFIT_STRING"
echo Your $IFIT_STRING dist packages are placed in
echo ../$IFIT_TARNAME-$IFIT_VERSION-src.zip