Skip to content

Commit

Permalink
Merge pull request #5789 from kit-ty-kate/win-release
Browse files Browse the repository at this point in the history
Add windows to the release script
  • Loading branch information
kit-ty-kate authored Jun 20, 2024
2 parents 62b041a + 1be5f89 commit 1d289f1
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/main/ocaml-cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ esac

FLEXDLL_VERSION=0.43

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

tar -xzf "ocaml-$OCAML_VERSION.tar.gz"
tar -xzf "$OCAML_VERSION.tar.gz"

case "${OCAML_VERSION%.*}" in
4.08) PATCHES='e322556b0a9097a2eff2117476193b773e1b947f 17df117b4939486d3285031900587afce5262c8c';;
Expand Down
3 changes: 2 additions & 1 deletion master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ users)

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

## Infrastructure

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

## Install script

Expand Down
41 changes: 30 additions & 11 deletions release/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ OPAM_VERSION = $(subst -,~,$(VERSION))
GIT_URL = ..

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

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

Expand Down Expand Up @@ -70,6 +72,13 @@ CLINKING_macos = \
CLINKING_openbsd = $(CLINKING_macos)
CLINKING_freebsd = $(CLINKING_macos)

CLINKING_windows = \
-lunix -lmccs_stubs -lmccs_glpk_stubs $(SHA_LINK) \
-lopam_stubs_win32_stubs \
-l:libstdc++.a -l:libpthread.a \
-Wl,-static \
-ladvapi32 -lgdi32 -luser32 -lshell32 -lole32 -luuid -luserenv

LINKING = (-noautolink $(patsubst %,-cclib %,$(CLINKING_$(1))))

EXPORTS_openbsd = \
Expand All @@ -80,6 +89,7 @@ EXPORTS_freebsd = \
CPATH=/usr/local/include: \
LIBRARY_PATH=/usr/local/lib: \

EXTRA_CONFIGURE_ARGS_windows = --host=x86_64-w64-mingw32 --with-flexdll

%: opam-$(VERSION)-%

Expand All @@ -92,12 +102,18 @@ opam-$(VERSION)-%: $(OUTDIR)/opam-$(VERSION)-%
build/$(HOST).env:
mkdir -p build/$(HOST)
cd build/$(HOST) && curl -OL $(OCAML_URL)
cd build/$(HOST) && tar xzf ocaml-$(OCAMLV).tar.gz
cd build/$(HOST) && tar xzf $(OCAMLV).tar.gz
cd build/$(HOST)/ocaml-$(OCAMLV) && curl -OL $(FLEXDLL_URL)
cd build/$(HOST)/ocaml-$(OCAMLV) && tar xzf $(shell basename "$(FLEXDLL_URL)")
cd build/$(HOST)/ocaml-$(OCAMLV) && rmdir flexdll && mv "flexdll-$(FLEXDLLV)" flexdll
cd build/$(HOST)/ocaml-$(OCAMLV) && \
./configure --prefix "$(shell pwd)/build/$(HOST)" && \
./configure --prefix "$(shell pwd)/build/$(HOST)" \
--disable-debug-runtime --disable-debugger --disable-instrumented-runtime \
--disable-ocamldoc --disable-stdlib-manpages --disable-ocamltest \
$(EXTRA_CONFIGURE_ARGS_$(HOST_OS)) && \
$(MAKE) -j$(JOBS) && \
$(MAKE) install
rm -rf build/$(HOST)/ocaml-$(OCAMLV) build/$(HOST)/ocaml-$(OCAMLV).tar.gz
rm -rf build/$(HOST)/ocaml-$(OCAMLV) build/$(HOST)/$(OCAMLV).tar.gz
touch $@

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

