;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2020 Mathieu Othacehe ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu build shepherd) #:use-module (gnu system file-systems) #:use-module (gnu build linux-container) #:use-module (guix build utils) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module
aboutsummaryrefslogtreecommitdiff
blob: 9115d9aee36a6bc69bc6658a1900f34fea26706f (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! @PYTHON@
# -*- mode: python -*-

import glob
import os
import sys
import warnings

def __renpy_files(directory):
    for pattern in ['*.rpa', '*.rpyc', '*.rpy']:
        for file in glob.iglob(pattern, root_dir=directory):
            yield file

def path_to_gamedir(basedir, name):
    candidates = [name, 'game', 'data', 'launcher/game']

    if __renpy_files(basedir):
        return basedir

    for candidate in candidates:
        gamedir = os.path.join(basedir, candidate)
        if __renpy_files(gamedir):
            return gamedir

    return basedir

def path_to_common(renpy_base):
    return renpy_base + "/common"

def path_to_saves(gamedir, save_directory=None):
    import renpy

    if save_directory is None:
        save_directory = renpy.config.save_directory
        save_directory = renpy.exports.fsencode(save_directory)

    if not save_directory:
        return gamedir + "/saves"

    return os.path.join(os.path.expanduser("~/.renpy"), save_directory)

def main():
    try:
        import renpy.bootstrap
        import renpy.arguments
    except ImportError:
        print("""Could not import renpy.bootstrap.
Please ensure you decompressed Ren'py correctly, preserving the directory
structure.""", file=sys.stderr)
        raise

    args = renpy.arguments.bootstrap()
    if not args.basedir:
        print("""This Ren'py requires a basedir to launch.
The basedir is the directory, in which .rpy source files or compiled .rpyc files
live -- usually the 'game' subdirectory of a game packaged by Ren'py.

If you want the Ren'py launcher, use \"renpy-launcher\" instead.""",
              file=sys.stderr)
        sys.exit()

    renpy.bootstrap.bootstrap("@RENPY_BASE@")

if __name__ == "__main__":
    main()
#:log-file log-file #:directory directory #:environment-variables environment-variables))))) (if pid-file (if (or (memq 'mnt namespaces) (memq 'pid namespaces)) (read-pid-file/container pid pid-file #:max-delay pid-file-timeout) (read-pid-file pid-file #:max-delay pid-file-timeout)) pid)))) (define* (fork+exec-command/container command #:key pid #:allow-other-keys #:rest args) "This is a variant of 'fork+exec-command' procedure, that joins the namespaces of process PID beforehand. If there is no support for containers, on Hurd systems for instance, fallback to direct forking." (define (strip-pid args) ;; TODO: Replace with 'strip-keyword-arguments' when that no longer pulls ;; in (guix config). (let loop ((args args) (result '())) (match args (() (reverse result)) ((#:pid _ . rest) (loop rest result)) ((head . rest) (loop rest (cons head result)))))) (let ((container-support? (file-exists? "/proc/self/ns")) (fork-proc (lambda () (apply fork+exec-command command (strip-pid args))))) (if container-support? (container-excursion* pid fork-proc) (fork-proc)))) ;; Local Variables: ;; eval: (put 'container-excursion* 'scheme-indent-function 1) ;; End: ;;; shepherd.scm ends here