Initial commit

This commit is contained in:
Ryan Houdek 2021-12-30 01:02:28 -08:00
commit bbb5e74d07
20 changed files with 513 additions and 0 deletions

24
LICENSE Normal file
View File

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org>

58
README_ppa.md Normal file
View File

@ -0,0 +1,58 @@
# Source needs to be dumped in to root folder
$ rm -Rf External/{fex-gcc-target-tests-bins,fex-gvisor-tests-bins,fex-posixtest-bins}
$ rm -Rf .git
$ rm -Rf unittests
$ tar -cvpzf ../FEX-ppa/fex-emu_<MATCHING VERSION>.orig.tar.gz .
# Stage 0
# Args = <Script> <Stage> <Version> <Changelog file> <Source tar>
# Generates a change log from the passed in changelog file and copies it in to debian/changelog
# Wrapped by changelog_template
# Make sure to check debian/changelog after generating
./create_packages.py 0 2201~3 TestChanges fex-emu_2201ubuntu4.orig.tar.gz
# Stage 1
# Generates all the target specific folder structures for building source packages
# Generates in to `gen_ppa` in cwd
./create_packages.py 1 2201~3 TestChanges fex-emu_2201ubuntu4.orig.tar.gz
# Stage 2
# Walks all of the target specific debian trees and runs `debuild -S` over them cleanly
./create_packages.py 2 2201~3 TestChanges fex-emu_2201ubuntu4.orig.tar.gz
# Stage 3
# Walks all of the created debian packages and uploads them directly to the fex-ppa with dput
# Hardcoded to ppa:fex-emu/fex
./create_packages.py 3 2201~3 TestChanges fex-emu_2201ubuntu4.orig.tar.gz
# Setting up a pbuilder
## Only needs to be done once
This allows you to create a pbuilder to test building the package before uploading to PPA
$ sudo pbuilder create --distribution impish --architecture amd64 --basetgz /var/cache/pbuilder/impish-amd64-base.tgz
$ sudo pbuilder create --distribution focal --architecture amd64 --basetgz /var/cache/pbuilder/focal-amd64-base.tgz
# Perform the build
This will attempt building the package provided with the dsc file
Result will be in /var/cache/pbuilder/result/
$ sudo pbuilder build --distribution impish --architecture amd64 --basetgz /var/cache/pbuilder/impish-amd64-base.tgz ../fex-emu_2201.dsc
$ sudo pbuilder build --distribution focal --architecture amd64 --basetgz /var/cache/pbuilder/focal-amd64-base.tgz ../fex-emu_2201.dsc
# Cleanup
$ sudo rm /var/cache/pbuilder/impish-amd64-base.tgz
# After this step you will need to do the `Setting up a pbuilder` step again
# Uploading to launchpad ppa
dput ppa:fex-emu/fex ../fex-emu_2201_source.changes
# Common errors
## Unable to find `fex-emu_2201ubuntu4.orig.tar.gz` in upload or distribution.
- debuild -S would have printed some text about this
- Working: dpkg-buildpackage: info: full upload (original source is included)
- Non-working: dpkg-buildpackage: info: binary and diff upload (original source NOT included)
- Failure I found with this was changelog had multiple version back to back same versions
## Unable to find mandatory field 'Changed-By' in the changes file.
- Changes need to be indented by two spaces otherwise the change file is invalid.
- Ensure it is indented

221
create_packages.py Executable file
View File