REMOTE_DIR = /tmp/opam-release
REMOTE_MAKE = make
REMOTE_SHELL = /bin/sh
SSH = ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
SCP = scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
remote: $(OUTDIR)/opam-full-$(VERSION).tar.gz
$(SSH) "$(REMOTE)" "mkdir -p $(REMOTE_DIR)/${OUTDIR}"
$(SSH) "$(REMOTE)" "mkdir -p $(REMOTE_DIR)/$(OUTDIR)"
$(SCP) Makefile "$(REMOTE):$(REMOTE_DIR)/"
$(SCP) "$^" "$(REMOTE):$(REMOTE_DIR)/$^"
$(SSH) "$(REMOTE)" 'sh -c "cd $(REMOTE_DIR) && ulimit -s 8192 && $(REMOTE_MAKE) host TAG=$(TAG) VERSION=$(VERSION) OCAMLV=$(OCAMLV)"'
$(SCP) "$(REMOTE):$(REMOTE_DIR)/$(OUTDIR)/opam-$(VERSION)*" "$(OUTDIR)/"

SSH_USER = root
ULIMIT = ulimit -s 8192 &&
qemu: $(OUTDIR)/opam-full-$(VERSION).tar.gz
$(SSH) -p "$(QEMU_PORT)" root@localhost "mkdir -p $(REMOTE_DIR)/${OUTDIR}"
$(SCP) -P "$(QEMU_PORT)" Makefile "root@localhost:$(REMOTE_DIR)/"
$(SCP) -P "$(QEMU_PORT)" "$^" "root@localhost:$(REMOTE_DIR)/$^"
$(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)"'
$(SCP) -P "$(QEMU_PORT)" "root@localhost:$(REMOTE_DIR)/$(OUTDIR)/opam-$(VERSION)*" "$(OUTDIR)/"
$(SSH) -p "$(QEMU_PORT)" $(SSH_USER)@localhost "$(REMOTE_SHELL) -c \"mkdir -p $(REMOTE_DIR)/$(OUTDIR)\""
$(SCP) -P "$(QEMU_PORT)" Makefile "$(SSH_USER)@localhost:$(REMOTE_DIR)/"
$(SCP) -P "$(QEMU_PORT)" "$^" "$(SSH_USER)@localhost:$(REMOTE_DIR)/$^"
$(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)\""
$(SCP) -P "$(QEMU_PORT)" "$(SSH_USER)@localhost:$(REMOTE_DIR)/$(OUTDIR)/opam-$(VERSION)*" "$(OUTDIR)/"

macos-local: $(OUTDIR)/opam-full-$(VERSION).tar.gz
LOCAL_RELEASE_DIR=$(shell mktemp -d); \
Expand Down
43 changes: 43 additions & 0 deletions release/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,48 @@
* run `make tests`, `opam-rt` [checked by github actions]
* update the CHANGE file: take `master_changes.md` content to fill it

## Windows setup

* From the "release" directory (where this here readme.md file should be)...
* Download Windows 10 English International 64bit from https://www.microsoft.com/en-gb/software-download/windows10ISO
* Run qemu-img create -f qcow2 Windows-10-x86_64.qcow2 32G
* 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
* Install Windows. Everything stays as default except:
* Click "I don’t have a product key"
* Choose "Windows 10 Pro"
* Click "Custom: ..." not "Upgrade: ..."
* This will take an hour or so
* Select the default keyboard then wait some more
* Upon restart:
* no online account
* yes, i want the limited experience
* username: opam
* no password
* no location
* no find my device
* send required diagnostic data
* no improve inking & typing
* no cortana
* 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.
* Start -> Power off
* Run qemu-system-x86_64 -drive file=Windows-10-x86_64.qcow2 -smp 8 -m 6G -machine q35
* Answer yes to the "would you like to be discoverable on the network" prompt
* Open the Settings app
* "System -> Power & Sleep" and select "Never" on the "When plugged in, turn off after" drop-down menu
* search for "Add an optional feature", then search for "OpenSSH" and install "OpenSSH Server"
* Run services.msc
* Double-click OpenSSH SSH Server then select Automatic from the Startup drop-down menu
* Click Ok
* Open cmd.exe as administrator and run "net start sshd", then "notepad C:/ProgramData/ssh/sshd_config"
* Uncomment and set:
* PermitEmptyPasswords yes
* PermitRootLogin yes
* PasswordAuthentication yes
* StrictMode no
* Save and close both applications
* Open regedit.exe and set HKey_Local_Machine\SYSTEM\CurrentControlSet\Control\Lsa\LimitBlankPasswordUse to 0
* Shutdown the computer using the startmenu button

