diff --git a/bin/install.pike b/bin/install.pike index d78a27041261dad050064eafc956111c7970e44e..0abd5d1273a3c2fc00f98702ca927851dd98cca7 100644 --- a/bin/install.pike +++ b/bin/install.pike @@ -141,7 +141,10 @@ int mkdirhier(string dir) if(export) return 1; if(dir=="" || (strlen(dir)==2 && dir[-1]==':')) return 1; + dir=fakeroot(dir); + status("creating",dir+"/"); + mixed s=file_stat(dir); if(s) { @@ -193,6 +196,8 @@ int low_install_file(string from, to_export+=({ from }); return 1; } + + to=fakeroot(to); status("installing",to); @@ -320,14 +325,43 @@ void install_header_files(string from, string to) mapping vars=([]); +object reg; +string regexp; + +string regquote(string s) +{ + while(s[-1] == '/' || s[-1]=='\\') s=s[..strlen(s)-2]; + return + replace(s, + ({".","[","]","*","\\","(",")","|","+"}), + ({"\\.","\\[","\\]","\\*","\\\\","\\(","\\)","\\|","\\+"}) ); +} + +string globify(string s) +{ + if(s[-1]=='/') s=s[..strlen(s)-2]; + return s+"*"; +} + string fakeroot(string s) { - if(vars->fakeroot) + if(!vars->fakeroot) return s; + if(!reg) { - return vars->fakeroot+combine_path(getcwd(),s); - }else{ - return s; + reg=Regexp(regexp=sprintf("^([^/])%{|(%s)%}", + Array.map( + ({ + getcwd(), + vars->LIBDIR_SRC, + vars->SRCDIR, + vars->TMP_BINDIR, + vars->MANDIR_SRC, + vars->TMP_LIBDIR, + vars->fakeroot, + }),regquote))); } + if(reg->match(s)) return s; + return vars->fakeroot+s; } string export_base_name; @@ -1066,7 +1100,7 @@ void do_install() pike=combine_path(exec_prefix,"pike"); if(!export) { - status1("Installing Pike in %s...\n",prefix); + status1("Installing Pike in %s...\n",fakeroot(prefix)); } mixed err=catch { @@ -1119,22 +1153,22 @@ void do_install() lib_prefix); } - install_dir(fakeroot(vars->TMP_LIBDIR),lib_prefix,1); - install_dir(fakeroot(vars->LIBDIR_SRC),lib_prefix,1); + install_dir(vars->TMP_LIBDIR,lib_prefix,1); + install_dir(vars->LIBDIR_SRC,lib_prefix,1); - install_header_files(fakeroot(vars->SRCDIR),include_prefix); - install_header_files(fakeroot(vars->TMP_BUILDDIR),include_prefix); + install_header_files(vars->SRCDIR,include_prefix); + install_header_files(vars->TMP_BUILDDIR,include_prefix); - install_file(fakeroot(combine_path(vars->TMP_BUILDDIR,"modules/dynamic_module_makefile")), + install_file(combine_path(vars->TMP_BUILDDIR,"modules/dynamic_module_makefile"), combine_path(include_prefix,"dynamic_module_makefile")); - install_file(fakeroot(combine_path(vars->TMP_BUILDDIR,"aclocal")), + install_file(combine_path(vars->TMP_BUILDDIR,"aclocal"), combine_path(include_prefix,"aclocal.m4")); if(file_stat(vars->MANDIR_SRC)) { // trace(9); // _debug(5); - install_dir(fakeroot(vars->MANDIR_SRC),combine_path(man_prefix,"man1"),0); + install_dir(vars->MANDIR_SRC,combine_path(man_prefix,"man1"),0); } }; @@ -1158,9 +1192,11 @@ void do_install() "PIKE_INCLUDE_PATH":"", "PIKE_MASTER":"", ]) ]); + + if(!s1 || !s2 || s1[3]>=s2[3] || redump_all) { - Process.create_process( ({pike,"-m", + Process.create_process( ({fakeroot(pike),"-m", combine_path(vars->SRCDIR,"dumpmaster.pike"), @(vars->fakeroot?({"--fakeroot="+ vars->fakeroot}):({})), @@ -1174,20 +1210,38 @@ void do_install() foreach(to_dump, string mod) rm(mod+".o"); /* Dump 50 modules at a time */ write("\n"); + + array cmd=({fakeroot(pike) }); + + if(vars->fakeroot) + cmd+=({ + sprintf("-DPIKE_FAKEROOT=%O",vars->fakeroot), + sprintf("-DPIKE_FAKEROOT_OMIT=%O", + Array.map( ({ + getcwd(), + vars->LIBDIR_SRC, + vars->SRCDIR, + vars->TMP_BINDIR, + vars->MANDIR_SRC, + vars->TMP_LIBDIR, + vars->fakeroot, + }), globify)*":"), + "-m",combine_path(vars->TMP_LIBDIR,"master.pike") + }); + + cmd+=({ combine_path(vars->SRCDIR,"dumpmodule.pike"), + +#if defined(USE_GTK) && constant(GTK.parse_rc) + label1?"--distquiet": +#endif + "--quiet"}); + +// werror("%O\n",cmd); + foreach(to_dump/50.0,to_dump) { write(" "); - Process.create_process( ({pike, - combine_path(vars->SRCDIR, - "dumpmodule.pike"), -#if defined(USE_GTK) && constant(GTK.parse_rc) - label1?"--distquiet": -#endif - "--quiet", - @(vars->fakeroot? - ({"--fakeroot="+vars->fakeroot}):({})), - }) + to_dump, - options)->wait(); + Process.create_process(cmd+ to_dump, options)->wait(); } } @@ -1200,20 +1254,20 @@ void do_install() if(lnk) { status("creating",lnk); - mixed s=file_stat(lnk,1); + mixed s=file_stat(fakeroot(lnk),1); if(s) { - if(!mv(lnk,lnk+".old")) + if(!mv(fakeroot(lnk),fakeroot(lnk+".old"))) { werror("Failed to move %s\n",lnk); exit(1); } } if (old_exec_prefix) { - mkdirhier(old_exec_prefix); + mkdirhier(fakeroot(old_exec_prefix)); } - mkdirhier(dirname(lnk)); - symlink(pike,lnk); + mkdirhier(fakeroot(dirname(lnk))); + symlink(pike,fakeroot(lnk)); status("creating",lnk,"done"); } #endif @@ -1258,5 +1312,20 @@ int main(int argc, array(string) argv) if(sscanf(foo,"%s=%s",string var, string value)==2) vars[var]=value; + /* Some magic for the fakeroot stuff */ + string tmp=vars->fakeroot; + m_delete(vars,"fakeroot"); + if(tmp!="") + { + if(tmp[-1]=='/' || tmp[-1]=='\\') + tmp=tmp[..sizeof(tmp)-2]; + + /* Create the fakeroot if it doesn't exist + /* This must be done with fakeroot unset since + * it would create fakeroot/fakeroot otherwise + */ + mkdirhier(tmp); + vars->fakeroot=tmp; + } return pre_install(argv); } diff --git a/lib/master.pike.in b/lib/master.pike.in index 474d3082514c6f722d6b37144337080ec2a854f4..f2886e545f74b16ff24b41db7e95ba6024db8b1b 100644 --- a/lib/master.pike.in +++ b/lib/master.pike.in @@ -1,6 +1,6 @@ /* -*- Pike -*- * - * $Id: master.pike.in,v 1.122 2000/06/09 21:46:37 mast Exp $ + * $Id: master.pike.in,v 1.123 2000/07/12 01:19:18 hubbe Exp $ * * Master-file for Pike. * @@ -28,6 +28,24 @@ constant out_of_date_warning = OUT_OF_DATE_WARNING; * Functions begin here. */ +#ifdef PIKE_FAKEROOT +object o; +string fakeroot(string s) +{ + string tmp1=combine_path_with_cwd(s); +#ifdef PIKE_FAKEROOT_OMIT + foreach(PIKE_FAKEROOT_OMIT/":", string x) + if(glob(x,tmp1)) + return s; +#endif + return PIKE_FAKEROOT+tmp1; +} +#else +#define fakeroot(X) X +#endif + + + int is_absolute_path(string p) { #ifdef __NT__ @@ -117,10 +135,11 @@ program compile_string(string data, void|string name, object|void handler) return compile(cpp(data,name||"-", 0, handler), handler); } + string master_read_file(string file) { object o=_static_modules.files()->Fd(); - if(o->open(file,"r")) + if(o->open(fakeroot(file),"r")) return o->read(); return 0; } @@ -313,7 +332,7 @@ static program low_findprog(string pname, string ext, object|void handler) } #endif - if( (s=master_file_stat(fname)) && s[1]>=0 ) + if( (s=master_file_stat(fakeroot(fname))) && s[1]>=0 ) { AUTORELOAD_BEGIN(); @@ -327,7 +346,7 @@ static program low_findprog(string pname, string ext, object|void handler) case "": case ".pike": foreach(query_precompiled_names(fname), string oname) { - if(array s2=master_file_stat(oname)) + if(array s2=master_file_stat(fakeroot(oname))) { if(s2[1]>=0 && s2[3]>=s[3]) { @@ -374,7 +393,8 @@ static program low_findprog(string pname, string ext, object|void handler) werror(sprintf("low_find_prog(\"%s\", \"%s\") => load_module(\"\")\n" "%s\n", pname, ext, describe_backtrace(backtrace()))); } - ret=load_module(fname); + + ret=load_module(fakeroot(fname)); #endif /* load_module */ } @@ -624,7 +644,7 @@ class dirnode } if( !files ) - files = get_dir(dirname); + files = get_dir(fakeroot(dirname)); int ret; foreach( files, string s ) @@ -677,7 +697,7 @@ class dirnode } if( !files ) - files = get_dir(dirname); + files = get_dir(fakeroot(dirname)); foreach(files, string fname) { mixed err = catch { if (((< ".pike", ".pmod" >)[fname[sizeof(fname)-5..]]) && @@ -824,7 +844,7 @@ object findmodule(string fullname) return o; } - if(array stat=master_file_stat(fullname+".pmod")) + if(array stat=master_file_stat(fakeroot(fullname+".pmod"))) { if(stat[1]==-2) return fc[fullname]=dirnode(fullname+".pmod"); @@ -834,7 +854,7 @@ object findmodule(string fullname) return fc[fullname]=o; #if constant(load_module) - if(master_file_stat(fullname+".so")) + if(master_file_stat(fakeroot(fullname+".so"))) return fc[fullname]=low_cast_to_object(fullname,"/."); #endif @@ -1327,7 +1347,7 @@ string handle_include(string f, foreach(pike_include_path, path) { path=combine_path(path,f); - if(master_file_stat(path)) + if(master_file_stat(fakeroot(path))) break; else path=0; diff --git a/src/Makefile.in b/src/Makefile.in index c6beadbcd07f1034522cb1c500d7141d4c7b6f9c..61457c8e34291e50d88b355b532eab724fbae6cb 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,5 +1,5 @@ # -# $Id: Makefile.in,v 1.194 2000/06/23 06:17:58 hubbe Exp $ +# $Id: Makefile.in,v 1.195 2000/07/12 01:19:28 hubbe Exp $ # # This line is needed on some machines. @@ -23,6 +23,14 @@ TMP_BUILDDIR = @BUILDDIR@ TMP_DOCDIR = @DOCDIR@ TMP_LIBDIR = $(TMP_BUILDDIR)/lib +# +# RPM and package builders, listen up, because this is your only +# documentation! This variable is prepended to the install path. +# Please note that Pike will not work until moved into the proper +# place. -Hubbe +# +buildroot= + prefix = @prefix@ exec_prefix = $(prefix)/bin lib_prefix = $(prefix)/lib/pike @@ -292,13 +300,15 @@ install: pike hilfe pike-module aclocal exec_prefix="$(exec_prefix)" lib_prefix="$(lib_prefix)" \ TMP_LIBDIR="$(TMP_LIBDIR)" LIBDIR_SRC="$(LIBDIR_SRC)" \ SRCDIR="$(SRCDIR)" prefix="$(prefix)" MANDIR_SRC="$(MANDIR_SRC)" \ - man_prefix="$(man_prefix)" pike_name=$(pike_name) + man_prefix="$(man_prefix)" pike_name=$(pike_name) \ + fakeroot="$(buildroot)" install_interactive: pike hilfe pike-module aclocal @$(RUNPIKE) $(TMP_BINDIR)/install.pike --interactive \ exec_prefix="$(exec_prefix)" prefix=$(prefix) \ TMP_LIBDIR="$(TMP_LIBDIR)" LIBDIR_SRC="$(LIBDIR_SRC)" \ - SRCDIR="$(SRCDIR)" MANDIR_SRC="$(MANDIR_SRC)" + SRCDIR="$(SRCDIR)" MANDIR_SRC="$(MANDIR_SRC)" \ + fakeroot="$(buildroot)" # tidy up a bit tidy: diff --git a/src/dumpmaster.pike b/src/dumpmaster.pike index cd07b193e707ccfe6e523128120a5a1e253cf810..8bd94a7e23ca2306c18297891463abbceada126b 100644 --- a/src/dumpmaster.pike +++ b/src/dumpmaster.pike @@ -1,18 +1,26 @@ #define UNDEFINED (([])[0]) -string fakeroot; +string fr; void handle_error(mixed err) { werror("%O\n",err); } -string read_file(string s) +void compile_error(string file,int line,string err) { - if(fakeroot) - s=fakeroot+combine_path(getcwd(),s); + werror(sprintf("%s:%s:%s\n",file, line?(string)line:"-",err)); +} - return _static_modules.files()->Fd(s,"r")->read(); +string fakeroot(string s) +{ + if(fr) s=fr+combine_path(getcwd(),s); + return s; +} + +string read_file(string s) +{ + return _static_modules.files()->Fd(fakeroot(s),"r")->read(); } program compile_file(string file) @@ -31,11 +39,11 @@ class Codec void _main(string *argv, string *env) { foreach(argv[1..sizeof(argv)-2], string f) - sscanf(f,"--fakeroot=%s",fakeroot); + sscanf(f,"--fakeroot=%s",fr); program p=compile_file(argv[-1]); string s=encode_value(p, Codec()); - _static_modules.files()->Fd(argv[-1] + ".o","wct")->write(s); + _static_modules.files()->Fd(fakeroot(argv[-1]) + ".o","wct")->write(s); exit(0); } diff --git a/src/dumpmodule.pike b/src/dumpmodule.pike index 90f0019d4b4cd0e8c638483e80d42a514275af1b..88539fdd1d47ee1c14e97f4d3596c8a232c010a8 100755 --- a/src/dumpmodule.pike +++ b/src/dumpmodule.pike @@ -2,16 +2,17 @@ program p; -string fakeroot; - -class FakeMaster +#ifdef PIKE_FAKEROOT +string fakeroot(string s) { - inherit "/master"; - string master_read_file(string s) - { - return ::master_read_file(fakeroot+combine_path_with_cwd(s)); - } + return PIKE_FAKEROOT+combine_path(getcwd(),s); } +#else +#define fakeroot(X) X +#endif + + + #define error(X) throw( ({ (X), backtrace() }) ) @@ -159,8 +160,6 @@ class Handler } } - - void dumpit(string file) { if(logfile) @@ -171,7 +170,7 @@ void dumpit(string file) mixed err=catch { rm(file+".o"); // Make sure no old files are left - if(mixed s=file_stat(file)) + if(mixed s=file_stat(fakeroot(file))) { if(s[1]<=0) { @@ -189,7 +188,7 @@ void dumpit(string file) p=decode_value(s,master()->Codec()); if(programp(p)) { - Stdio.File(file + ".o","wct")->write(s); + Stdio.File(fakeroot(file) + ".o","wct")->write(s); switch(quiet) { case 1: werror("."); break; @@ -262,12 +261,6 @@ int main(int argc, string *argv) logfile=0; } - if(sscanf(argv[1],"--fakeroot=%s",fakeroot)) - { - argv=argv[1..]; - replace_master(FakeMaster()); - } - foreach(argv[1..],string file) dumpit(file);