steam-runtime: build using new Runtime build system
This commit is contained in:
parent
18ddcd2847
commit
eae00fe687
106
pkgs/games/steam/build-runtime.py
Normal file
106
pkgs/games/steam/build-runtime.py
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
#!/usr/bin/env python2
|
||||||
|
#
|
||||||
|
# Script to build and install packages into the Steam runtime
|
||||||
|
# Patched version of https://github.com/ValveSoftware/steam-runtime/blob/master/build-runtime.py
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
|
||||||
|
# The top level directory
|
||||||
|
top = sys.path[0]
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("-r", "--runtime", help="specify runtime path", default=os.path.join(top,"runtime"))
|
||||||
|
parser.add_argument("-i", "--input", help="packages JSON", required=True)
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def install_deb (basename, deb, md5, dest_dir):
|
||||||
|
installtag_dir=os.path.join(dest_dir, "installed")
|
||||||
|
if not os.access(installtag_dir, os.W_OK):
|
||||||
|
os.makedirs(installtag_dir)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Write the tag file and checksum to the 'installed' subdirectory
|
||||||
|
#
|
||||||
|
with open(os.path.join(installtag_dir,basename),"w") as f:
|
||||||
|
subprocess.check_call(['dpkg-deb', '-c', deb], stdout=f)
|
||||||
|
with open(os.path.join(installtag_dir,basename+".md5"),"w") as f:
|
||||||
|
f.write("%s %s.deb\n" % (md5, basename))
|
||||||
|
|
||||||
|
#
|
||||||
|
# Unpack the package into the dest_dir
|
||||||
|
#
|
||||||
|
os.chdir(top)
|
||||||
|
subprocess.check_call(['dpkg-deb', '-x', deb, dest_dir])
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Walks through the files in the runtime directory and converts any absolute symlinks
|
||||||
|
# to their relative equivalent
|
||||||
|
#
|
||||||
|
def fix_symlinks ():
|
||||||
|
for dir, subdirs, files in os.walk(args.runtime):
|
||||||
|
for name in files:
|
||||||
|
filepath=os.path.join(dir,name)
|
||||||
|
if os.path.islink(filepath):
|
||||||
|
target = os.readlink(filepath)
|
||||||
|
if os.path.isabs(target):
|
||||||
|
#
|
||||||
|
# compute the target of the symlink based on the 'root' of the architecture's runtime
|
||||||
|
#
|
||||||
|
target2 = os.path.join(args.runtime,target[1:])
|
||||||
|
|
||||||
|
#
|
||||||
|
# Set the new relative target path
|
||||||
|
#
|
||||||
|
os.unlink(filepath)
|
||||||
|
os.symlink(os.path.relpath(target2,dir), filepath)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Creates the usr/lib/debug/.build-id/xx/xxxxxxxxx.debug symlink tree for all the debug
|
||||||
|
# symbols
|
||||||
|
#
|
||||||
|
def fix_debuglinks ():
|
||||||
|
for dir, subdirs, files in os.walk(os.path.join(args.runtime,"usr/lib/debug")):
|
||||||
|
if ".build-id" in subdirs:
|
||||||
|
subdirs.remove(".build-id") # don't recurse into .build-id directory we are creating
|
||||||
|
|
||||||
|
for file in files:
|
||||||
|
|
||||||
|
#
|
||||||
|
# scrape the output of readelf to find the buildid for this binary
|
||||||
|
#
|
||||||
|
p = subprocess.Popen(["readelf", '-n', os.path.join(dir,file)], stdout=subprocess.PIPE)
|
||||||
|
for line in iter(p.stdout.readline, ""):
|
||||||
|
m = re.search('Build ID: (\w{2})(\w+)',line)
|
||||||
|
if m:
|
||||||
|
linkdir = os.path.join(args.runtime,"usr/lib/debug/.build-id",m.group(1))
|
||||||
|
if not os.access(linkdir, os.W_OK):
|
||||||
|
os.makedirs(linkdir)
|
||||||
|
link = os.path.join(linkdir,m.group(2))
|
||||||
|
print "SYMLINKING symbol file %s to %s" % (link, os.path.relpath(os.path.join(dir,file),linkdir))
|
||||||
|
if os.path.lexists(link):
|
||||||
|
os.unlink(link)
|
||||||
|
os.symlink(os.path.relpath(os.path.join(dir,file), linkdir),link)
|
||||||
|
|
||||||
|
|
||||||
|
args = parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
print ("Creating Steam Runtime in %s" % args.runtime)
|
||||||
|
|
||||||
|
with open(args.input) as pkgfile:
|
||||||
|
pkgs = json.load(pkgfile)
|
||||||
|
for pkg in pkgs:
|
||||||
|
install_deb(pkg["name"], pkg["source"], pkg["md5"], args.runtime)
|
||||||
|
|
||||||
|
fix_debuglinks()
|
||||||
|
fix_symlinks()
|
||||||
|
|
||||||
|
# vi: set noexpandtab:
|
3483
pkgs/games/steam/runtime-generated.nix
Normal file
3483
pkgs/games/steam/runtime-generated.nix
Normal file
File diff suppressed because it is too large
Load diff
|
@ -98,7 +98,7 @@ in stdenv.mkDerivation rec {
|
||||||
|
|
||||||
nativeBuildInputs = [ perl ];
|
nativeBuildInputs = [ perl ];
|
||||||
|
|
||||||
builder = ./build-runtime.sh;
|
builder = ./build-wrapped.sh;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
buildDir "${toString steam-runtime.libs}" "$allPkgs"
|
buildDir "${toString steam-runtime.libs}" "$allPkgs"
|
||||||
|
|
|
@ -1,23 +1,21 @@
|
||||||
{ stdenv, fetchurl }:
|
{ stdenv, fetchurl, writeText, python2, dpkg, binutils }:
|
||||||
|
|
||||||
let arch = if stdenv.system == "x86_64-linux" then "amd64"
|
let arch = if stdenv.system == "x86_64-linux" then "amd64"
|
||||||
else if stdenv.system == "i686-linux" then "i386"
|
else if stdenv.system == "i686-linux" then "i386"
|
||||||
else abort "Unsupported platform";
|
else abort "Unsupported platform";
|
||||||
|
|
||||||
in stdenv.mkDerivation rec {
|
input = builtins.getAttr arch (import ./runtime-generated.nix { inherit fetchurl; });
|
||||||
name = "steam-runtime-${version}";
|
|
||||||
version = "2014-04-15";
|
|
||||||
|
|
||||||
phases = [ "unpackPhase" "installPhase" ];
|
inputFile = writeText "steam-runtime.json" (builtins.toJSON input);
|
||||||
|
|
||||||
src = fetchurl {
|
in stdenv.mkDerivation {
|
||||||
url = "http://media.steampowered.com/client/runtime/steam-runtime-release_${version}.tar.xz";
|
name = "steam-runtime-20151020";
|
||||||
sha256 = "0i6xp81rjbfn4664h4mmvw0xjwlwvdp6k7cc53jfjadcblw5cf99";
|
|
||||||
};
|
|
||||||
|
|
||||||
installPhase = ''
|
nativeBuildInputs = [ python2 dpkg binutils ];
|
||||||
|
|
||||||
|
buildCommand = ''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
mv ${arch}/* $out/
|
python2 ${./build-runtime.py} -i ${inputFile} -r $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = rec {
|
passthru = rec {
|
||||||
|
@ -34,8 +32,7 @@ in stdenv.mkDerivation rec {
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
description = "The official runtime used by Steam";
|
description = "The official runtime used by Steam";
|
||||||
homepage = https://github.com/ValveSoftware/steam-runtime;
|
homepage = https://github.com/ValveSoftware/steam-runtime;
|
||||||
license = licenses.mit;
|
license = licenses.unfreeRedistributable; # Includes NVIDIA CG toolkit
|
||||||
maintainers = with maintainers; [ hrdinka ];
|
maintainers = with maintainers; [ hrdinka abbradar ];
|
||||||
hydraPlatforms = [];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
138
pkgs/games/steam/update-runtime.py
Executable file
138
pkgs/games/steam/update-runtime.py
Executable file
|
@ -0,0 +1,138 @@
|
||||||
|
#!/usr/bin/env python2
|
||||||
|
#
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
out = open("runtime-generated.nix", "w");
|
||||||
|
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()
|
||||||
|
|
||||||
|
def download_file(file_base, file_name, file_url):
|
||||||
|
file_shortname = file_base + ".deb"
|
||||||
|
md5 = subprocess.check_output(["nix-prefetch-url", "--type", "md5", "--name", file_shortname, file_url])
|
||||||
|
out.write(" rec {\n")
|
||||||
|
out.write(" name = \"%s\";\n" % file_name)
|
||||||
|
out.write(" md5 = \"%s\";\n" % md5.strip())
|
||||||
|
out.write(" source = fetchurl {\n")
|
||||||
|
out.write(" url = \"%s\";\n" % file_url)
|
||||||
|
out.write(" inherit md5;\n")
|
||||||
|
out.write(" name = \"%s\";\n" % file_shortname)
|
||||||
|
out.write(" };\n")
|
||||||
|
out.write(" }\n")
|
||||||
|
|
||||||
|
|
||||||
|
def install_binaries (arch, binarylist):
|
||||||
|
installset = binarylist.copy()
|
||||||
|
|
||||||
|
#
|
||||||
|
# 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'])
|
||||||
|
download_file(p, os.path.splitext(os.path.basename(stanza['Filename']))[0], file_url)
|
||||||
|
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
|
||||||
|
source_pkgs = set()
|
||||||
|
binary_pkgs = set()
|
||||||
|
|
||||||
|
print ("Creating runtime-generated.nix")
|
||||||
|
|
||||||
|
pkgs_list = urllib.urlopen("https://raw.githubusercontent.com/ValveSoftware/steam-runtime/master/packages.txt").readlines()
|
||||||
|
for line in pkgs_list:
|
||||||
|
if line[0] != '#':
|
||||||
|
toks = line.split()
|
||||||
|
if len(toks) > 1:
|
||||||
|
source_pkgs.add(toks[0])
|
||||||
|
binary_pkgs.update(toks[1:])
|
||||||
|
|
||||||
|
# remove development packages for end-user runtime
|
||||||
|
if not args.debug:
|
||||||
|
binary_pkgs -= {x for x in binary_pkgs if re.search('-dbg$|-dev$|-multidev$',x)}
|
||||||
|
|
||||||
|
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:
|
Loading…
Reference in a new issue