aboutsummaryrefslogtreecommitdiff
path: root/makedist
blob: 0cc247d3fd3029db2cb89397efa53e95201e4171 (plain)
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
#!/bin/bash -e

if ! [ "$1" ]
then
   echo "usage: $0 <version>"
   exit 1
fi

if ! [ -d ".git" ]
then
   echo "Should be run from the LuaRocks git repo dir."
   exit 1
fi

make clean || exit 1

version=$1
shift

#-------------------------------------------------------------------------------
if ! [ "$version" = "dev" ]
then

# e.g. if $version is "2.3.0", $xyversion is "2.3"
xyversion=${version%.*}

ROCKSPEC="luarocks-$version-1.rockspec"

if [ "$1" = "branch" ]
then
   shift

   if git show $version &> /dev/null
   then
      echo "Branch $version already exists."
      exit 1
   fi

   git reset
   git checkout .
   git checkout -B $version
   ROCKSPEC="luarocks-$version-1.rockspec"
   currentrockspec=$(ls luarocks-*.rockspec)
   if [ "$currentrockspec" != "$ROCKSPEC" ] && ! [ -e "$ROCKSPEC" ]
   then
      git mv luarocks-*.rockspec "$ROCKSPEC"
   fi
   sed -i 's/"Configuring LuaRocks version .*"/"Configuring LuaRocks version '$version'..."/' configure
   sed -i 's/version = "[^"]*"/version = "'$version'-1"/' $ROCKSPEC
   sed -i 's/\(   url = "[^"]*",\)/\1\n   tag = "v'$version'"/' $ROCKSPEC
   sed -i 's/program_version = "[^"]*"/program_version = "'$version'"/' src/luarocks/core/cfg.lua
   sed -i 's/version: [0-9.]*/version: '$version'./' appveyor.yml
   sed -i 's/LUAROCKS_VER: [0-9.]*/LUAROCKS_VER: '$version'/' appveyor.yml
   sed -i 's/vars.VERSION = "[0-9.]*"/vars.VERSION = "'$xyversion'"/' install.bat
   echo "==============================================================================="
   git diff
   echo "==============================================================================="
   echo "Does the change look alright? Press 'y' to commit"
   echo "==============================================================================="
   read
   if [ "$REPLY" = "y" ]
   then
      git commit -av -m "Release $version"
   fi
fi


[ -e "$ROCKSPEC" ] || {
   echo
   echo "$ROCKSPEC is missing. Please check rockspec version is correct."
}

grep -q "LuaRocks version $version" "configure" || {
   echo
   echo "version in configure is incorrect. Please fix it."
   exit 1
}

grep -q "\"$version-1\"" "$ROCKSPEC" || {
   echo
   echo "version in rockspec is incorrect. Please fix it."
   exit 1
}

grep -q "program_version = \"$version\"" src/luarocks/core/cfg.lua || {
   echo
   echo "program_version in src/luarocks/core/cfg.lua is incorrect. Please fix it."
   exit 1
}

grep -q "version: $version\\." appveyor.yml || {
   echo
   echo "version in appveyor.yml is incorrect. Please fix it."
   exit 1
}

grep -q "LUAROCKS_VER: $version" appveyor.yml || {
   echo
   echo "LUAROCKS_VER in appveyor.yml is incorrect. Please fix it."
   exit 1
}

grep -q "vars.VERSION = \"$xyversion\"" install.bat || {
   echo
   echo "vars.VERSION in install.bat is incorrect. Please fix it."
   exit 1
}

fi # if ! [ "$version" = "dev" ]
#-------------------------------------------------------------------------------

out="luarocks-$version"
rm -rf "$out"
mkdir "$out"

git ls-files | while read i
do
   if [ -f "$i" ]
   then
      dir=`dirname $i`
      mkdir -p "$out/$dir"
      cp "$i" "$out/$dir"
   fi
done

rm -rf "release-unix" "release-windows" "$out.tar.gz" "$out-win32.zip"

mkdir "release-unix"
cp -a "$out" "release-unix"
mkdir "release-windows"
mv "$out" "release-windows/$out-win32"

cd "release-unix/$out"
rm -rf makedist install.bat win32 .github .gitignore appveyor* .appveyor
cd ..
tar czvpf ../"$out.tar.gz" "$out"
rm -f ../"$out.tar.gz.asc"
cd ..
rm -rf "release-unix"

cd "release-windows/$out-win32"
rm -rf makedist Makefile GNUmakefile configure .github .gitignore test appveyor* .appveyor
cd ..
zip -r ../"$out-win32.zip" "$out-win32"
rm -f ../"$out-win32.zip.asc"
cd ..
rm -rf "release-windows"

if [ "$1" = "binary" ]
then
   shift

   ./configure --lua-version=5.4

   make binary
   cd build-binary
   mkdir "$out-linux-x86_64"
   cp luarocks.exe "$out-linux-x86_64/luarocks"
   cp luarocks-admin.exe "$out-linux-x86_64/luarocks-admin"
   zip "../$out-linux-x86_64.zip" "$out-linux-x86_64"/*
   cd ..
   rm -f "$out-linux-x86_64.zip.asc"

   make windows-binary-32
   cd build-windows-binary-i686-w64-mingw32
   mkdir "$out-windows-32"
   cp luarocks.exe "$out-windows-32/luarocks.exe"
   cp luarocks-admin.exe "$out-windows-32/luarocks-admin.exe"
   zip "../$out-windows-32.zip" "$out-windows-32"/*
   cd ..
   rm -f "$out-windows-32.zip.asc"

   make windows-binary-64
   cd build-windows-binary-x86_64-w64-mingw32
   mkdir "$out-windows-64"
   cp luarocks.exe "$out-windows-64/luarocks.exe"
   cp luarocks-admin.exe "$out-windows-64/luarocks-admin.exe"
   zip "../$out-windows-64.zip" "$out-windows-64"/*
   cd ..
   rm -f "$out-windows-64.zip.asc"

fi

if [ "$1" = "sign" ]
then
   shift

   for f in \
      $out-windows-32.zip \
      $out-windows-64.zip \
      $out-linux-x86_64.zip \
      $out-win32.zip \
      $out.tar.gz
   do
      [ -e "$f" -a ! -e "$f.asc" ] && gpg --armor --output "$f.asc" --detach-sign "$f"
   done
fi