/usr/bin/polymake is in polymake-common 3.2r2-3.
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 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | #!/usr/bin/perl
#
# Copyright (c) 1997-2018
# Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
# http://www.polymake.org
#
# This program 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 2, or (at your option) any
# later version: http://www.gnu.org/licenses/gpl.txt.
#
# This program 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.
#-------------------------------------------------------------------------------
use v5.16;
package Polymake;
# global variables needed for the bootstrap
use vars qw($InstallTop $InstallArch $Arch $DeveloperMode @BundledExts $ConfigTime $DebugLevel);
my @addlibs;
BEGIN {
$InstallTop="/usr/share/polymake";
$InstallArch="/usr/lib/polymake";
$Arch="x86_64";
@BundledExts=qw(bliss cdd libnormaliz lrs ppl sympol atint);
}
use lib "$InstallTop/perllib", "$InstallArch/perlx", @addlibs;
#########################################################################################
#
# Parsing the command line
#
use Getopt::Long qw( GetOptions :config require_order bundling no_ignore_case );
my ($verbose, $script, $iscript, $connect, $touch, $help, $tell_version, $start_application, $ignore_start_applications, $reconfigure);
my @config_path;
if ( ! GetOptions( 'v+' => \$verbose, 'd+' => \$DebugLevel,
'A=s' => sub { $start_application = $_[1]; $ignore_start_applications=1; },
'a=s' => \$start_application,
### 'T=f' => \$Polymake::Core::Rule::timeout,
'script=s' => sub { $script=$_[1]; die "!FINISH\n" },
'iscript=s' => sub { $iscript=$_[1]; die "!FINISH\n" },
'connect=s' => \$connect,
'touch' => \$touch, 'help' => \$help, 'version' => \$tell_version,
'config-path=s' => \@config_path,
'no-config' => sub { @config_path=("none") },
'ignore-config' => sub { @config_path=("ignore") },
'reconfigure' => \$reconfigure,
)
# --*script --connect --touch --help --version are mutually exclusive
or defined($script)+defined($iscript)+defined($connect)+(@ARGV==1 && $ARGV[0] eq "-")+$touch+$help+$tell_version > 1
# --help --version do not consume any additional args
or $help+$tell_version && @ARGV) {
$!=1;
die <<'.';
usage: polymake [-dv] [-A|-a <application>]
[--reconfigure] [--config-path PATH ... | --no-config | --ignore-config]
[ --script | --iscript <script_file> arg ... ] | '<code>' | --connect SOCKETFILE || HOST:PORT | -
<file> <property|method> ... |
--touch <file> ... | --help | --version
.
}
if ($help) {
print STDERR <<'.';
usage: polymake [options] [arguments]
Called without arguments:
start an interactive shell.
Arguments may be one of the following:
--help
Print this text and exit.
--version
Print the version number, copyright notice, and exit.
[--script] [application::]script_file
Execute the script stored in a file.
If application prefix is specified, this application is loaded
and the script file is looked up in its script directory.
--script [application::]script_file arguments ...
Execute the script, passing the arguments in @ARGV .
--iscript [application::]script_file arguments ...
Execute the script which may contain interactive commands.
'code'
Interpret the string as a perl expression.
-
Read and execute the commands from the standard input.
Standard output and error streams are not redirected.
--connect SOCKETFILE
Read and execute the commands from a named socket.
Print commands send the data back into the socket.
--connect HOST:PORT
Connect to the remote host, read and execute commands.
Standard output and error streams are sent back to the host.
file PROPERTY | METHOD [ ... ]
Legacy mode (resembling polymake <= 2.3):
Read the object from the data file, print the properties or
run the user methods.
--touch file [ file ... ]
Read the files and write them out; useful for converting from
older polymake versions.
Options are:
-A application_name
Start with this application, ignoring the $default_application and
@start_applications settings.
-a application_name
Start with this application, ignoring the $default_application but,
in contrast to -A, load everything in @start_applications.
-d Produce some debug output; can be repeated to increase the debug level.
-v Tell what's going on; can be repeated to increase the verbosity level.
This is an obsolete option, please use custom variables $Verbose::*
to gain more detailed control.
--reconfigure
Re-run the autoconfiguration sections in all rule files.
--config-path PATH
Import settings from a global configuration file;
PATH may also point to a folder containing files prefer.pl and/or customize.pl
created by polymake earlier e.g. for another user.
Several --config-path options are allowed, later instances override settings
from earlier ones.
--config-path user[=DIR]
Specify the location of user's private settings, by default it's ~/.polymake
which may be overridden via POLYMAKE_USER_DIR environment variable.
All global --config-path imports must precede this option.
--no-config
Don't read any configuration files,
don't try to configure rules automatically,
don't load rule files requiring auto-configuration.
Equivalent to --config-path=none .
--ignore-config
Don't read any configuration files,
skip auto-configuration routines in the rule files.
Equivalent to --config-path=ignore .
.
exit;
}
# Getopt::Long does not allow to combine short option bundling with multi-value options
# Here is a work-around. It is not used in this main program but in some scripts.
sub collect_arglist {
my $list=shift;
@$list=@_;
while (@ARGV && $ARGV[0] !~ /^-/) {
push @$list, shift @ARGV;
}
}
#########################################################################################
#
# Start of the real work
#
use strict;
use Polymake;
use namespaces;
use warnings qw(FATAL void syntax misc);
if ($tell_version) {
print STDERR Main::greeting();
exit;
}
# prepare for graceful termination from outside, e.g. in a docker container
$SIG{TERM}=sub { print STDERR "Terminating...\n"; exit; };
if ($verbose || $DebugLevel) {
print STDERR "polymake version $Version\n";
}
if ($reconfigure) {
require Polymake::Configure;
Configure::prepare_reconfigure();
}
Main::init(@config_path ? join(";", @config_path) : $ENV{POLYMAKE_CONFIG_PATH} || "user");
if ($DebugLevel) {
$Verbose::rules=3;
assign_max($Verbose::scheduler, $DebugLevel);
if ($DebugLevel>1) {
$Verbose::external=1;
}
}
if ($verbose) {
assign_max($Verbose::rules, $verbose);
assign_max($Verbose::scheduler, $verbose);
}
if ($touch) {
if (Main::load_apps()) {
require Polymake::Core::Shell;
Core::Shell::start();
Main::touch_files();
}
} elsif (defined $script) {
Main::run_script($script);
} elsif (defined $iscript) {
require Polymake::Core::Shell;
if (-t STDIN) {
Core::Shell::start();
}
Main::run_script($iscript);
} elsif (defined $connect) {
### named socket or host connection
require Polymake::Sockets;
my ($socket, $redirects);
if (-S $connect) {
$socket=new ClientSocket($connect);
$redirects=1;
} elsif (!-e $connect && $connect =~ /^(.*):(\d+)$/) {
$socket=new ClientSocket($1, $2);
$redirects=3;
} else {
die "option --connect requires a named socket file or a remote host:port\n";
}
require Polymake::Core::Shell;
if (Main::load_apps()) {
Core::Shell::start($socket, $redirects);
Core::Shell::run_pipe();
}
} elsif (@ARGV<=1) {
if (@ARGV==0) {
if (-t STDIN) {
### interactive shell
print "Welcome to ", Main::greeting(), "\nLoading applications now...";
STDOUT->flush();
require Polymake::Core::Shell;
if (Main::load_apps()) {
Core::Shell::start();
Core::Shell::run();
}
} else {
die "can't start the interactive shell without terminal input\n";
}
} else {
my $arg=shift;
if ($arg eq "-") {
### anonymous pipe
require Polymake::Core::Shell;
if (Main::load_apps()) {
Core::Shell::start(\*STDIN, 0);
Core::Shell::run_pipe();
}
} elsif ($arg !~ /[\s'"(){}\[\]\$]/) {
### script file
Main::run_script($arg);
} elsif (Main::load_apps()) {
local_unshift(\@INC, $User::application);
local $Scope=new Scope();
$User::application->eval_expr->("package Polymake::User; $arg");
beautify_error() if $@;
}
}
} elsif (Main::load_apps()) {
require Polymake::Core::Compat;
eval {
Polymake::User::Compat::execute(@ARGV);
}
}
if ($@) {
err_print($@);
exit 1;
}
package Polymake::Main;
sub load_apps {
if ($start_application // $User::default_application) {
eval {
unless ($ignore_start_applications) {
foreach my $app_name (@User::start_applications) {
add Core::Application($app_name);
}
}
User::application($start_application // $User::default_application);
1
}
} else {
$@="Start application not specified\n";
0
}
}
sub run_script {
my ($filename)=@_;
if ($filename =~ s/^($id_re)::(?!$)//o) {
User::application($1);
} else {
$User::application=new Core::NeutralScriptLoader();
}
replace_special_paths($filename);
my ($full_path, $tm, $app)=Core::StoredScript::locate_file($filename)
or die "script file '$filename' not found\n";
local_unshift(\@INC, $app || $User::application);
local $Scope=new Scope();
do "script" . (defined($app) ? ":" : "=") . $full_path;
beautify_error() if $@;
}
sub touch_files {
local $Scope=new Scope();
local $Core::XMLreader::force_verification=1;
foreach (@ARGV) {
eval { User::load($_) };
err_print($@) if $@;
}
}
# to serve as a breakpoint in the perl debugger
sub Polymake::stop_here { print STDERR "@_\n" if @_ }
# Local Variables:
# mode: perl
# cperl-indent-level:3
# indent-tabs-mode:nil
# End:
|