Skip to content

Commit 1d289f1

Browse files
authored
Merge pull request #5789 from kit-ty-kate/win-release
Add windows to the release script
2 parents 62b041a + 1be5f89 commit 1d289f1

File tree

6 files changed

+111
-18
lines changed

6 files changed

+111
-18
lines changed

.github/scripts/main/ocaml-cache.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ esac
4646

4747
FLEXDLL_VERSION=0.43
4848

49-
curl -sLO "https://caml.inria.fr/pub/distrib/ocaml-${OCAML_VERSION%.*}/ocaml-$OCAML_VERSION.tar.gz"
49+
curl -sLO "https://github.com/ocaml/ocaml/archive/refs/tags/${OCAML_VERSION}.tar.gz"
5050
if [[ $PLATFORM = 'Windows' ]] ; then
5151
curl -sLO "https://github.com/ocaml/flexdll/archive/refs/tags/$FLEXDLL_VERSION.tar.gz"
5252
fi
5353

54-
tar -xzf "ocaml-$OCAML_VERSION.tar.gz"
54+
tar -xzf "$OCAML_VERSION.tar.gz"
5555

5656
case "${OCAML_VERSION%.*}" in
5757
4.08) PATCHES='e322556b0a9097a2eff2117476193b773e1b947f 17df117b4939486d3285031900587afce5262c8c';;

master_changes.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@ users)
7272