@ -0,0 +1,221 @@
#!/bin/python3
import os
import sys
import shutil
import subprocess
# Supported distros in the form of: letter, series name
supported_distros = [
["f", "focal"], # Oldest supported is 20.04 focal
["h", "hirsute"],
["i", "impish"],
["j", "jammy"],
]
# Supported CPUs split by features
# By package suffix, -mcpu flavour
supported_cpus = [
["armv8.0", "cortex-a57"],
["armv8.2", "cortex-a75"],
["armv8.4", "apple-a13"], # Not quite but sure whatever
]
debfiles_tocopy = [
"changelog",
"control",
"copyright",
"files",
"install",
"rules",
"fex-emu-binfmt32.install",
"fex-emu-binfmt64.install",
"source/",
]
def ReadFile(filename):
if not os.path.isfile(filename):
print("Couldn't open file! {}".format(filename))
sys.exit()
file = open(filename, "r")
text = file.read()
file.close()
return text
def StoreFile(filename, text):
if not os.path.isfile(filename):
print("Couldn't open file! {}".format(filename))
sys.exit()
file = open(filename, "w")
file.write(text)
file.close()
def PrependChangelog(filename, changelog):
changelog_file = open(filename, "r")
original_changelog = changelog_file.read()
changelog_file.close()
changelog_file = open(filename, "w")
changelog_file.write(changelog)
changelog_file.write(original_changelog)
changelog_file.close()
def AppendToFile(filename, text):
_file = open(filename, "r")
original_file = _file.read()
_file.close()
_file = open(filename, "w")
_file.write(original_file)
_file.write(text)
_file.close()
def GetDateInCorrectFormat():
return subprocess.getoutput("date -u -R")
# Args: <Stage> <BaseVersion> <Base Changelog txt> <Base Source tar.gz>
if len(sys.argv) < 3:
sys.exit()
RootBaseDeb = "deb_base"
RootGenPPA = os.path.abspath("gen_ppa")
RootPackageName = "fex-emu"
Stage = int(sys.argv[1])
RootPackageVersion = sys.argv[2]
CurrentChangelogFile = sys.argv[3]
SourceTar = sys.argv[4]
if "-" in RootPackageVersion:
print("Can't have dash in package version. Breaks things")
sys.exit()
if not os.path.isfile(CurrentChangelogFile):
print("Couldn't open file! {}".format(CurrentChangelogFile))
sys.exit()
if not os.path.isfile(SourceTar):
print("Couldn't open file! {}".format(SourceTar))
sys.exit()
UploaderName = "Ryan Houdek"
UploaderEmail = "houdek.ryan@fex-emu.org"
if Stage == 0:
print("Generating Changelog")
CurrentDate = GetDateInCorrectFormat()
DebChangelogBase = ReadFile(RootBaseDeb + "/changelog_template")
CurrentChangelog = ReadFile(CurrentChangelogFile)
# Replace portions of the change log that are common
DebChangelogBase = DebChangelogBase.replace("@UPLOADER_NAME@", UploaderName)
DebChangelogBase = DebChangelogBase.replace("@UPLOADER_EMAIL@", UploaderEmail)
DebChangelogBase = DebChangelogBase.replace("@CHANGE_DATE@", CurrentDate)
DebChangelogBase = DebChangelogBase.replace("@VERSION@", RootPackageVersion)
DebChangelogBase = DebChangelogBase.replace("@CHANGE_TEXT@", CurrentChangelog)
# Prepend the changelog to the base as an update
PrependChangelog(RootBaseDeb + "/changelog", DebChangelogBase)
print(DebChangelogBase)
print("\tMake sure to check {} before starting stage 2".format(RootBaseDeb + "/changelog"))
if Stage == 1:
print("Generating debian file structure trees")
# First thing's first, bifurcate all of our options
os.makedirs(RootGenPPA, exist_ok = True)
for distro in supported_distros:
for arch in supported_cpus:
# Create subfolder
SubFolder = RootGenPPA + "/" + RootPackageName + "-" + arch[0] + "_" + RootPackageVersion + "~" + distro[0]
os.makedirs(SubFolder, exist_ok = True)
# Create debian folder
DebSubFolder = SubFolder + "/debian"
os.makedirs(DebSubFolder, exist_ok = True)
BaseDeb = "./" + RootBaseDeb + "/"
ResultFolder = DebSubFolder + "/"
# Copy over each file that needs to be straight copied
for debfile in debfiles_tocopy:
DebFile = BaseDeb + debfile
if os.path.isdir(DebFile):
os.makedirs(ResultFolder + "/" + debfile, exist_ok = True)
for file in os.listdir(DebFile):
shutil.copy(DebFile + file, ResultFolder + debfile)
else:
shutil.copy(DebFile, ResultFolder)
# These need to be copied with rename
# "fex-emu.install",
# "fex-emu.postinst",
# "fex-emu.postrm",
# "libfex-emu-dev.install",
shutil.copy(BaseDeb + "/fex-emu.install", ResultFolder + "/fex-emu-" + arch[0] + ".install")
shutil.copy(BaseDeb + "/fex-emu.postinst", ResultFolder + "/fex-emu-" + arch[0] + ".postinst")
shutil.copy(BaseDeb + "/fex-emu.postrm", ResultFolder + "/fex-emu-" + arch[0] + ".postrm")
shutil.copy(BaseDeb + "/libfex-emu-dev.install", ResultFolder + "/libfex-emu-" + arch[0] + "-dev.install")
# Modify the changelog file in place
SpecificChangelogFile = DebSubFolder + "/" + "changelog"
SpecificChangelog = ReadFile(SpecificChangelogFile)
SpecificChangelog = SpecificChangelog.replace("@DISTRO_SERIES_LETTER@", distro[0])
SpecificChangelog = SpecificChangelog.replace("@DISTRO_SERIES@", distro[1])
SpecificChangelog = SpecificChangelog.replace("@ARCH_SUFFIX@", arch[0])
StoreFile(SpecificChangelogFile, SpecificChangelog)
# Modify the rules file in place
SpecificRulesFile = DebSubFolder + "/" + "rules"
SpecificRules = ReadFile(SpecificRulesFile)
SpecificRules = SpecificRules.replace("@TUNE_CPU@", arch[1])
StoreFile(SpecificRulesFile, SpecificRules)
# If this is armv8.0 then append the binfmt_misc builds to its control file
# Debian only allows one source package to provide a binary package
SpecificControlFile = DebSubFolder + "/" + "control"
SpecificSourceControlFile = BaseDeb + "/control." + arch[0]
if os.path.isfile(SpecificSourceControlFile):
SpecificSourceControl = ReadFile(SpecificSourceControlFile)
AppendToFile(SpecificControlFile, SpecificSourceControl)
# Modify the controls file in place
# Generate Arch conflicts
ArchConflicts = ""
LibArchConflicts = ""
for archconflict in supported_cpus:
if arch[0] != archconflict[0]:
ArchConflicts = ArchConflicts + "fex-emu-" + archconflict[0] + ", "
LibArchConflicts = LibArchConflicts + "libfex-emu-" + archconflict[0] + "-dev, "
# Strip ', '
ArchConflicts = ArchConflicts[:-2]
LibArchConflicts = LibArchConflicts[:-2]
SpecificControl = ReadFile(SpecificControlFile)
SpecificControl = SpecificControl.replace("@ARCH_SUFFIX@", arch[0])
SpecificControl = SpecificControl.replace("@ARCH_CONFLICTS@", ArchConflicts)
SpecificControl = SpecificControl.replace("@LIBARCH_CONFLICTS@", LibArchConflicts)
StoreFile(SpecificControlFile, SpecificControl)
# Create a softlink to the source folder which is unchanged between each distro
# This is terrible. It doesn't even go in to the package specific folder but instead the folder above it.
TargetSymlink = RootGenPPA + "/" + RootPackageName + "-" + arch[0] + "_" + RootPackageVersion + "~" + distro[0] + ".orig.tar.gz"
if os.path.islink(TargetSymlink):
os.remove(TargetSymlink)
os.symlink(os.path.abspath(SourceTar), TargetSymlink)
if Stage == 2:
print("Generating debuild files")
for distro in supported_distros:
for arch in supported_cpus:
SubFolder = RootGenPPA + "/" + RootPackageName + "-" + arch[0] + "_" + RootPackageVersion + "~" + distro[0]
p = subprocess.Popen(["debuild", "-S"], cwd = SubFolder)
p.wait()
if Stage == 3:
print("Uploading results")
for distro in supported_distros:
for arch in supported_cpus:
PackageName = RootPackageName + "-" + arch[0] + "_" + RootPackageVersion + "~" + distro[0] + "_source.changes"
p = subprocess.Popen(["dput", "ppa:fex-emu/fex", PackageName], cwd = RootGenPPA)
p.wait()

