Skip to content
Snippets Groups Projects
Select Git revision
  • 2d0830f893bffcb981b54f2819b8a4829b682b2d
  • master default protected
  • hpke
  • ppc-chacha-4core
  • delete-internal-name-mangling
  • master-updates
  • ppc-gcm
  • ppc-chacha-2core
  • refactor-ecc-mod
  • ppc-chacha-core
  • use-mpn_cnd-functions
  • optimize-ecc-invert
  • default-m4-quote-char
  • power-asm-wip
  • test-fat
  • chacha-3core-neon
  • x86_64-salsa20-2core
  • salsa20-2core-neon
  • bcrypt
  • arm-salsa20-chacha-vsra
  • test-shlib-dir
  • nettle_3.6_release_20200429
  • nettle_3.6rc3
  • nettle_3.6rc2
  • nettle_3.6rc1
  • nettle_3.5.1_release_20190627
  • nettle_3.5_release_20190626
  • nettle_3.5rc1
  • nettle_3.4.1_release_20181204
  • nettle_3.4.1rc1
  • nettle_3.4_release_20171119
  • nettle_3.4rc2
  • nettle_3.4rc1
  • nettle_3.3_release_20161001
  • nettle_3.2_release_20160128
  • nettle_3.1.1_release_20150424
  • nettle_3.1_release_20150407
  • nettle_3.1rc3
  • nettle_3.1rc2
  • nettle_3.1rc1
  • nettle_3.0_release_20140607
41 results

des-compat.c