7373
## Build
7474
* Fix the lower-bound constraint on ocaml-re (bump from >= 1.9.0 to >= 1.10.0) [#6016 @kit-ty-kate]
75-
* Update source file location as caml.inria.fr is unavailable [#6032 @mtelvers]
75+
* Update source file location as caml.inria.fr is unavailable [#6032 #5789 @mtelvers @kit-ty-kate]
7676

7777
## Infrastructure
7878

7979
## Release scripts
80+
* Add windows to the release script [#5789 @kit-ty-kate]
8081

8182
## Install script
8283

release/Makefile

+30-11
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ OPAM_VERSION = $(subst -,~,$(VERSION))
44
GIT_URL = ..
55

66
OCAMLV = 4.14.2
7+
FLEXDLLV = 0.43
78
# currently hardcoded in Dockerfile.in
8-
OCAML_URL = https://caml.inria.fr/pub/distrib/ocaml-$(basename $(OCAMLV))/ocaml-$(OCAMLV).tar.gz
9+
OCAML_URL = https://github.com/ocaml/ocaml/archive/refs/tags/$(OCAMLV).tar.gz
10+
FLEXDLL_URL = https://github.com/ocaml/flexdll/archive/refs/tags/$(FLEXDLLV).tar.gz
911

10-
HOST_OS = $(shell uname -s | tr A-Z a-z | sed 's/darwin/macos/')
12+
HOST_OS = $(shell uname -s | tr A-Z a-z | sed -e 's/_.*//' -e 's/darwin/macos/' -e 's/cygwin/windows/')
1113
HOST = $(shell uname -m | sed 's/amd64/x86_64/')-$(HOST_OS)
1214
OUTDIR = out/$(TAG)
1315

@@ -70,6 +72,13 @@ CLINKING_macos = \
7072
CLINKING_openbsd = $(CLINKING_macos)
7173
CLINKING_freebsd = $(CLINKING_macos)
7274

75+
CLINKING_windows = \
76+
-lunix -lmccs_stubs -lmccs_glpk_stubs $(SHA_LINK) \
77+
-lopam_stubs_win32_stubs \
78+
-l:libstdc++.a -l:libpthread.a \
79+
-Wl,-static \
80+
-ladvapi32 -lgdi32 -luser32 -lshell32 -lole32 -luuid -luserenv
81+
7382
LINKING = (-noautolink $(patsubst %,-cclib %,$(CLINKING_$(1))))
7483

7584
EXPORTS_openbsd = \
@@ -80,6 +89,7 @@ EXPORTS_freebsd = \
8089
CPATH=/usr/local/include: \
8190
LIBRARY_PATH=/usr/local/lib: \
8291

92+
EXTRA_CONFIGURE_ARGS_windows = --host=x86_64-w64-mingw32 --with-flexdll
8393

8494
%: opam-$(VERSION)-%
8595

@@ -92,12 +102,18 @@ opam-$(VERSION)-%: $(OUTDIR)/opam-$(VERSION)-%
92102
build/$(HOST).env:
93103
mkdir -p build/$(HOST)
94104
cd build/$(HOST) && curl -OL $(OCAML_URL)
95-
cd build/$(HOST) && tar xzf ocaml-$(OCAMLV).tar.gz
105+
cd build/$(HOST) && tar xzf $(OCAMLV).tar.gz
106+
cd build/$(HOST)/ocaml-$(OCAMLV) && curl -OL $(FLEXDLL_URL)
107+
cd build/$(HOST)/ocaml-$(OCAMLV) && tar xzf $(shell basename "$(FLEXDLL_URL)")
108+
cd build/$(HOST)/ocaml-$(OCAMLV) && rmdir flexdll && mv "flexdll-$(FLEXDLLV)" flexdll
96109
cd build/$(HOST)/ocaml-$(OCAMLV) && \
97-
./configure --prefix "$(shell pwd)/build/$(HOST)" && \
110+
./configure --prefix "$(shell pwd)/build/$(HOST)" \
111+
--disable-debug-runtime --disable-debugger --disable-instrumented-runtime \
112+
--disable-ocamldoc --disable-stdlib-manpages --disable-ocamltest \
113+
$(EXTRA_CONFIGURE_ARGS_$(HOST_OS)) && \
98114
$(MAKE) -j$(JOBS) && \
99115
$(MAKE) install
100-
rm -rf build/$(HOST)/ocaml-$(OCAMLV) build/$(HOST)/ocaml-$(OCAMLV).tar.gz
116+
rm -rf build/$(HOST)/ocaml-$(OCAMLV) build/$(HOST)/$(OCAMLV).tar.gz
101117
touch $@
102118

103119
# Actually builds $(OUTDIR)/opam-$(VERSION)-$(HOST), but we don't want to override the
@@ -137,21 +153,24 @@ distclean: clean
137153

138154
REMOTE_DIR = /tmp/opam-release
139155
REMOTE_MAKE = make
156+
REMOTE_SHELL = /bin/sh
140157
SSH = ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
141158
SCP = scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
142159
remote: $(OUTDIR)/opam-full-$(VERSION).tar.gz
143-
$(SSH) "$(REMOTE)" "mkdir -p $(REMOTE_DIR)/${OUTDIR}"
160+
$(SSH) "$(REMOTE)" "mkdir -p $(REMOTE_DIR)/$(OUTDIR)"
144161
$(SCP) Makefile "$(REMOTE):$(REMOTE_DIR)/"
145162
$(SCP) "$^" "$(REMOTE):$(REMOTE_DIR)/$^"
146163
$(SSH) "$(REMOTE)" 'sh -c "cd $(REMOTE_DIR) && ulimit -s 8192 && $(REMOTE_MAKE) host TAG=$(TAG) VERSION=$(VERSION) OCAMLV=$(OCAMLV)"'
147164
$(SCP) "$(REMOTE):$(REMOTE_DIR)/$(OUTDIR)/opam-$(VERSION)*" "$(OUTDIR)/"
148165

166+
SSH_USER = root
167+
ULIMIT = ulimit -s 8192 &&
149168
qemu: $(OUTDIR)/opam-full-$(VERSION).tar.gz
150-
$(SSH) -p "$(QEMU_PORT)" root@localhost "mkdir -p $(REMOTE_DIR)/${OUTDIR}"
151-
$(SCP) -P "$(QEMU_PORT)" Makefile "root@localhost:$(REMOTE_DIR)/"
152-
$(SCP) -P "$(QEMU_PORT)" "$^" "root@localhost:$(REMOTE_DIR)/$^"
153-
$(SSH) -p "$(QEMU_PORT)" root@localhost 'sh -c "cd $(REMOTE_DIR) && ulimit -s 8192 && $(REMOTE_MAKE) host JOBS=$(JOBS) TAG=$(TAG) VERSION=$(VERSION) OCAMLV=$(OCAMLV)"'
154-
$(SCP) -P "$(QEMU_PORT)" "root@localhost:$(REMOTE_DIR)/$(OUTDIR)/opam-$(VERSION)*" "$(OUTDIR)/"
169+
$(SSH) -p "$(QEMU_PORT)" $(SSH_USER)@localhost "$(REMOTE_SHELL) -c \"mkdir -p $(REMOTE_DIR)/$(OUTDIR)\""
170+
$(SCP) -P "$(QEMU_PORT)" Makefile "$(SSH_USER)@localhost:$(REMOTE_DIR)/"
171+
$(SCP) -P "$(QEMU_PORT)" "$^" "$(SSH_USER)@localhost:$(REMOTE_DIR)/$^"
172+
$(SSH) -p "$(QEMU_PORT)" $(SSH_USER)@localhost "$(REMOTE_SHELL) -c \"cd $(REMOTE_DIR) && $(ULIMIT) $(REMOTE_MAKE) host JOBS=$(JOBS) TAG=$(TAG) VERSION=$(VERSION) OCAMLV=$(OCAMLV)\""
173+
$(SCP) -P "$(QEMU_PORT)" "$(SSH_USER)@localhost:$(REMOTE_DIR)/$(OUTDIR)/opam-$(VERSION)*" "$(OUTDIR)/"
155174

156175
macos-local: $(OUTDIR)/opam-full-$(VERSION).tar.gz
157176
LOCAL_RELEASE_DIR=$(shell mktemp -d); \

release/readme.md

+43
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,48 @@
77
* run `make tests`, `opam-rt` [checked by github actions]
88
* update the CHANGE file: take `master_changes.md` content to fill it
99

10+
## Windows setup
11+
12+
* From the "release" directory (where this here readme.md file should be)...
13+
* Download Windows 10 English International 64bit from https://www.microsoft.com/en-gb/software-download/windows10ISO
14+
* Run qemu-img create -f qcow2 Windows-10-x86_64.qcow2 32G
15+
* Run qemu-system-x86_64 -cdrom Win10_22H2_EnglishInternational_x64v1.iso -drive file=Windows-10-x86_64.qcow2 -smp 8 -m 6G -net nic -net user,restrict=on -machine q35
16+
* Install Windows. Everything stays as default except:
17+
* Click "I don’t have a product key"
18+
* Choose "Windows 10 Pro"
19+
* Click "Custom: ..." not "Upgrade: ..."
20+
* This will take an hour or so
21+
* Select the default keyboard then wait some more
22+
* Upon restart:
23+
* no online account
24+
* yes, i want the limited experience
25+
* username: opam
26+
* no password
27+
* no location
28+
* no find my device
29+
* send required diagnostic data
30+
* no improve inking & typing
31+
* no cortana
32+
* Open gpedit.msc and right-click on "Computer Configuration -> Administrative Templates -> Windows Components -> Windows Update -> Configure Automatic Updates", click Edit and in the new window click on Enabled and then select "2. Notify for download and auto install", click Apply and then Ok.
33+
* Start -> Power off
34+
* Run qemu-system-x86_64 -drive file=Windows-10-x86_64.qcow2 -smp 8 -m 6G -machine q35
35+
* Answer yes to the "would you like to be discoverable on the network" prompt
36+
* Open the Settings app
37+
* "System -> Power & Sleep" and select "Never" on the "When plugged in, turn off after" drop-down menu
38+
* search for "Add an optional feature", then search for "OpenSSH" and install "OpenSSH Server"
39+
* Run services.msc
40+
* Double-click OpenSSH SSH Server then select Automatic from the Startup drop-down menu
41+
* Click Ok
42+
* Open cmd.exe as administrator and run "net start sshd", then "notepad C:/ProgramData/ssh/sshd_config"
43+
* Uncomment and set:
44+
* PermitEmptyPasswords yes
45+
* PermitRootLogin yes
46+
* PasswordAuthentication yes
47+
* StrictMode no
48+
* Save and close both applications
49+
* Open regedit.exe and set HKey_Local_Machine\SYSTEM\CurrentControlSet\Control\Lsa\LimitBlankPasswordUse to 0
50+
* Shutdown the computer using the startmenu button
51+
1052
## Github release
1153

1254
[ once bump version & changes PRs merged ]
@@ -48,6 +90,7 @@
4890

4991
## Device requirements
5092
* Mac M1 or above with Rosetta2
93+
* >=70GB of disk space free
5194
* brew dependencies: git, gpg, qemu>=8.1.0, docker>=24.0.0, md5sha1sum (only when releasing on the 2.1 branch)
5295
* opam repo with the tag fetched
5396
* Have the secret key available

release/release.sh

+33-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,36 @@ SSH="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
3232
OUTDIR="out/$TAG"
3333
mkdir -p "$OUTDIR"
3434

35+
windows_build() {
36+
local port=$1
37+
local image=$2
38+
39+
if ! ${SSH} -p "${port}" opam@localhost cd; then
40+
qemu-img convert -O raw "./${image}.qcow2" "./${image}.raw"
41+
# NOTE: -machine q35 seems to be required to avoid random but recurring crashes
42+
"qemu-system-x86_64" -drive "file=./${image}.raw,format=raw" -nic "user,hostfwd=tcp::${port}-:22" -m 6G -smp "${JOBS}" -machine q35 &
43+
sleep 120
44+
fi
45+
46+
# Disable Windows Defender before anything else (makes the build process faster)
47+
# TODO: ... doesn't work
48+
# as well as the following line to add to the readme.md: Open the Windows Security app and turn off "Tamper Protection" and Real-time protection" from "Virus & threat protection -> Virus & threat protection settings -> Manage settings"
49+
#${SSH} -p "${port}" opam@localhost "powershell -c 'Set-MpPreference -Force \
50+
# -DisableBehaviorMonitoring \$True \
51+
# -DisableRealtimeMonitoring \$True \
52+
# -DisableScriptScanning \$True \
53+
# -EnableLowCpuPriority \$True'"
54+
55+
${SSH} -p "${port}" opam@localhost "curl -LO https://cygwin.com/setup-x86_64.exe"
56+
${SSH} -p "${port}" opam@localhost '.\setup-x86_64.exe -q -O -s https://cygwin.mirror.uk.sargasso.net -P make,diffutils,mingw64-x86_64-gcc-g++,mingw64-i686-gcc-g++,rsync,patch,curl,unzip,git,binutils'
57+
58+
make TAG="$TAG" JOBS="${JOBS}" qemu QEMU_PORT="${port}" REMOTE_MAKE=make REMOTE_DIR="opam-release-$TAG" 'REMOTE_SHELL=C:\Cygwin64\bin\bash.exe -l' SSH_USER=opam ULIMIT=""
59+
60+
${SSH} -p "${port}" opam@localhost "shutdown /s /f"
61+
62+
wait
63+
}
64+
3565
qemu_build() {
3666
local port=$1
3767
local image=$2
@@ -59,6 +89,6 @@ make JOBS="${JOBS}" TAG="$TAG" s390x-linux
5989
[ -f "${OUTDIR}/opam-$TAG-x86_64-macos" ] || make TAG="$TAG" JOBS="${JOBS}" macos-local MACOS_ARCH=x86_64 REMOTE_DIR=opam-release-$TAG GIT_URL="$CWD/.."
6090
[ -f "${OUTDIR}/opam-$TAG-arm64-macos" ] || make TAG="$TAG" JOBS="${JOBS}" macos-local MACOS_ARCH=arm64 REMOTE_DIR=opam-release-$TAG GIT_URL="$CWD/.."
6191
[ -d ./qemu-base-images ] || git clone https://gitlab.com/kit-ty-kate/qemu-base-images.git
62-
[ -f "${OUTDIR}/opam-$TAG-x86_64-openbsd" ] || qemu_build 9999 OpenBSD-7.4-amd64 "pkg_add gmake curl bzip2" gmake x86_64 &
63-
[ -f "${OUTDIR}/opam-$TAG-x86_64-freebsd" ] || qemu_build 9998 FreeBSD-13.2-RELEASE-amd64 "pkg install -y gmake curl bzip2" gmake x86_64 &
64-
wait
92+
[ -f "${OUTDIR}/opam-$TAG-x86_64-openbsd" ] || qemu_build 9999 OpenBSD-7.4-amd64 "pkg_add gmake curl bzip2" gmake x86_64
93+
[ -f "${OUTDIR}/opam-$TAG-x86_64-freebsd" ] || qemu_build 9998 FreeBSD-13.2-RELEASE-amd64 "pkg install -y gmake curl bzip2" gmake x86_64
94+
[ -f "${OUTDIR}/opam-$TAG-x86_64-windows" ] || windows_build 9997 Windows-10-x86_64

src_ext/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ endif
88

99
PATCH ?= patch
1010

11-
URL_ocaml = https://github.com/ocaml/ocaml/archive/4.14.2.tar.gz
11+
URL_ocaml = https://github.com/ocaml/ocaml/archive/refs/tags/4.14.2.tar.gz
1212
MD5_ocaml = b28daefda803b5d5910cecf085b1451c
1313

1414
URL_flexdll = https://github.com/ocaml/flexdll/archive/0.43.tar.gz

0 commit comments

Comments
 (0)