/usr/bin/pyntor-selfrun is in pyntor 0.6-4.
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Creation of self-extracting Pyntor presentations
# Copyright (C) 2006 Josef Spillner <josef@coolprojects.org>
# Published under GNU GPL conditions
import base64
import os
import sys
import getopt
#import tempfile
import atexit
### Parse command line options
templatename = "pyntor-selfrun.template"
releasefile = None
archiveonly = False
try:
longopts = ["help", "archive", "template=", "release="]
options = getopt.gnu_getopt(sys.argv[1:], "hat:r:", longopts)
except:
print "Error:", sys.exc_info()[1]
sys.exit(1)
(options, arguments) = options
for opt in options:
(optkey, optvalue) = opt
if optkey in ("-h", "--help"):
print "Pyntor Selfrun - tool to create self-extracting presentations"
print "Copyright (C) 2006 Josef Spillner <josef@coolprojects.org>"
print "Published under GNU GPL conditions"
print ""
print "Synopsis: pyntor-selfrun [options] <presentation-archive>|<presentation-dir>"
print ""
print "Options:"
print "[-t | --template=...] Template file to use instead of the default"
print "[-r | --release=... ] Take pyntor files from release tarball"
print "[-a | --archive ] Only create archive from presentation directory"
print "[-h | --help ] Display this help"
sys.exit(0)
elif optkey in ("-t", "--template"):
templatename = optvalue
elif optkey in ("-r", "--release"):
releasefile = optvalue
elif optkey in ("-a", "--archive"):
archiveonly = True
if len(arguments) != 1:
print "Error: either presentation archive or presentation directory not specified"
sys.exit(-1)
### Check if presentation archive or directory was given
filename = arguments[0]
tempname = None
try:
contents = os.listdir(filename)
dirname = filename + "/"
dirname = dirname.replace("//", "/")
dirname = dirname.split("/")[-2]
tempname = dirname + ".pyntor"
except:
pass
if tempname:
#tempdir = tempfile.mkdtemp()
tempdir = "."
os.system("tar czf " + tempdir + "/" + tempname + " " + filename)
def cleanup(tmpfile):
if tmpfile is not None:
#print "(cleanup...)", tmpfile
os.remove(tmpfile)
if archiveonly:
if not tempname:
print "Error: must specify a presentation directory for archive creation"
sys.exit(-1)
else:
print "Created presentation archive", tempname, "from", filename
sys.exit(0)
else:
if tempname:
atexit.register(cleanup, tempname)
filename = tempname
### Get the tarball filename
if releasefile:
pyntorname = releasefile
else:
print "Error: pyntor release tarball argument missing"
sys.exit(1)
### Load template file
try:
templatefile = open(templatename)
except:
print "Error: could not open template file", templatename
sys.exit(1)
template = templatefile.readlines()
template = str.join("", template)
templatefile.close()
### Create tempfile with archive in base64 format
try:
infile = open(filename)
except:
print "Error: could not open presentation file", filename
sys.exit(1)
packfilename = filename + ".b64"
try:
outfile = open(packfilename, "w")
except:
print "Error: could not write to temporary file", packfilename
sys.exit(1)
base64.encode(infile, outfile)
infile.close()
outfile.close()
### Same for pyntor source archive
try:
infile = open(pyntorname)
except:
print "Error: could not open pyntor source archive", pyntorname
sys.exit(1)
packpyntorname = pyntorname + ".b64"
try:
outfile = open(packpyntorname, "w")
except:
print "Error: could not write to temporary file", packpyntorname
sys.exit(1)
base64.encode(infile, outfile)
infile.close()
outfile.close()
### Read in base64 strings and delete tempfiles
packfile = open(packfilename)
lines = packfile.readlines()
lines = str.join("", lines)
packfile.close()
os.unlink(packfilename)
packfile = open(packpyntorname)
pyntorlines = packfile.readlines()
pyntorlines = str.join("", pyntorlines)
packfile.close()
os.unlink(packpyntorname)
### Write out templates with archive string replacements
template = template.replace("%ARCHIVE%", lines)
template = template.replace("%PYNTOR%", pyntorlines)
extractorname = filename + ".selfrun.py"
try:
extractorfile = open(extractorname, "w")
except:
print "Error: could not write to self-extracting file", extractorname
sys.exit(1)
extractorfile.write(template)
extractorfile.close()
os.chmod(extractorname, 0755)
print "Created self-extracting archive", extractorname
|