## Github release

[ once bump version & changes PRs merged ]
Expand Down Expand Up @@ -48,6 +90,7 @@

## Device requirements
* Mac M1 or above with Rosetta2
* >=70GB of disk space free
* brew dependencies: git, gpg, qemu>=8.1.0, docker>=24.0.0, md5sha1sum (only when releasing on the 2.1 branch)
* opam repo with the tag fetched
* Have the secret key available
36 changes: 33 additions & 3 deletions release/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,36 @@ SSH="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
OUTDIR="out/$TAG"
mkdir -p "$OUTDIR"

windows_build() {
local port=$1
local image=$2

if ! ${SSH} -p "${port}" opam@localhost cd; then
qemu-img convert -O raw "./${image}.qcow2" "./${image}.raw"
# NOTE: -machine q35 seems to be required to avoid random but recurring crashes
"qemu-system-x86_64" -drive "file=./${image}.raw,format=raw" -nic "user,hostfwd=tcp::${port}-:22" -m 6G -smp "${JOBS}" -machine q35 &
sleep 120
fi

# Disable Windows Defender before anything else (makes the build process faster)
# TODO: ... doesn't work
# 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"
#${SSH} -p "${port}" opam@localhost "powershell -c 'Set-MpPreference -Force \
# -DisableBehaviorMonitoring \$True \
# -DisableRealtimeMonitoring \$True \
# -DisableScriptScanning \$True \
# -EnableLowCpuPriority \$True'"

${SSH} -p "${port}" opam@localhost "curl -LO https://cygwin.com/setup-x86_64.exe"
${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'

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=""

${SSH} -p "${port}" opam@localhost "shutdown /s /f"

wait
}

qemu_build() {
local port=$1
local image=$2
Expand Down Expand Up @@ -59,6 +89,6 @@ make JOBS="${JOBS}" TAG="$TAG" s390x-linux
[ -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/.."
[ -f "${OUTDIR}/opam-$TAG-arm64-macos" ] || make TAG="$TAG" JOBS="${JOBS}" macos-local MACOS_ARCH=arm64 REMOTE_DIR=opam-release-$TAG GIT_URL="$CWD/.."
[ -d ./qemu-base-images ] || git clone https://gitlab.com/kit-ty-kate/qemu-base-images.git
[ -f "${OUTDIR}/opam-$TAG-x86_64-openbsd" ] || qemu_build 9999 OpenBSD-7.4-amd64 "pkg_add gmake curl bzip2" gmake x86_64 &
[ -f "${OUTDIR}/opam-$TAG-x86_64-freebsd" ] || qemu_build 9998 FreeBSD-13.2-RELEASE-amd64 "pkg install -y gmake curl bzip2" gmake x86_64 &
wait
[ -f "${OUTDIR}/opam-$TAG-x86_64-openbsd" ] || qemu_build 9999 OpenBSD-7.4-amd64 "pkg_add gmake curl bzip2" gmake x86_64
[ -f "${OUTDIR}/opam-$TAG-x86_64-freebsd" ] || qemu_build 9998 FreeBSD-13.2-RELEASE-amd64 "pkg install -y gmake curl bzip2" gmake x86_64
[ -f "${OUTDIR}/opam-$TAG-x86_64-windows" ] || windows_build 9997 Windows-10-x86_64
2 changes: 1 addition & 1 deletion src_ext/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif

PATCH ?= patch

URL_ocaml = https://github.com/ocaml/ocaml/archive/4.14.2.tar.gz
URL_ocaml = https://github.com/ocaml/ocaml/archive/refs/tags/4.14.2.tar.gz
MD5_ocaml = b28daefda803b5d5910cecf085b1451c

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

0 comments on commit 1d289f1

Please sign in to comment.