Blame
  • Forked from Nettle / nettle
    Source project has a limited visibility.
    export.pike 6.89 KiB
    #! /usr/bin/env pike
    
    /* $Id: export.pike,v 1.51 2002/04/28 13:28:54 mikael%brandstrom.org Exp $ */
    
    multiset except_modules = (<>);
    string vpath;
    
    string dirname(string dir)
    {
      array tmp=dir/"/";
      if(tmp[-1]=="") tmp=tmp[..sizeof(tmp)-2];
      tmp=tmp[..sizeof(tmp)-2];
      if(sizeof(tmp)<2) return "/";
      return tmp*"/";
    }
    
    array(string) get_files(string path)
    {
      array(string) files = get_dir(path);
    
      if(!getenv("PIKE_EXPORT_CVS_DIRS"))
        files -= ({ "CVS", "RCS", ".cvsignore" });
    
      array(string) ret = ({});
      foreach(files, string fn)
      {
        if( fn=="core" ) continue;
        if( fn[-1]=='~' ) continue;
        if( fn[0]=='#' && fn[-1]=='#' ) continue;
        if( fn[0]=='.' && fn[1]=='#' ) continue;
    
        if( path==vpath+"/src/modules" && except_modules[fn] )
          continue;
    
        if( path==vpath+"/bin" && except_modules[fn] )
          continue;
    
        if( has_prefix(path, vpath+"/lib/modules") &&
    	(except_modules[fn] || except_modules[fn - ".pmod"]))
          continue;
    
        fn = path+"/"+fn;
    
        if( Stdio.file_size(fn)==-2 )
          ret += get_files(fn);
        else
          ret += ({ fn });
      }
      return ret;
    }
    
    void fix_configure(string dir)
    {
      Stdio.Stat config=file_stat(dir+"/configure");
      Stdio.Stat config_in=file_stat(dir+"/configure.in");
    
      if(config_in)
      {
        if(!config || config_in->mtime > config->mtime)
        {
          werror("Fixing configure in "+dir+".\n");
          Process.create_process( ({"autoconf"}),
    			      (["cwd":dir]) )->wait();
        }
      }
    }
    
    array(int) getversion()
    {
      string s = Stdio.read_file(pike_base_name+"/src/version.h");
    
      if(!s)
      {
        werror("Failed to read version.h\n");
        werror("cwd=%s  version.h=%s\n", getcwd(), pike_base_name+"/src/version.h");
        exit(1);
      }
    
      int maj, min, build;
    
      if ((!sscanf(s, "%*sPIKE_MAJOR_VERSION %d", maj)) ||
          (!sscanf(s, "%*sPIKE_MINOR_VERSION %d", min)) ||
          (!sscanf(s, "%*sPIKE_BUILD_VERSION %d", build))) {
    
        werror("Failed to get Pike version.\n");
        exit(1);
      }
    
      return ({ maj, min, build });
    }
    
    void bump_version()
    {
      werror("Bumping release number.\n");
      Process.create_process( ({ "cvs", "update", "version.h" }),
    			  ([ "cwd":pike_base_name+"/src" ]) )->wait();
    
      string s = Stdio.read_file(pike_base_name+"/src/version.h");
      sscanf(s, "%s PIKE_BUILD_VERSION %d%s", string pre, int rel, string post);
      rel++;
      Stdio.write_file( pike_base_name+"/src/version.h",
    		    pre+" PIKE_BUILD_VERSION "+rel+post );
      Process.create_process( ({ "cvs", "commit", "-m",
    			     "release number bumped to "+rel+" by export.pike",
    			     "version.h" }),
    			  ([ "cwd":pike_base_name+"/src" ]) )->wait();
    }
    
    array(string) build_file_list(string vpath, string list_file)
    {
      array(string) ret=({ });
      foreach(Stdio.FILE(list_file)->line_iterator(1);; string line)
        {
          if( !sizeof(line) || line[0]=='#' )
    	continue;
          werror("%O\n",line);
          string name=vpath+line;
          Stdio.Stat fs;
          if((fs = file_stat(name)) && fs->isdir)
    	ret += get_files(name);
          else
    	ret += ({ name });
        }
      return ret;
    }  
    
    constant stamp=#"Pike export stamp
    major:%maj
    minor:%min
    build:%bld
    year:%Y
    month:%M
    day:%D
    hour:%h
    minute:%m
    second:%s
    ";
    
    string pike_base_name;
    string srcdir;
    int rebuild;
    
    int main(int argc, array(string) argv)
    {
      array(string) files;
      string export_list, filename;
      object cvs;
      int tag, snapshot;
    
      foreach(Getopt.find_all_options(argv, ({
        ({ "srcdir",    Getopt.HAS_ARG, "--srcdir"     }),
        ({ "rebuild",   Getopt.NO_ARG,  "--rebuild"    }),
        ({ "tag",       Getopt.NO_ARG,  "--tag"        }),
        ({ "help",      Getopt.NO_ARG,  "--help"       }),
        ({ "exportlist",Getopt.HAS_ARG, "--exportlist" }),
        ({ "filename",  Getopt.HAS_ARG, "--name"       })
      }) ),array opt)
        {
          switch(opt[0])
          {
    	case "srcdir":
    	  srcdir=opt[1];
    	  if(basename(srcdir)=="src")
    	    srcdir=dirname(srcdir);
    	  pike_base_name=".";
    	  
    	  cd(srcdir);
    	  break;
    	  
            case "exportlist":
    	  export_list=opt[1];
    	  break;
    	  
            case "filename":
    	  filename=opt[1];
    	  break;
    
    	case "rebuild":
    	  rebuild=1;
    	  break;
    
            case "tag":
    	  tag=1;
    	  break;
    	  
            case "help":
    	  write(documentation);
    	  return 0;
          }
        }
          
    
      argv -= ({ 0 });
      except_modules = (multiset)argv[1..];
      if(!srcdir || !export_list || !filename) {
        werror(documentation);
        return 1;
      }
    
      export_list=srcdir+"/"+export_list;
    
      if(rebuild)
      {
        werror("Not yet finished!\n");
        exit(1);
        object autoconfig=Process.create_process(({"./run_autoconfig"}),
    					     (["cwd":pike_base_name]));
        /* make depend... */
        /* And other things... */
      }
    
      if(tag && file_stat(pike_base_name+"/CVS"))
      {
        bump_version();
    
        array(int) version = getversion();
        vpath = sprintf("Pike-v%d.%d.%d", @version);
        string tag = sprintf("v%d_%d_%d", @version);
    
        werror("Creating tag "+tag+" in the background.\n");
        cvs = Process.create_process( ({"cvs", "tag", "-R", "-F", tag}) );
      }
    
      mapping m = gmtime(time());
      array(int) version = getversion();
      mapping symbols=([
        "%maj":(string) version[0],
        "%min":(string) version[1],
        "%bld":(string) version[2],
        "%Y":sprintf("%04d",1900+m->year),
        "%M":sprintf("%02d",1+m->mon),
        "%D":sprintf("%02d",m->mday),
        "%h":sprintf("%02d",m->hour),
        "%m":sprintf("%02d",m->min),
        "%s":sprintf("%02d",m->sec)
      ]);
        
      vpath=replace(filename,symbols);
    
      fix_configure(pike_base_name+"/src");
    
      foreach(get_dir(pike_base_name+"/src/modules") - ({"CVS","RCS"}), string fn)
        if(Stdio.file_size(pike_base_name+"/src/modules/"+fn) == -2)
          fix_configure("modules/"+fn);
    
      symlink(".", vpath);
    
      files = build_file_list(vpath,export_list);
      Stdio.write_file("export.stamp", replace(stamp, symbols));
      files += ({ vpath+"/export.stamp" });
    
      werror("Creating "+vpath+".tar.gz:\n");
    
      int first = 1;
      foreach(files/25.0, files)
        {
          if(Process.create_process
    	 ( ({"tar",
    	     first?"cvf":"rvf",
    	     pike_base_name+"/"+vpath+".tar" }) +
    	   files)->wait())
          {
    	werror("Tar file creation failed!\n");
    	if(cvs) cvs->wait();
    	rm(vpath);
    	exit(1);
          }
          first = 0;
        }
    
      if(Process.create_process
         ( ({"gzip",
    	 "-9",
    	 pike_base_name+"/"+vpath+".tar"
         }) )->wait())
        {
          werror("Gzip failed!\n");
          if(cvs) cvs->wait();
          rm(vpath);
          exit(1);
        }
    
      rm(vpath);
      rm("export.stamp");
      werror("Done.\n");
    
      if(cvs && tag)
      {
        cvs->wait();
        bump_version();
      }
    
      return 0;
    }
    
    constant documentation = #"
    Usage: export.pike <arguments> <except modules>
    
    Creates a pike distribution. Needs one tar and one gzip binary in the path.
    Mandatory arguments:
    
     name       Name of export archive (%maj, %min, %bld, %Y, %M, %D, %h, %m, %s
                are replaced with apropiate values).
     exportlist A file which lists all the files and directories to be exported.
     srcdir     The path to the source directory.
    
    Optional arguments:
    
     rebuild    Not implemented.
     tag        Bump the Pike build version and tag the CVS tree.
     help       Show this text.
    ";