Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • 9.0
  • 8.0
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • nt-tools
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • grubba/wip/sakura/8.0
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
  • v8.0.1982
  • v8.0.1980
  • v8.0.1978
  • v8.0.1976
  • v8.0.1974
  • v8.0.1972
  • v8.0.1970
  • v8.0.1968
  • v8.0.1966
  • v8.0.1964
40 results

make_solaris_pkg.pike

Blame
  • make_solaris_pkg.pike 4.83 KiB
    #! /usr/bin/env pike
    
    /*
    # this script prepares a pike package from a previously created
    # pike installation.
    #
    # usage: make_solaris_pkg.pike --prefix=installprefix \
    #   --pkgdest=pkgdestdir --installroot=installroot
    #
    # assumptions:
    #    1. we have previously prepared an installed pike in a buildroot using
    #         cd $BUILDDIR; make buildroot=/path/to/installroot install
    #    2. the return value of version() is "majornum.minornum release buildnum"
    #    3. we have enough room to do the whole package operation under $BUILDDIR
    #    4. that we call this script using the same version of pike as to be 
    #         packaged.
    #
    # to do:
    #    1. do we want to have dependencies? currently we only depend on Java 
    #         and GMP.
    #    2. do we want to split the package up for non-default modules such
    #         as Oracle, etc?
    */
    
    constant packagename="IDApike";
    
    string installprefix;
    string pkgdest;
    string installroot;
    string arch;
    
    int main(int argc, array argv)
    {
    
      if(!parse_options(argv)) return 1;
      arch=get_pike_arch();
      prepare_tree();
      Stdio.write_file("pkginfo", make_pkginfo());
      Stdio.write_file("depend", make_depend());
      Stdio.write_file("prototype", make_prototype());
      make_package();
      return 0;
    }
    
    
    void usage()
    {
           werror("Usage: make_solaris_pkg.pike [--help] --prefix=pikeprefix"
    	" --installroot=tempimginstallroot --pkgdest=pkgdestinationdir\n");
    }
    
    int parse_options(array args)
    {
        if(Getopt.find_option(args, "", "help") || sizeof(args)==0)
        {
    	usage();
    	return 0;
        }
    
        installprefix=Getopt.find_option(args, "", "prefix");
        installroot=Getopt.find_option(args, "", "installroot");
        pkgdest=Getopt.find_option(args, "", "pkgdest");
    
        if(!(installprefix && installroot && pkgdest))
        {
    	usage();
    	return 0;
        }
        if(!Stdio.is_dir(installroot))
        {
            werror("Error: install image root " + installroot + 
    		" is not a valid path.\n");
    	return 0;
        }
        if(!Stdio.is_dir(pkgdest))
        {
            werror("Error: package destination " + installroot + 
    		" is not a valid path.\n");
    	return 0;
        }
    
        return 1;
    }
    
    string get_pike_prefix()
    {
       return (installprefix);
    }
    
    string get_pike_version()
    {
       return (version()/"v")[1];
    }
    
    string get_pike_arch()
    {
        return (Process.popen("uname -p")-"\n");
    }
    
    void prepare_tree()
    {
      //
      // we want to remove the bin directory from where it is (pkgroot/pike), 
      // and move it under pkgroot
      // also, we want a pike-major.minor in the bin directory.
      //
      string ver=get_pike_version();
      ver=replace(ver, " release ", ".");
      Stdio.recursive_rm(installroot + "/" + installprefix + "/bin");
      Process.system("mkdir " + installroot + "/" + 
    	installprefix + "/pike/bin");
      Process.system("ln -s ../" 
    	+ ver + "/bin/pike " + 
    	installroot + "/" + installprefix + "/pike/bin/pike");
      Process.system("ln -s ../" 
    	+ ver + "/bin/pike " + 
    	installroot + "/" + installprefix + "/pike/bin/pike-" + ((ver/".")[0..1]*"."));
    }
    
    string make_pkginfo()
    {
      string pkginfo="";
    
      pkginfo+="PKG=" + packagename + "\n";
      pkginfo+="NAME=Pike Programming Language\n";
      pkginfo+="BASEDIR=" + get_pike_prefix() + "\n";
      pkginfo+="CATEGORY=application\n";
      pkginfo+="ARCH=" + arch + "\n";
      pkginfo+="VENDOR=The Pike Project\n";
      pkginfo+="EMAIL=pike@pike.ida.liu.se\n";
      pkginfo+="MAXINST=255\n";
      pkginfo+="VERSION=" + get_pike_version() + "\n";
    
      return pkginfo;
    }
    
    string make_depend()
    {
      string depend="";
    /*
    echo "P SFWftype Freetype Font Rendering Library" >> depend
    echo " (sparc)" >> depend
    echo "P SMCzlib zlib compression Library" >> depend
    echo " (sparc)" >> depend
    echo "P SFWpng PNG graphics Library" >> depend
    echo " (sparc)" >> depend
    */
      depend+="P GNUgmp GNU Multi Precision Library\n";
      depend+=" (" + arch + ")\n";
      depend+="P SUNWjvrt Java Run Time Environment\n";
      depend+=" (" + arch + ")\n";
    /*
    echo "P SFWjpg JPEG graphics Library" >> depend
    echo " (sparc)" >> depend
    echo "P SFWtiff TIFF graphics Library" >> depend
    echo " (sparc)" >> depend
    */
    return depend;
    }
    
    string make_prototype()
    {
      string prototype="";
      
      prototype+="i pkginfo\n";
      prototype+="i depend\n";
    
      prototype+=Process.popen("pkgproto " + installroot + "/" + 
    	installprefix + "=");
    
      return prototype;
    }
    
    
    
    int make_package()
    {
      string ver=get_pike_version();
      ver=replace(ver, " release ", ".");
      Stdio.mkdirhier(installroot + "/../pkgbuild");
      Process.popen("pkgmk -o -d " + installroot + "/../pkgbuild");
      Process.popen("pkgtrans -s " + installroot + "/../pkgbuild " +
         pkgdest + "/" + "pike-" + ver +"-"+ arch + ".pkg " + packagename);
    
      if(!Stdio.recursive_rm(installroot + "/../pkgbuild"))
        werror("error deleting pkgbuild temporary directory.\n");
      if(!Stdio.recursive_rm("depend"))
        werror("error deleting depend.\n");
      if(!Stdio.recursive_rm("pkginfo"))
        werror("error deleting pkginfo.\n");
      if(!Stdio.recursive_rm("prototype"))
        werror("error deleting prototype.\n");
      
      return 1;
    }