This file is indexed.

/usr/share/sagemath/bin/sage-pkg is in sagemath-common 7.4-9.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python

from __future__ import print_function

import os, sys
from subprocess import Popen, PIPE, check_call, CalledProcessError

def tar_file(dir, no_compress=False):
    """
    Create tar file from ``dir``.  If ``no_compress`` is True, don't
    compress; otherwise, compress using bzip2.

    If on a Mac, set the environment variable ``COPYFILE_DISABLE`` to
    True and use the subprocess module to call tar (to use the new
    environment variable).  Otherwise, use the tarfile module to
    create the tar file.
    """
    if sys.platform == 'darwin':
        # workaround OS X issue -- see trac #2522
        COPYFILE_DISABLE = True
        os.environ['COPYFILE_DISABLE'] = 'true'
        if no_compress:
            cmd = "tar -cf %s.spkg %s" % (dir, dir)
        else:
            cmd = "tar -cf - %s | bzip2 > %s.spkg" % (dir, dir)
        try:
            check_call(cmd, shell=True)
        except CalledProcessError:
            print("Package creation failed.")
            sys.exit(1)
    else:
        import tarfile
        if no_compress:
            mode = "w"
        else:
            mode = "w:bz2"
        try:
            tar = tarfile.open("%s.spkg" % dir, mode=mode)
            tar.add(dir, exclude=lambda f: f == ".DS_Store")
            tar.close()
        except tarfile.TarError:
            print("Package creation failed.")
            sys.exit(1)

def main():
    import re
    from optparse import OptionParser
    parser = OptionParser()
    parser.add_option("-n", "--no-compress", "--no_compress", "--nocompress",
                      dest="no_compress", action="store_true",
                      help="don't compress the spkg file")
    (options, args) = parser.parse_args()
    for path in args:
        print("Creating {1}Sage package from {0}".format(path,
                "uncompressed " if options.no_compress else ""))

        if not os.path.isdir(path):
            print("No directory {}".format(path))
            sys.exit(1)
        dir = os.path.basename(path.rstrip("/"))
        file = dir + ".spkg"
        s = dir.split("-", 1)
        try:
            name = s[0]
            version = s[1]
        except IndexError:
            name = dir
            version = ""

        if len(version) == 0:
            print("Warning: no version number detected")
        else:
            m = re.match(r"[0-9]+[-.0-9a-zA-Z]*(\.p[0-9]+)?$", version)
            if not m:
                print("Warning: version number ({}) not of the expected form."
                      .format(version))
                print("""The version number should start with a number and contain only numbers,
letters, periods, and hyphens.  It may optionally end with a string of
the form 'pNUM' where NUM is a non-negative integer.

Proceeding anyway...""")

        tar_file(dir, no_compress = options.no_compress)

        size = os.path.getsize(file)
        if size < 1024 * 1024:
            size = "{}K".format(size / 1024)
        else:
            size = "{:.1f}M".format(size / (1024 * 1024.0))

        if os.path.exists(os.path.join(dir, "SPKG.txt")):
            spkg_txt = "Good"
        else:
            spkg_txt = "File is missing"

        print("""
Created package {file}.

    NAME: {name}
 VERSION: {version}
    SIZE: {size}
SPKG.txt: {spkg}

Please test this package using

   sage -f {file}

immediately.""".format(file=file, name=name,  version=version, size=size,
                       spkg=spkg_txt), end=' ')

        if options.no_compress:
            print()
            print()
        else:
            print(""" Also, note that you can use

   sage -pkg_nc {}

to make an uncompressed version of the package (useful if the
package is full of compressed data).
""".format(dir))

if __name__ == "__main__":
    main()