1
deb_base/changelog Normal file
View File

@ -0,0 +1 @@

View File

@ -0,0 +1,5 @@
fex-emu-@ARCH_SUFFIX@ (@VERSION@~@DISTRO_SERIES_LETTER@) @DISTRO_SERIES@; urgency=medium
@CHANGE_TEXT@
-- @UPLOADER_NAME@ <@UPLOADER_EMAIL@> @CHANGE_DATE@

47
deb_base/control Normal file
View File

@ -0,0 +1,47 @@
Source: fex-emu-@ARCH_SUFFIX@
Section: misc
Priority: optional
Maintainer: Ryan Houdek <houdek.ryan@fex-emu.org>
Uploaders: Ryan Houdek <houdek.ryan@fex-emu.org>
Standards-Version: 4.5.1
Build-Depends:
debhelper-compat (= 12),
cmake (>= 3.14),
ninja-build,
clang,
lld,
libsdl2-dev,
libepoxy-dev,
python3,
gzip,
llvm,
git,
tree,
Homepage: https://fex-emu.org/
Vcs-Browser: https://github.com/FEX-Emu/FEX
Vcs-Git: https://github.com/FEX-Emu/FEX.git
Rules-Requires-Root: no
Package: fex-emu-@ARCH_SUFFIX@
Section: misc
Architecture: any
Depends:
libsdl2-2.0-0,
libepoxy0,
${shlibs:Depends}, ${misc:Depends}
Conflicts: @ARCH_CONFLICTS@
Replaces: @ARCH_CONFLICTS@
Provides: fex-emu
Description: x86 and x86-64 Linux emulator
FEX is very much work in progress, so expect things to change.
Package: libfex-emu-@ARCH_SUFFIX@-dev
Section: libs
Architecture: any
Depends:
${shlibs:Depends}, ${misc:Depends}
Conflicts: @LIBARCH_CONFLICTS@
Replaces: @LIBARCH_CONFLICTS@
Provides: libfex-emu-dev
Description: x86 and x86-64 Linux emulator
FEX is very much work in progress, so expect things to change.

