lol
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 17.09-beta 138 lines 4.2 kB view raw
1#!/usr/bin/env python2 2# 3# Script to build a Nix script to actually build a Steam runtime. 4# Patched version of https://github.com/ValveSoftware/steam-runtime/blob/master/build-runtime.py 5 6import os 7import re 8import sys 9import urllib 10import gzip 11import cStringIO 12import subprocess 13from debian import deb822 14import argparse 15 16destdir="newpkg" 17arches=["amd64", "i386"] 18 19REPO="http://repo.steampowered.com/steamrt" 20DIST="scout" 21COMPONENT="main" 22 23out = open("runtime-generated.nix", "w"); 24out.write("# This file is autogenerated! Do not edit it yourself, use update-runtime.py for regeneration.\n") 25out.write("{ fetchurl }:\n") 26out.write("\n") 27out.write("{\n") 28 29def parse_args(): 30 parser = argparse.ArgumentParser() 31 parser.add_argument("-b", "--beta", help="build beta runtime", action="store_true") 32 parser.add_argument("-d", "--debug", help="build debug runtime", action="store_true") 33 parser.add_argument("--symbols", help="include debugging symbols", action="store_true") 34 parser.add_argument("--repo", help="source repository", default=REPO) 35 return parser.parse_args() 36 37def download_file(file_base, file_name, file_url): 38 file_shortname = file_base + ".deb" 39 sha256 = subprocess.check_output(["nix-prefetch-url", "--type", "sha256", "--name", file_shortname, file_url]) 40 out.write(" rec {\n") 41 out.write(" name = \"%s\";\n" % file_name) 42 out.write(" sha256 = \"%s\";\n" % sha256.strip()) 43 out.write(" url = \"%s\";\n" % file_url.replace(REPO, "mirror://steamrt", 1)) 44 out.write(" source = fetchurl {\n") 45 out.write(" inherit url sha256;\n") 46 out.write(" name = \"%s\";\n" % file_shortname) 47 out.write(" };\n") 48 out.write(" }\n") 49 50 51def install_binaries (arch, binarylist): 52 installset = binarylist.copy() 53 54 # 55 # Load the Packages file so we can find the location of each binary package 56 # 57 packages_url = "%s/dists/%s/%s/binary-%s/Packages" % (REPO, DIST, COMPONENT, arch) 58 print("Downloading %s binaries from %s" % (arch, packages_url)) 59 for stanza in deb822.Packages.iter_paragraphs(urllib.urlopen(packages_url)): 60 p = stanza['Package'] 61 if p in installset: 62 print("DOWNLOADING BINARY: %s" % p) 63 64 # 65 # Download the package and install it 66 # 67 file_url="%s/%s" % (REPO,stanza['Filename']) 68 download_file(p, os.path.splitext(os.path.basename(stanza['Filename']))[0], file_url) 69 installset.remove(p) 70 71 for p in installset: 72 # 73 # There was a binary package in the list to be installed that is not in the repo 74 # 75 e = "ERROR: Package %s not found in Packages file %s\n" % (p, packages_url) 76 sys.stderr.write(e) 77 78 79 80def install_symbols (arch, binarylist): 81 # 82 # Load the Packages file to find the location of each symbol package 83 # 84 packages_url = "%s/dists/%s/%s/debug/binary-%s/Packages" % (REPO, DIST, COMPONENT, arch) 85 print("Downloading %s symbols from %s" % (arch, packages_url)) 86 for stanza in deb822.Packages.iter_paragraphs(urllib.urlopen(packages_url)): 87 p = stanza['Package'] 88 m = re.match('([\w\-\.]+)\-dbgsym', p) 89 if m and m.group(1) in binarylist: 90 print("DOWNLOADING SYMBOLS: %s" % p) 91 # 92 # Download the package and install it 93 # 94 file_url="%s/%s" % (REPO,stanza['Filename']) 95 download_file(p, os.path.splitext(os.path.basename(stanza['Filename']))[0], file_url) 96 97 98 99args = parse_args() 100 101REPO=args.repo 102 103if args.beta: 104 DIST="steam_beta" 105 106if args.debug: 107 COMPONENT = "debug" 108 109# Process packages.txt to get the list of source and binary packages 110source_pkgs = set() 111binary_pkgs = set() 112 113print ("Creating runtime-generated.nix") 114 115pkgs_list = urllib.urlopen("https://raw.githubusercontent.com/ValveSoftware/steam-runtime/master/packages.txt").readlines() 116for line in pkgs_list: 117 if line[0] != '#': 118 toks = line.split() 119 if len(toks) > 1: 120 source_pkgs.add(toks[0]) 121 binary_pkgs.update(toks[1:]) 122 123# remove development packages for end-user runtime 124if not args.debug: 125 binary_pkgs -= {x for x in binary_pkgs if re.search('-dbg$|-dev$|-multidev$',x)} 126 127for arch in arches: 128 out.write(" %s = [\n" % arch) 129 install_binaries(arch, binary_pkgs) 130 131 if args.symbols: 132 install_symbols(arch, binary_pkgs) 133 134 out.write(" ];\n"); 135 136out.write("}\n") 137 138# vi: set noexpandtab: