Skip to content

Commit

Permalink
Add GitHub workflow for installer
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Sep 9, 2024
1 parent 8aadd71 commit a5390d4
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 0 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash

# GitHub actions - Create QEMU installer for Windows

# Author: Stefan Weil (2020-2023)

#~ set -e
set -x

ARCH=$1

if test "$ARCH" = "i686"; then
MINGW=mingw32
else
ARCH=x86_64
MINGW=mingw64
fi

ROOTDIR=$PWD
DISTDIR=$ROOTDIR/dist
HOST=$ARCH-w64-mingw32
BUILDDIR=bin/ndebug/$HOST

echo deb http://de.archive.ubuntu.com/ubuntu kinetic main universe | \
sudo tee /etc/apt/sources.list.d/kinetic.list

sudo apt-get update
sudo apt-get install --yes curl make pkg-config

# Install packages.
sudo apt-get update
sudo apt-get install --yes --no-install-recommends \
mingw-w64-tools ninja-build nsis \
gcc libc6-dev \
g++-mingw-w64-${ARCH/_/-} gcc-mingw-w64-${ARCH/_/-} \
bison flex gettext python3-sphinx texinfo

# Get newer version of mingw-w64-*-dev.
if test "$ARCH" = "i686"; then
curl -sS -O http://de.archive.ubuntu.com/ubuntu/pool/universe/m/mingw-w64/mingw-w64-i686-dev_10.0.0-3_all.deb
sudo dpkg -i mingw-w64-i686-dev_10.0.0-3_all.deb
else
curl -sS -O http://de.archive.ubuntu.com/ubuntu/pool/universe/m/mingw-w64/mingw-w64-x86-64-dev_10.0.0-3_all.deb
sudo dpkg -i mingw-w64-x86-64-dev_10.0.0-3_all.deb
fi

# Get header files for WHPX API from Mingw-w64 git master.
if test "$ARCH" != "i686"; then
(
sudo mkdir -p /usr/$HOST/sys-include
cd /usr/$HOST/sys-include
sudo curl -sS -o winhvemulation.h https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-headers/include/winhvemulation.h?format=raw
sudo curl -sS -o winhvplatform.h https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-headers/include/winhvplatform.h?format=raw
sudo curl -sS -o winhvplatformdefs.h https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-headers/include/winhvplatformdefs.h?format=raw
sudo ln -s winhvemulation.h WinHvEmulation.h
sudo ln -s winhvplatform.h WinHvPlatform.h
sudo ln -s winhvplatformdefs.h WinHvPlatformDefs.h
)
fi

mkdir -p $DISTDIR

#~ TAG=5.0.0-alpha.$(date +%Y%m%d)

#~ git config --global user.email "[email protected]"
#~ git config --global user.name "Stefan Weil"
#~ git tag -a v$TAG -m "QEMU $TAG"

# Build QEMU installer.

echo Building $HOST...
mkdir -p $BUILDDIR && cd $BUILDDIR

# Run configure.
../../../configure --cross-prefix=$HOST- --disable-guest-agent-msi \
--disable-werror \
--enable-strip \
--extra-cflags="-isystem /$MINGW/include" \
--extra-ldflags="-L/$MINGW/lib"

cp config.log $DISTDIR/

make

echo Building installers...
date=$(date +%Y%m%d)
INSTALLER=$DISTDIR/qemu-$ARCH-setup-$date.exe
#make installer SIGNCODE=signcode INSTALLER=$INSTALLER
make installer SIGNCODE=true
mv -v qemu-setup-*.exe $INSTALLER

echo Calculate SHA-512 checksum...
(cd $DISTDIR; exe=$(basename $INSTALLER); sha512sum $exe >${exe/exe/sha512})
53 changes: 53 additions & 0 deletions .github/workflows/pacman.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

# GitHub actions - Install packages for Windows cross builds

# Author: Stefan Weil (2023)

ARCH=$1

if test "$ARCH" = "i686"; then
MINGW=mingw32
else
ARCH=x86_64
MINGW=mingw64
fi

ROOTDIR=$PWD
DISTDIR=$ROOTDIR/dist
HOST=$ARCH-w64-mingw32
BUILDDIR=bin/ndebug/$HOST

sudo apt-get update
sudo apt-get install --no-install-recommends -y git libarchive-dev libcurl3-dev libgpgme-dev libssl-dev make meson sudo

git clone https://gitlab.archlinux.org/sw/pacman.git
(
cd pacman/
meson setup build
cd build
sudo meson install
)

sudo mkdir /etc/pacman.d
echo "[$MINGW]" | sudo tee -a /etc/pacman.conf
echo "Include = /etc/pacman.d/mirrorlist.mingw" | sudo tee -a /etc/pacman.conf
curl https://raw.githubusercontent.com/msys2/MSYS2-packages/master/pacman-mirrors/mirrorlist.mingw | sudo tee /etc/pacman.d/mirrorlist.mingw

git clone https://github.com/msys2/MSYS2-keyring.git
(
cd MSYS2-keyring
sudo make
)

sudo ln -s /usr/local/share/pacman/keyrings /usr/share/pacman/
sudo pacman-key --init
sudo pacman-key --populate msys2
sudo pacman -Syu

test -e /etc/mtab || sudo ln -s ../proc/self/mounts /etc/mtab

sudo pacman -S --noconfirm mingw-w64-$ARCH-SDL2 mingw-w64-$ARCH-SDL2_image mingw-w64-$ARCH-asciidoc mingw-w64-$ARCH-cairo mingw-w64-$ARCH-capstone mingw-w64-$ARCH-curl-winssl mingw-w64-$ARCH-cyrus-sasl mingw-w64-$ARCH-gnutls mingw-w64-$ARCH-gtk3 mingw-w64-$ARCH-headers-git mingw-w64-$ARCH-icu mingw-w64-$ARCH-jack2 mingw-w64-$ARCH-leptonica mingw-w64-$ARCH-libarchive mingw-w64-$ARCH-libb2 mingw-w64-$ARCH-libnfs mingw-w64-$ARCH-libslirp mingw-w64-$ARCH-libssh mingw-w64-$ARCH-lz4 mingw-w64-$ARCH-pango mingw-w64-$ARCH-pdcurses mingw-w64-$ARCH-snappy mingw-w64-$ARCH-spice mingw-w64-$ARCH-usbredir mingw-w64-$ARCH-virglrenderer

sudo mkdir -p /usr/local/$ARCH-w64-mingw32/lib
sudo ln -s /$MINGW/lib/pkgconfig /usr/local/$ARCH-w64-mingw32/lib
34 changes: 34 additions & 0 deletions .github/workflows/win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# GitHub actions - Create QEMU installers for Windows

name: Cross build for Windows

on: [push]

jobs:
build32:
if: github.repository == 'stweil/qemu'
runs-on: [ubuntu-22.04]
steps:
- uses: actions/checkout@v3
- name: Get pacman package manager
run: .github/workflows/pacman.sh i686
- name: Build QEMU installer (32 bit)
run: .github/workflows/build.sh i686
- uses: actions/upload-artifact@v3
with:
name: QEMU Installer Windows 32 bit
path: dist

build64:
if: github.repository == 'stweil/qemu'
runs-on: [ubuntu-22.04]
steps:
- uses: actions/checkout@v3
- name: Get pacman package manager
run: .github/workflows/pacman.sh x86_64
- name: Build QEMU installer (64 bit)
run: .github/workflows/build.sh x86_64
- uses: actions/upload-artifact@v3
with:
name: QEMU Installer Windows 64 bit
path: dist

0 comments on commit a5390d4

Please sign in to comment.