20
deb_base/control.armv8.0 Normal file
View File

@ -0,0 +1,20 @@
Package: fex-emu-binfmt32
Section: libs
Architecture: arm64
Depends:
binfmt-support,
fex-emu,
${shlibs:Depends}, ${misc:Depends}
Description: x86 and x86-64 Linux emulator
FEX is very much work in progress, so expect things to change.
Package: fex-emu-binfmt64
Section: libs
Architecture: arm64
Depends:
binfmt-support,
fex-emu,
${shlibs:Depends}, ${misc:Depends}
Description: x86 and x86-64 Linux emulator
FEX is very much work in progress, so expect things to change.

27
deb_base/copyright Normal file
View File

@ -0,0 +1,27 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: fex-emu
Upstream-Contact: FEX-Emu Maintainers <team@fex-emu.org>
Source: https://github.com/FEX-Emu/FEX
Files: *
Copyright: 2018 Ryan Houdek <Sonicadvance1@gmail.com>
License: MIT
Copyright (c) 2019 Ryan Houdek <Sonicadvance1@gmail.com>
.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1 @@
usr/share/binfmts/FEX-x86

View File

@ -0,0 +1,12 @@
#!/bin/sh
set -e
update_binfmt() {
# Check for update-binfmts
command -v update-binfmts >/dev/null || return 0
# Setup binfmt_misc
update-binfmts --import FEX-x86
}
update_binfmt

View File

@ -0,0 +1 @@
usr/share/binfmts/FEX-x86_64

View File

@ -0,0 +1,12 @@
#!/bin/sh
set -e
update_binfmt() {
# Check for update-binfmts
command -v update-binfmts >/dev/null || return 0
# Setup binfmt_misc
update-binfmts --import FEX-x86_64
}
update_binfmt

10
deb_base/fex-emu.install Normal file
View File

@ -0,0 +1,10 @@
usr/bin/FEXBash
usr/bin/FEXConfig
usr/bin/FEXGetConfig
usr/bin/FEXLoader
usr/bin/FEXLogServer
usr/bin/FEXMountDaemon
usr/bin/FEXRootFSFetcher
usr/bin/FEXUpdateAOTIRCache
usr/share/fex-emu/*
usr/share/man/man1/FEX.1.gz

View File

@ -0,0 +1,6 @@
#!/bin/sh
# Install FEXInterpreter hardlink
# Needs to be done before setting up binfmt_misc
rm /usr/bin/FEXInterpreter || true
ln -f /usr/bin/FEXLoader /usr/bin/FEXInterpreter

1
deb_base/fex-emu.postrm Normal file
View File

@ -0,0 +1 @@
rm /usr/bin/FEXInterpreter

1
deb_base/files Normal file
View File

@ -0,0 +1 @@
fex-emu_2201ubuntu4_source.buildinfo misc optional

0
deb_base/install Normal file
View File

View File

@ -0,0 +1,2 @@
usr/lib/libFEXCore*
usr/include/FEXCore/*

63
deb_base/rules Executable file
View File

@ -0,0 +1,63 @@
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1
include /usr/share/dpkg/pkg-info.mk
# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
confflags =
buildflags = \
CXXFLAGS="-Wno-deprecated-enum-enum-conversion"
confflags += \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_LTO=True \
-DENABLE_LLD=True \
-DENABLE_STATIC_PIE=False \
-DBUILD_TESTS=False \
-DENABLE_ASSERTIONS=False \
-DTUNE_CPU=@TUNE_CPU@ \
-DENABLE_X86_HOST_DEBUG=True
override_dh_clean:
rm -rf build
dh_clean
#override_dh_auto_configure:
# ls -l
# mkdir build
# cd build && $(buildflags) make $(confflags) -j$(nproc) ..
#
override_dh_auto_configure:
$(buildflags) dh_auto_configure -- $(confflags)
#override_dh_auto_build:
# cd build && ; tree .
#
# We will have installed with auto_install
#override_dh_install:
# true
#override_dh_installdocs:
# dh_installdocs
#override_dh_installchangelogs:
# dh_installchangelogs
%:
dh $@ --builddirectory=build/ --buildsystem=cmake

1
deb_base/source/format Normal file
View File

@ -0,0 +1 @@
3.0 (quilt)