Created
November 10, 2020 17:18
-
-
Save skissane/c81dc0e433965ddda56b24d71b08fba5 to your computer and use it in GitHub Desktop.
Install Fedora 33 in chroot on Ubuntu 19.10. Installs Cygwin GCC in the Fedora 33 chroot and tests if it works
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -xue | |
# Script to install Fedora 33 in a chroot on Ubuntu | |
# And then in turn install cygwin64-gcc in that chroot | |
# Finally we test we can compile a .exe with Cygwin | |
# | |
# Run this as root | |
# | |
# Works on Ubuntu 19.10 | |
# Configuration | |
fedoraver=33 | |
chroot=/fedora${fedoraver} | |
rpminst=/tmp/rpminst | |
server=https://download.fedoraproject.org | |
serverpath=pub/fedora/linux/releases/${fedoraver}/Everything/x86_64/os/Packages/f | |
serverfile=fedora-repos-${fedoraver}-1.noarch.rpm | |
# Install yum and yumdownloader | |
apt install -y yum yum-utils | |
# Create our chroot | |
mkdir -p $chroot | |
# Download and install the fedora-repos package | |
wget $server/$serverpath/$serverfile | |
rpm -i --nodeps --force --root=$chroot $serverfile | |
# Ubuntu's RPM is too old for python-pip-wheel package | |
# So says YUM. But it works anyway if you do it manually | |
mkdir -p ${rpminst} | |
yumdownloader --installroot=$chroot --releasever=${fedoraver} --destdir=${rpminst} python-pip-wheel | |
rpm -i --nodeps --force --root=$chroot ${rpminst}/*.rpm | |
# Install DNF and core plugins | |
yum --installroot=$chroot --releasever=${fedoraver} install -y --nogpgcheck dnf dnf-plugins-core | |
# Ensure we can resolve DNS | |
rm -f $chroot/etc/resolv.conf | |
cp /etc/resolv.conf $chroot/etc | |
# Enable cygwin DNF repository | |
chroot $chroot dnf --releasever ${fedoraver} copr enable -y yselkowitz/cygwin | |
# Install cygwin64-gcc | |
chroot $chroot dnf --releasever ${fedoraver} install --nogpgcheck -y cygwin64-gcc | |
# Create test.c | |
echo $'#include<stdio.h>\nint main(int argc,char*argv){printf("Hello World!\\n");return 0;}' > $chroot/test.c | |
# Compile test.c | |
chroot $chroot x86_64-pc-cygwin-gcc -o test.exe test.c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment