aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhillip Lord2017-10-24 18:34:35 +0100
committerPhillip Lord2017-10-24 18:34:35 +0100
commit3fc05cfaecf03a249bb9df1a9566d16ec005c7c3 (patch)
tree5a5ec4c2f4fac8f8d54136d406a456de6e5f986a
parent928a106939080df7df6ea158318f5afa5579ddcf (diff)
downloademacs-3fc05cfaecf03a249bb9df1a9566d16ec005c7c3.tar.gz
emacs-3fc05cfaecf03a249bb9df1a9566d16ec005c7c3.zip
Scripts to automate windows binary distribution
* admin/nt/dist-build/README-windows-binaries, admin/nt/dist-build/build-dep-zips.py, admin/nt/dist-build/build-zips.sh: New Files
-rw-r--r--admin/nt/dist-build/README-windows-binaries45
-rwxr-xr-xadmin/nt/dist-build/build-dep-zips.py223
-rwxr-xr-xadmin/nt/dist-build/build-zips.sh143
3 files changed, 411 insertions, 0 deletions
diff --git a/admin/nt/dist-build/README-windows-binaries b/admin/nt/dist-build/README-windows-binaries
new file mode 100644
index 00000000000..27a5483c02b
--- /dev/null
+++ b/admin/nt/dist-build/README-windows-binaries
@@ -0,0 +1,45 @@
1Windows Binaries
2================
3
4Currently, we provide four different binary packages for Emacs, which
5are:
6
7emacs-$VERSION-x86_64.zip
8
9Contains a 64-bit build of Emacs with dependencies. Mostly, this is
10the best one to install.
11
12emacs-$VERSION-x86_64-no-deps.zip
13
14Contains a 64-bit build of Emacs without any dependencies. This may be
15useful if you wish to install where the dependencies are already
16available, or if you want the small possible Emacs.
17
18emacs-$VERSION-i686.zip
19
20Contains a 32-bit build of Emacs with dependencies. This is useful for
21running on a 32-bit machine.
22
23emacs-$VERSION-i686-no-deps.zip
24
25Contains a 32-bit build of Emacs without dependencies
26
27In addition, we provide the following files which will not be useful
28for most end-users.
29
30emacs-26-x86_64-deps.zip
31
32The dependencies. Unzipping this file on top of
33emacs-$VERSION-x86_64-no-deps.zip should result in the same install as
34emacs-$VERSION-x86_64.zip.
35
36emacs-26-i686-deps.zip
37
38The 32-bit version of the dependencies.
39
40emacs-26-deps-mingw-w64-src.zip
41
42The source for the dependencies. Source for Emacs itself is available
43in the main distribution tarball. These dependencies were produced
44from an updated msys2 at the point of the first pre-test. It is not
45intended that these will be updated after that point. \ No newline at end of file
diff --git a/admin/nt/dist-build/build-dep-zips.py b/admin/nt/dist-build/build-dep-zips.py
new file mode 100755
index 00000000000..33bc4b586c9
--- /dev/null
+++ b/admin/nt/dist-build/build-dep-zips.py
@@ -0,0 +1,223 @@
1#!/usr/bin/python3
2
3## Copyright (C) 2017 Free Software Foundation, Inc.
4
5## This file is part of GNU Emacs.
6
7## GNU Emacs is free software: you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation, either version 3 of the License, or
10## (at your option) any later version.
11
12## GNU Emacs is distributed in the hope that it will be useful,
13## but WITHOUT ANY WARRANTY; without even the implied warranty of
14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15## GNU General Public License for more details.
16
17## You should have received a copy of the GNU General Public License
18## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19import argparse
20import multiprocessing as mp
21import glob
22import os
23import shutil
24import re
25
26from subprocess import check_output
27
28## Constants
29EMACS_MAJOR_VERSION="26"
30
31
32## Options
33DRY_RUN=False
34
35## Packages to fiddle with
36SKIP_PKGS=["mingw-w64-gcc-libs"]
37MUNGE_PKGS ={"mingw-w64-libwinpthread-git":"mingw-w64-winpthreads-git"}
38ARCH_PKGS=["mingw-w64-mpc",
39 "mingw-w64-termcap",
40 "mingw-w64-xpm-nox"]
41SRC_REPO="https://sourceforge.net/projects/msys2/files/REPOS/MINGW/Sources"
42
43
44def check_output_maybe(*args,**kwargs):
45 if(DRY_RUN):
46 print("Calling: {}{}".format(args,kwargs))
47 else:
48 return check_output(*args,**kwargs)
49
50def extract_deps():
51
52 # This list derives from the features we want Emacs to compile with.
53 PKG_REQ='''mingw-w64-x86_64-giflib
54mingw-w64-x86_64-gnutls
55mingw-w64-x86_64-libjpeg-turbo
56mingw-w64-x86_64-libpng
57mingw-w64-x86_64-librsvg
58mingw-w64-x86_64-libtiff
59mingw-w64-x86_64-libxml2
60mingw-w64-x86_64-xpm-nox
61mingw-w64-x86_64-lcms2'''.split()
62
63 # Get a list of all dependencies needed for packages mentioned above.
64 # Run `pactree -lu' for each elment of $PKG_REQ
65 pkgs = set()
66 for x in PKG_REQ:
67 pkgs.update(
68 check_output(["pactree", "-lu", x]).decode("utf-8").split()
69 )
70
71 return sorted(pkgs)
72
73def gather_deps(deps, arch, directory):
74
75 os.mkdir(arch)
76 os.chdir(arch)
77
78 ## Replace the architecture with the correct one
79 deps = [re.sub(r"x86_64",arch,x) for x in deps]
80
81 ## find all files the transitive dependencies
82 deps_files = check_output(
83 ["pacman", "-Ql"] + deps
84 ).decode("utf-8").split("\n")
85
86 ## Produces output like
87 ## mingw-w64-x86_64-zlib /mingw64/lib/libminizip.a
88
89 ## drop the package name
90 tmp = deps_files.copy()
91 deps_files=[]
92 for d in tmp:
93 slt = d.split()
94 if(not slt==[]):
95 deps_files.append(slt[1])
96
97 ## sort uniq
98 deps_files = sorted(list(set(deps_files)))
99 ## copy all files into local
100 print("Copying dependencies: {}".format(arch))
101 check_output_maybe(["rsync", "-R"] + deps_files + ["."])
102
103 ## And package them up
104 os.chdir(directory)
105 print("Zipping: {}".format(arch))
106 check_output_maybe("zip -9r ../../emacs-26-{}-deps.zip *".format(arch),
107 shell=True)
108 os.chdir("../../")
109
110
111def download_source(tarball):
112 print("Downloading {}...".format(tarball))
113 check_output_maybe(
114 "wget -a ../download.log -O {} {}/{}/download"
115 .format(tarball, SRC_REPO, tarball),
116 shell=True
117 )
118 print("Downloading {}... done".format(tarball))
119
120def gather_source(deps):
121
122
123 ## Source for gcc-libs is part of gcc
124 ## Source for libwinpthread is in libwinpthreads
125 ## mpc, termcap, xpm -- has x86_64, and i686 versions
126
127 ## This needs to have been run first at the same time as the
128 ## system was udpated.
129 os.mkdir("emacs-src")
130 os.chdir("emacs-src")
131
132 to_download = []
133 for pkg in deps:
134 pkg_name_and_version= \
135 check_output(["pacman","-Q", pkg]).decode("utf-8").strip()
136
137 ## Produces output like:
138 ## mingw-w64-x86_64-zlib 2.43.2
139 pkg_name_components = pkg_name_and_version.split()
140 pkg_name=pkg_name_components[0]
141 pkg_version=pkg_name_components[1]
142
143 ## make a simple name to make lookup easier
144 simple_pkg_name = re.sub(r"x86_64-","",pkg_name)
145
146 if(simple_pkg_name in SKIP_PKGS):
147 continue
148
149 ## Some packages have different source files for different
150 ## architectures. For these we need two downloads.
151 if(simple_pkg_name in ARCH_PKGS):
152 downloads = [pkg_name,
153 re.sub(r"x86_64","i686",pkg_name)]
154 else:
155 downloads = [simple_pkg_name]
156
157 for d in downloads:
158 ## Switch names if necessary
159 d = MUNGE_PKGS.get(d,d)
160
161 tarball = "{}-{}.src.tar.gz".format(d,pkg_version)
162
163 to_download.append(tarball)
164
165 ## Download in parallel or it is just too slow
166 p = mp.Pool(16)
167 p.map(download_source,to_download)
168
169 print("Zipping")
170 check_output_maybe("zip -9 ../emacs-{}-deps-mingw-w64-src.zip *"
171 .format(EMACS_MAJOR_VERSION),
172 shell=True)
173
174 os.chdir("..")
175
176
177def clean():
178 print("Cleaning")
179 os.path.isdir("emacs-src") and shutil.rmtree("emacs-src")
180 os.path.isdir("i686") and shutil.rmtree("i686")
181 os.path.isdir("x86_64") and shutil.rmtree("x86_64")
182 os.path.isfile("download.log") and os.remove("download.log")
183
184
185if(os.environ["MSYSTEM"] != "MSYS"):
186 print("Run this script in an MSYS-shell!")
187 exit(1)
188
189
190parser = argparse.ArgumentParser()
191parser.add_argument("-t", help="32 bit deps only",
192 action="store_true")
193
194parser.add_argument("-f", help="64 bit deps only",
195 action="store_true")
196
197parser.add_argument("-s", help="source code only",
198 action="store_true")
199
200parser.add_argument("-c", help="clean only",
201 action="store_true")
202
203parser.add_argument("-d", help="dry run",
204 action="store_true")
205
206args = parser.parse_args()
207do_all=not (args.c or args.s or args.f or args.t)
208
209deps=extract_deps()
210
211DRY_RUN=args.d
212
213if( do_all or args.t ):
214 gather_deps(deps,"i686","mingw32")
215
216if( do_all or args.f ):
217 gather_deps(deps,"x86_64","mingw64")
218
219if( do_all or args.s ):
220 gather_source(deps)
221
222if( args.c ):
223 clean()
diff --git a/admin/nt/dist-build/build-zips.sh b/admin/nt/dist-build/build-zips.sh
new file mode 100755
index 00000000000..e78f72cf9c3
--- /dev/null
+++ b/admin/nt/dist-build/build-zips.sh
@@ -0,0 +1,143 @@
1#!/bin/bash
2
3## Copyright (C) 2017 Free Software Foundation, Inc.
4
5## This file is part of GNU Emacs.
6
7## GNU Emacs is free software: you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation, either version 3 of the License, or
10## (at your option) any later version.
11
12## GNU Emacs is distributed in the hope that it will be useful,
13## but WITHOUT ANY WARRANTY; without even the implied warranty of
14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15## GNU General Public License for more details.
16
17## You should have received a copy of the GNU General Public License
18## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20
21function git_up {
22 echo Making git worktree for Emacs $VERSION
23 cd $HOME/emacs-build/git/emacs-$MAJOR_VERSION
24 git pull
25 git worktree add ../emacs-$BRANCH emacs-$BRANCH
26
27 cd ../emacs-$BRANCH
28 ./autogen.sh
29
30}
31
32function build_zip {
33
34 ARCH=$1
35 PKG=$2
36 HOST=$3
37
38 echo Building Emacs-$VERSION for $ARCH
39 if [ $ARCH == "i686" ]
40 then
41 PATH=/mingw32/bin:$PATH
42 MSYSTEM=MINGW32
43 fi
44
45 mkdir --parents $HOME/emacs-build/build/emacs-$VERSION/$ARCH
46 cd $HOME/emacs-build/build/emacs-$VERSION/$ARCH
47
48 export PKG_CONFIG_PATH=$PKG
49 ../../../git/emacs-$BRANCH/configure \
50 --without-dbus \
51 --host=$HOST --without-compress-install \
52 CFLAGS="-O2 -static -g3"
53 make -j 8 install \
54 prefix=$HOME/emacs-build/install/emacs-$VERSION/$ARCH
55 cd $HOME/emacs-build/install/emacs-$VERSION/$ARCH
56 cp $HOME/emacs-build/deps/libXpm/$ARCH/libXpm-noX4.dll bin
57 zip -r -9 emacs-$VERSION-$ARCH-no-deps.zip *
58 mv emacs-$VERSION-$ARCH.zip $HOME/emacs-upload
59 rm bin/libXpm-noX4.dll
60 unzip $HOME/emacs-build/deps/emacs-26-$ARCH-deps.zip
61 zip -r -9 emacs-$VERSION-$ARCH.zip *
62 mv emacs-$VERSION-$ARCH.zip ~/emacs-upload
63}
64
65
66##set -o xtrace
67set -o errexit
68
69SNAPSHOT=
70
71BUILD_32=1
72BUILD_64=1
73GIT_UP=0
74
75while getopts "36ghsV:" opt; do
76 case $opt in
77 3)
78 BUILD_32=1
79 BUILD_64=0
80 GIT_UP=0
81 ;;
82 6)
83 BUILD_32=0
84 BUILD_64=1
85 GIT_UP=0
86 ;;
87
88 g)
89 BUILD_32=0
90 BUILD_64=0
91 GIT_UP=1
92 ;;
93 V)
94 VERSION=$OPTARG
95 ;;
96 s)
97 SNAPSHOT="-snapshot"
98 ;;
99 h)
100 echo "build-zips.sh"
101 echo " -3 32 bit build only"
102 echo " -6 64 bit build only"
103 echo " -g git update and worktree only"
104 exit 0
105 ;;
106 \?)
107 echo "Invalid option: -$OPTARG" >&2
108 ;;
109 esac
110done
111
112if [ -z $VERSION ];
113then
114 echo "doing version thing"
115 VERSION=`
116 sed -n 's/^AC_INIT(GNU Emacs,[ ]*\([^ ,)]*\).*/\1/p' < ../../../configure.ac
117`
118fi
119
120if [ -z $VERSION ];
121then
122 echo Cannot determine Emacs version
123 exit 1
124fi
125
126MAJOR_VERSION="$(echo $VERSION | cut -d'.' -f1)"
127BRANCH=$VERSION
128VERSION=$VERSION$SNAPSHOT
129
130if (($GIT_UP))
131then
132 git_up
133fi
134
135if (($BUILD_32))
136then
137 build_zip i686 /mingw32/lib/pkgconfig i686-w64-mingw32
138fi
139
140if (($BUILD_64))
141then
142 build_zip x86_64 /mingw64/lib/pkgconfig x86_64-w64-mingw32
143fi