2018-10-25 10:33:37 +02:00
|
|
|
#! /usr/bin/env nix-shell
|
|
|
|
#! nix-shell -i python2 -p "with python2Packages; [python debian]"
|
|
|
|
|
2015-10-20 16:08:44 +02:00
|
|
|
# Script to build a Nix script to actually build a Steam runtime.
|
|
|
|
# Patched version of https://github.com/ValveSoftware/steam-runtime/blob/master/build-runtime.py
|
|
|
|
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
import urllib
|
|
|
|
import gzip
|
|
|
|
import cStringIO
|
|
|
|
import subprocess
|
|
|
|
from debian import deb822
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
destdir="newpkg"
|
|
|
|
arches=["amd64", "i386"]
|
|
|
|
|
|
|
|
REPO="http://repo.steampowered.com/steamrt"
|
|
|
|
DIST="scout"
|
|
|
|
COMPONENT="main"
|
|
|
|
|
2018-10-25 10:33:37 +02:00
|
|
|
out = open("runtime-generated.nix", "w")
|
2015-10-20 16:08:44 +02:00
|
|
|
out.write("# This file is autogenerated! Do not edit it yourself, use update-runtime.py for regeneration.\n")
|
|
|
|
out.write("{ fetchurl }:\n")
|
|
|
|
out.write("\n")
|
|
|
|
out.write("{\n")
|
|
|
|
|
|
|
|
def parse_args():
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("-b", "--beta", help="build beta runtime", action="store_true")
|
|
|
|
parser.add_argument("-d", "--debug", help="build debug runtime", action="store_true")
|
|
|
|
parser.add_argument("--symbols", help="include debugging symbols", action="store_true")
|
|
|
|
parser.add_argument("--repo", help="source repository", default=REPO)
|
|
|
|
return parser.parse_args()
|
|
|
|
|
2019-04-19 18:19:22 +02:00
|
|
|
def download_file(file_base, file_name, file_url, sha256):
|
2015-10-20 16:08:44 +02:00
|
|
|
file_shortname = file_base + ".deb"
|
|
|
|
out.write(" rec {\n")
|
|
|
|
out.write(" name = \"%s\";\n" % file_name)
|
2019-04-19 18:19:22 +02:00
|
|
|
out.write(" sha256 = \"%s\";\n" % sha256)
|
2016-02-19 12:07:09 +01:00
|
|
|
out.write(" url = \"%s\";\n" % file_url.replace(REPO, "mirror://steamrt", 1))
|
2015-10-20 16:08:44 +02:00
|
|
|
out.write(" source = fetchurl {\n")
|
2016-09-06 01:48:13 +02:00
|
|
|
out.write(" inherit url sha256;\n")
|
2015-10-20 16:08:44 +02:00
|
|
|
out.write(" name = \"%s\";\n" % file_shortname)
|
|
|
|
out.write(" };\n")
|
|
|
|
out.write(" }\n")
|
|
|
|
|
|
|
|
|
2019-04-19 18:19:22 +02:00
|
|
|
def parse_dependencies (arch, binarylist):
|
|
|
|
packages_url = "%s/dists/%s/%s/binary-%s/Packages" % (REPO, DIST, COMPONENT, arch)
|
|
|
|
for stanza in deb822.Packages.iter_paragraphs(urllib.urlopen(packages_url)):
|
|
|
|
p = stanza['Package']
|
|
|
|
if p in binarylist:
|
|
|
|
for deps in stanza.relations['depends']:
|
|
|
|
for dep in deps:
|
|
|
|
binarylist.add(dep['name'])
|
|
|
|
return binarylist
|
|
|
|
|
2015-10-20 16:08:44 +02:00
|
|
|
def install_binaries (arch, binarylist):
|
2019-04-19 18:19:22 +02:00
|
|
|
installset = parse_dependencies(arch, binarylist.copy())
|
|
|
|
# Steam doesn't start if we include their libc
|
|
|
|
installset.remove("libc6")
|
2015-10-20 16:08:44 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Load the Packages file so we can find the location of each binary package
|
|
|
|
#
|
|
|
|
packages_url = "%s/dists/%s/%s/binary-%s/Packages" % (REPO, DIST, COMPONENT, arch)
|
|
|
|
print("Downloading %s binaries from %s" % (arch, packages_url))
|
|
|
|
for stanza in deb822.Packages.iter_paragraphs(urllib.urlopen(packages_url)):
|
|
|
|
p = stanza['Package']
|
|
|
|
if p in installset:
|
|
|
|
print("DOWNLOADING BINARY: %s" % p)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Download the package and install it
|
|
|
|
#
|
|
|
|
file_url="%s/%s" % (REPO,stanza['Filename'])
|
2019-04-19 18:19:22 +02:00
|
|
|
download_file(p, os.path.splitext(os.path.basename(stanza['Filename']))[0], file_url, stanza["SHA256"])
|
2015-10-20 16:08:44 +02:00
|
|
|
installset.remove(p)
|
|
|
|
|
|
|
|
for p in installset:
|
|
|
|
#
|
|
|
|
# There was a binary package in the list to be installed that is not in the repo
|
|
|
|
#
|
|
|
|
e = "ERROR: Package %s not found in Packages file %s\n" % (p, packages_url)
|
|
|
|
sys.stderr.write(e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def install_symbols (arch, binarylist):
|
|
|
|
#
|
|
|
|
# Load the Packages file to find the location of each symbol package
|
|
|
|
#
|
|
|
|
packages_url = "%s/dists/%s/%s/debug/binary-%s/Packages" % (REPO, DIST, COMPONENT, arch)
|
|
|
|
print("Downloading %s symbols from %s" % (arch, packages_url))
|
|
|
|
for stanza in deb822.Packages.iter_paragraphs(urllib.urlopen(packages_url)):
|
|
|
|
p = stanza['Package']
|
|
|
|
m = re.match('([\w\-\.]+)\-dbgsym', p)
|
|
|
|
if m and m.group(1) in binarylist:
|
|
|
|
print("DOWNLOADING SYMBOLS: %s" % p)
|
|
|
|
#
|
|
|
|
# Download the package and install it
|
|
|
|
#
|
|
|
|
file_url="%s/%s" % (REPO,stanza['Filename'])
|
|
|
|
download_file(p, os.path.splitext(os.path.basename(stanza['Filename']))[0], file_url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args = parse_args()
|
|
|
|
|
|
|
|
REPO=args.repo
|
|
|
|
|
|
|
|
if args.beta:
|
|
|
|
DIST="steam_beta"
|
|
|
|
|
|
|
|
if args.debug:
|
|
|
|
COMPONENT = "debug"
|
|
|
|
|
|
|
|
# Process packages.txt to get the list of source and binary packages
|
|
|
|
binary_pkgs = set()
|
|
|
|
|
|
|
|
print ("Creating runtime-generated.nix")
|
|
|
|
|
2019-04-19 18:19:22 +02:00
|
|
|
# https://github.com/ValveSoftware/steam-runtime/blob/173ef028fb6b84e804f4e1b0ef11c12ffd4f3a8e/build-runtime.py#L264
|
|
|
|
binary_pkgs.add("steamrt-libs")
|
|
|
|
binary_pkgs.add("steamrt-legacy")
|
2015-10-20 16:08:44 +02:00
|
|
|
|
|
|
|
for arch in arches:
|
|
|
|
out.write(" %s = [\n" % arch)
|
|
|
|
install_binaries(arch, binary_pkgs)
|
|
|
|
|
|
|
|
if args.symbols:
|
|
|
|
install_symbols(arch, binary_pkgs)
|
|
|
|
|
|
|
|
out.write(" ];\n");
|
|
|
|
|
|
|
|
out.write("}\n")
|
|
|
|
|
|
|
|
# vi: set noexpandtab:
|