File: make_solaris_pkg.pike

package info (click to toggle)
pike8.0 8.0.702-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 79,608 kB
  • sloc: ansic: 266,508; xml: 186,324; makefile: 3,537; sh: 1,731; cpp: 1,328; lisp: 655; awk: 441; asm: 242; objc: 240; pascal: 157; perl: 34; sed: 34
file content (195 lines) | stat: -rwxr-xr-x 4,944 bytes parent folder | download | duplicates (10)
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
#! /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;
}