Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
4cca7a0c
Commit
4cca7a0c
authored
24 years ago
by
Fredrik Noring
Browse files
Options
Downloads
Patches
Plain Diff
Moved common functions and classes to the Tools.Install module.
Rev: bin/install.pike:1.65 Rev: src/dumpmodule.pike:1.14
parent
0ab82989
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/install.pike
+8
-167
8 additions, 167 deletions
bin/install.pike
src/dumpmodule.pike
+4
-57
4 additions, 57 deletions
src/dumpmodule.pike
with
12 additions
and
224 deletions
bin/install.pike
+
8
−
167
View file @
4cca7a0c
...
@@ -17,60 +17,7 @@ array(string) to_export=({});
...
@@ -17,60 +17,7 @@ array(string) to_export=({});
int export;
int export;
int no_gui;
int no_gui;
class ProgressBar
Tools.Install.ProgressBar progress_bar;
{
private constant width = 45;
private float phase_base, phase_size;
private int max, cur;
private string name;
void set_current(int _cur)
{
cur = _cur;
}
void set_phase(float _phase_base, float _phase_size)
{
phase_base = _phase_base;
phase_size = _phase_size;
}
void update(int increment)
{
cur += increment;
cur = min(cur, max);
float ratio = phase_base + ((float)cur/(float)max) * phase_size;
if(1.0 < ratio)
ratio = 1.0;
int bar = (int)(ratio * (float)width);
int is_full = (bar == width);
write("\r %-13s |%s%c%s%s %4.1f %% ",
name+":",
"="*bar,
is_full ? '|' : ({ '\\', '|', '/', '-' })[cur & 3],
is_full ? "" : " "*(width-bar-1),
is_full ? "" : "|",
100.0 * ratio);
}
void create(string _name, int _cur, int _max,
float|void _phase_base, float|void _phase_size)
/* NOTE: max must be greater than zero. */
{
name = _name;
max = _max;
cur = _cur;
phase_base = _phase_base || 0.0;
phase_size = _phase_size || 1.0 - phase_base;
}
}
ProgressBar progress_bar;
/* for progress bar */
/* for progress bar */
int files_to_install;
int files_to_install;
...
@@ -479,7 +426,7 @@ void do_export()
...
@@ -479,7 +426,7 @@ void do_export()
#ifdef __NT__
#ifdef __NT__
status("Creating",export_base_name+".burk");
status("Creating",export_base_name+".burk");
Stdio.File p=Stdio.File(export_base_name+".burk","wc");
Stdio.File p=Stdio.File(export_base_name+".burk","wc");
string msg=" Loading
Pike
installation script, please wait...";
string msg=" Loading installation script, please wait...";
p->write("w%4c%s",strlen(msg),msg);
p->write("w%4c%s",strlen(msg),msg);
#define TRANSLATE(X,Y) combine_path(".",X) : Y
#define TRANSLATE(X,Y) combine_path(".",X) : Y
...
@@ -603,7 +550,7 @@ COPYING and DISCLAIMER in the Pike distribution for more details.
...
@@ -603,7 +550,7 @@ COPYING and DISCLAIMER in the Pike distribution for more details.
shift
shift
done
done
"
"
"echo \" Loading
Pike
installation script, please wait...\"\n"
"echo \" Loading installation script, please wait...\"\n"
"tar xf \"$TARFILE\" "+tmpname+".tar.gz\n"
"tar xf \"$TARFILE\" "+tmpname+".tar.gz\n"
"gzip -dc "+tmpname+".tar.gz | tar xf -\n"
"gzip -dc "+tmpname+".tar.gz | tar xf -\n"
"rm -rf "+tmpname+".tar.gz\n"
"rm -rf "+tmpname+".tar.gz\n"
...
@@ -709,113 +656,6 @@ string make_absolute_path(string path)
...
@@ -709,113 +656,6 @@ string make_absolute_path(string path)
return path;
return path;
}
}
class Readline
{
inherit Stdio.Readline;
int match_directories_only;
void trap_signal(int n)
{
destruct(this_object());
exit(1);
}
void destroy()
{
::destroy();
signal(signum("SIGINT"));
}
static private string low_edit(string data, string|void local_prompt,
array(string)|void attrs)
{
string r = ::edit(data, local_prompt, (attrs || ({})) | ({ "bold" }));
if(!r)
{
// ^D?
werror("\nExiting, please wait...\n");
destruct(this_object());
exit(0);
}
return r;
}
string edit(mixed ... args)
{
return low_edit(@args);
}
string edit_filename(mixed ... args)
{
match_directories_only = 0;
get_input_controller()->bind("^I", file_completion);
string s = low_edit(@args);
get_input_controller()->unbind("^I");
return s;
}
string edit_directory(mixed ... args)
{
match_directories_only = 1;
get_input_controller()->bind("^I", file_completion);
string s = low_edit(@args);
get_input_controller()->unbind("^I");
return s;
}
static private string file_completion(string tab)
{
string text = gettext();
int pos = getcursorpos();
array(string) path = make_absolute_path(text[..pos-1])/"/";
array(string) files =
glob(path[-1]+"*",
get_dir(sizeof(path)>1? path[..sizeof(path)-2]*"/"+"/":".")||({}));
if(match_directories_only)
files = Array.filter(files, lambda(string f, string p)
{ return (file_stat(p+f)||({0,0}))[1]==-2; },
path[..sizeof(path)-2]*"/"+"/");
switch(sizeof(files))
{
case 0:
get_output_controller()->beep();
break;
case 1:
insert(files[0][sizeof(path[-1])..], pos);
if((file_stat((path[..sizeof(path)-2]+files)*"/")||({0,0}))[1]==-2)
insert("/", getcursorpos());
break;
default:
string pre = String.common_prefix(files)[sizeof(path[-1])..];
if(sizeof(pre))
{
insert(pre, pos);
} else {
if(!sizeof(path[-1]))
files = Array.filter(files, lambda(string f)
{ return !(sizeof(f) && f[0] == '.'); });
list_completions(sort(files));
}
break;
}
}
void create(mixed ... args)
{
signal(signum("SIGINT"), trap_signal);
::create(@args);
}
}
#ifdef USE_GTK
#ifdef USE_GTK
object window1;
object window1;
object vbox1;
object vbox1;
...
@@ -1029,7 +869,7 @@ int pre_install(array(string) argv)
...
@@ -1029,7 +869,7 @@ int pre_install(array(string) argv)
status1("");
status1("");
interactive=Readline();
interactive=
Tools.Install.
Readline();
write(" Welcome to the interactive "+version()+
write(" Welcome to the interactive "+version()+
" installation script.\n"
" installation script.\n"
...
@@ -1177,13 +1017,14 @@ void do_install()
...
@@ -1177,13 +1017,14 @@ void do_install()
pike=combine_path(exec_prefix,"pike");
pike=combine_path(exec_prefix,"pike");
if(!export)
if(!export)
{
{
status1("
Please wait, i
nstalling Pike in %s...\n", fakeroot(prefix));
status1("
I
nstalling Pike in %s
, please wait
...\n", fakeroot(prefix));
}
}
catch {
catch {
files_to_install = (int)Stdio.read_file("num_files_to_install");
files_to_install = (int)Stdio.read_file("num_files_to_install");
if(!export && files_to_install)
if(!export && files_to_install)
progress_bar = ProgressBar("Installing", 0, files_to_install, 0.0, 0.2);
progress_bar =
Tools.Install.ProgressBar("Installing", 0, files_to_install, 0.0, 0.2);
};
};
mixed err=catch {
mixed err=catch {
...
@@ -1380,7 +1221,7 @@ void do_install()
...
@@ -1380,7 +1221,7 @@ void do_install()
}
}
progress_bar = 0;
progress_bar = 0;
status1("
I
nstallation completed successfully.");
status1("
Pike i
nstallation completed successfully.");
}
}
int main(int argc, array(string) argv)
int main(int argc, array(string) argv)
...
...
This diff is collapsed.
Click to expand it.
src/dumpmodule.pike
+
4
−
57
View file @
4cca7a0c
...
@@ -12,60 +12,7 @@ string fakeroot(string s)
...
@@ -12,60 +12,7 @@ string fakeroot(string s)
#define fakeroot(X) X
#define fakeroot(X) X
#endif
#endif
class ProgressBar
Tools.Install.ProgressBar progress_bar;
{
private constant width = 45;
private float phase_base, phase_size;
private int max, cur;
private string name;
void set_current(int _cur)
{
cur = _cur;
}
void set_phase(float _phase_base, float _phase_size)
{
phase_base = _phase_base;
phase_size = _phase_size;
}
void update(int increment)
{
cur += increment;
cur = min(cur, max);
float ratio = phase_base + ((float)cur/(float)max) * phase_size;
if(1.0 < ratio)
ratio = 1.0;
int bar = (int)(ratio * (float)width);
int is_full = (bar == width);
write("\r %-13s |%s%c%s%s %4.1f %% ",
name+":",
"="*bar,
is_full ? '|' : ({ '\\', '|', '/', '-' })[cur & 3],
is_full ? "" : " "*(width-bar-1),
is_full ? "" : "|",
100.0 * ratio);
}
void create(string _name, int _cur, int _max,
float|void _phase_base, float|void _phase_size)
/* NOTE: max must be greater than zero. */
{
name = _name;
max = _max;
cur = _cur;
phase_base = _phase_base || 0.0;
phase_size = _phase_size || 1.0 - phase_base;
}
}
ProgressBar progress_bar;
#define error(X) throw( ({ (X), backtrace() }) )
#define error(X) throw( ({ (X), backtrace() }) )
...
@@ -323,9 +270,9 @@ int main(int argc, string *argv)
...
@@ -323,9 +270,9 @@ int main(int argc, string *argv)
quiet = 2;
quiet = 2;
logfile = Stdio.File("dumpmodule.log","caw");
logfile = Stdio.File("dumpmodule.log","caw");
progress_bar = ProgressBar("Precompiling",
progress_bar =
Tools.Install.
ProgressBar("Precompiling",
@array_sscanf(argv[1], "%d,%d"),
@array_sscanf(argv[1], "%d,%d"),
0.2, 0.8);
0.2, 0.8);
argv = argv[2..];
argv = argv[2..];
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment