File: gap2deb

package info (click to toggle)
gap 4r7p5-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 29,272 kB
  • ctags: 7,129
  • sloc: ansic: 107,802; xml: 46,868; sh: 3,548; perl: 2,329; makefile: 740; python: 94; asm: 62; awk: 6
file content (273 lines) | stat: -rwxr-xr-x 8,936 bytes parent folder | download
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#! /usr/bin/gap -q
# Copyright 2014 Bill Allombert <ballombe@debian.org>
# This program is distributed under the term of the GNU GPL2+
# The author assert no copyright interest in the output.

# require htmltotext

debhelperver := "5";

Commas:=function(list)
  return JoinStringsWithSeparator(list,", ");
end;

BaseDir:= function (path)
  local tmp, file, dir, name, ext;
  tmp :=  SplitString(path,"/");
  file:= tmp[Length(tmp)];
  Remove(tmp);
  dir := JoinStringsWithSeparator(tmp,"/");
  tmp := SplitString(file,".");
  ext := tmp[Length(tmp)];
  name := JoinStringsWithSeparator(tmp,".");
  return [dir, name, ext];
end;

Backquote:= function (prg)
  local shell, out, str;
  str := ""; 
  out := OutputTextString(str,true);
  Process( DirectoryCurrent(), "/bin/sh", InputTextNone(), out, ["-c", prg] );
  CloseStream(out);
  return Chomp(str);
end;

HTMLToText:=function(html)
  local shell, inp, out, str;
  str := ""; 
  inp := InputTextString(html);
  out := OutputTextString(str,true);
  Process(DirectoryCurrent(), "/usr/bin/html2text", inp, out,["-width","77"]);
  CloseStream(inp);
  CloseStream(out);
  return str;
end;

Email:=function(r)
  if IsBound(r.Email) then
    return Concatenation(" <",r.Email,">");
  else
    return "";
  fi;
end;

PkgName:=function(x)
  return Concatenation("gap-pkg-",LowercaseString(x));
end;

if IsReadableFile("PackageInfo.g")=false then
  stderr:=OutputTextFile("*errout*",true);
  WriteAll(stderr, Concatenation(
"GAP pkg to source Debian package converter\n",
"file PackageInfo.g not found\n",
"gap2deb must be launched inside a GAP package source directory\n"
 ));
  CloseStream(stderr);
  quit;
fi;
Unbind( GAPInfo.PackageInfoCurrent );
Read("PackageInfo.g");
pkg:= GAPInfo.PackageInfoCurrent;
Unbind( GAPInfo.PackageInfoCurrent );

env:=GAPInfo.KernelInfo.ENVIRONMENT;
if IsBound(env.DEBFULLNAME) then
  maint := env.DEBFULLNAME;
else
  debemail:= env.DEBEMAIL;
  maintname:=SplitString(Backquote("getent passwd $USER"),":,")[5];
  maint:=Concatenation(maintname," <",debemail,">");
fi;

pkgname := LowercaseString(pkg.PackageName);
srcname := Concatenation("gap-",pkgname);
binname := Concatenation("gap-",pkgname);
synopsis := Concatenation("GAP ",pkg.PackageName," - ",pkg.Subtitle);
baseURL := "ftp://ftp.gap-system.org/pub/gap/gap4/tar.bz2/packages";
homepage := Concatenation("http://www.gap-system.org/Packages/",pkgname,".html");
date := Backquote("date -R");
year := Backquote("date +%Y");
copyyear := SplitString(pkg.Date,"/")[3];
abstract :=JoinStringsWithSeparator(SplitString(HTMLToText(pkg.AbstractHTML),"\n"),"\n ");
comp :=  SplitString(pkg.ArchiveURL,"/");
archivebase := SplitString(comp[Length(comp)],"0123456789")[1];
authors := Commas(List(pkg.Persons,x->Concatenation(x.FirstNames," ",x.LastName)));
authoremails := 
  Commas(List(pkg.Persons,x->Concatenation(x.FirstNames," ",x.LastName,Email(x))));
pkgbaseN:=Concatenation("usr/share/gap/pkg/",pkg.PackageName);
pkgbase:=Concatenation("/",pkgbaseN);

gapdepver :=  ReplacedString(pkg.Dependencies.GAP,".","r");
gapdep := Concatenation("gap (",gapdepver,")");
neededslist:=List(pkg.Dependencies.NeededOtherPackages,x->PkgName(x[1]));
suggestionslist := List(pkg.Dependencies.SuggestedOtherPackages,x->PkgName(x[1]));
conditionslist := List(pkg.Dependencies.ExternalConditions,x->x[1]);
PackageDoc := BaseDir(pkg.PackageDoc.HTMLStart);
PackageDocHTML := Concatenation(PackageDoc[1],"/*.",PackageDoc[3]);
Depends:=Concatenation("Depends: ", 
  Commas(Concatenation(["${misc:Depends}", gapdep],neededslist,conditionslist)),"\n");
if IsEmpty(suggestionslist) then
  Suggests:="";
else
  Suggests:=Concatenation("Suggests: ",Commas(suggestionslist),"\n");
fi;

if IsDirectoryPath("debian")=false then
  CreateDir("debian");
  CreateDir("debian/source");
  CreateDir("debian/patches");
fi;
FileString("debian/source/format","3.0 (quilt)\n");

FileString("debian/compat",Concatenation(debhelperver,"\n"));

FileString("debian/changelog",Concatenation(
srcname," (",pkg.Version,"-1) unstable; urgency=low\n",
"\n",
"  * Initial Release.\n",
"  * This is part of the GAP system.\n",
"\n",
"\n -- ",maint,"  ",date,"\n"));

FileString("debian/control",Concatenation(
"Source: ",srcname,"\n",
"Section: math\n",
"Priority: optional\n",
"Maintainer: ",maint,"\n",
"Build-Depends: debhelper (>= ",debhelperver,"), gap (>= 4r7), gap-doc\n",
"Standards-Version: 3.9.5\n",
"Homepage: ",homepage,"\n",
"\n",
"Package: ",binname,"\n",
"Provides: gap-pkg-",pkgname,"\n",
Depends,
Suggests,
"Architecture: all\n",
"Description: ",synopsis,"\n",
" GAP is a system for computational discrete algebra, with particular emphasis\n",
" on Computational Group Theory. GAP provides a programming language, a library\n",
" of thousands of functions implementing algebraic algorithms written in the GAP\n",
" language as well as large data libraries of algebraic objects. GAP is used in\n",
" research and teaching for studying groups and their representations, rings,\n",
" vector spaces, algebras, combinatorial structures, and more.\n",
" .\n",
" ",pkg.Subtitle,"\n"));

FileString("debian/watch",Concatenation(
"version=3\n",
baseURL,"/",archivebase,"([0-9].*)\\.tar\\.bz2 debian uupdate\n"));

FileString("debian/doc-base",Concatenation(
"Document: ",binname,"\n",
"Title: ",pkg.PackageDoc.LongTitle,"\n",
"Author: ",authors,"\n",
"Abstract:\n ",abstract,"\n",
"Section: Science/Mathematics\n",
"\n",
"Format: pdf\n",
"Files: ",pkgbase,"/",pkg.PackageDoc.PDFFile,"\n",
"\n",
"Format: HTML\n",
"Index: ",pkgbase,"/",pkg.PackageDoc.HTMLStart,"\n",
"Files: ",pkgbase,"/",PackageDocHTML,"\n"));

FileString("debian/copyright", Concatenation(
"Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/\n",
"Upstream-Name: ",pkg.PackageName,"\n",
"Source: ",baseURL,"\n", 
"\n",
"Files: *\n",
"Copyright: Copyright ",copyyear," ",authoremails,"\n",
"License: GPL-2+\n",
"\n",
"Files: debian/*\n",
"Copyright: Copyright ",year," ",maint,"\n",
"License: GPL-2+\n"));

FileString("debian/links", Concatenation(
pkgbase,"/doc /usr/share/doc/",binname,"/doc\n"));

FileString("debian/patches/series", "doc-makefile\n");
FileString("debian/patches/doc-makefile", Concatenation(
"Index: ",srcname,"/doc/Makefile\n",
"===================================================================\n",
"--- /dev/null   1970-01-01 00:00:00.000000000 +0000\n",
"+++ ",srcname,"/doc/Makefile      2013-07-27 23:11:04.365369025 +0200\n",
"@@ -0,0 +1,33 @@\n",
"+SHELL=/bin/bash\n",
"+pkgdocdir=",pkgbase,"/doc\n",
"+DOCDIR=$(DESTDIR)$(pkgdocdir)\n",
"+MANUAL=main\n",
"+DIRS=.\n",
"+doc:\n",
"+\t./make_doc\n",
"+clean:\n",
"+\trm -f $(DIRS)/*.{html,txt,css,js}\n",
"+\trm -f $(DIRS)/make_manuals.out\n",
"+\trm -f $(DIRS)/$(MANUAL).{aux,bbl,blg,brf,idx,ilg,ind,log,out,pnr,tex,toc,toc.gz}\n",
"+\trm -f $(DIRS)/manual{,-bw}.{lab,six,six.gz,pdf}\n",
"+\trm -f manualbib.xml.bib wsp.g\n",
"+install: install-pdf install-help install-html\n",
"+install-pdf:\n",
"+\ttest -d $(DOCDIR)/$(DIRS) || install -d $(DOCDIR)/$(DIRS)\n",
"+\tset -e; for man in $(DIRS); do \\\n",
"+\t  install -o root -g root -m 0644 $$man/manual.pdf $(DOCDIR)/$$man;\\\n",
"+\tdone\n",
"+install-help:\n",
"+\ttest -d $(DOCDIR)/$(DIRS) || install -d $(DOCDIR)/$(DIRS)\n",
"+\tset -e; for man in $(DIRS); do \\\n",
"+\t  gzip --best $$man/manual.six; \\\n",
"+\t  gzip --best $$man/$(MANUAL).toc; \\\n",
"+\t  install -o root -g root -m 0644 $$man/manual.six.gz $(DOCDIR)/$$man;\\\n",
"+\t  install -o root -g root -m 0644 $$man/$(MANUAL).toc.gz $(DOCDIR)/$$man;\\\n",
"+\t  install -o root -g root -m 0644 $$man/*.txt $(DOCDIR)/$$man;\\\n",
"+\tdone\n",
"+install-html:\n",
"+\ttest -d $(DOCDIR)/$(DIRS) || install -d $(DOCDIR)/$(DIRS)\n",
"+\tset -e; for man in $(DIRS); do \\\n",
"+\t  install -o root -g root -m 0644 $$man/*.{html,css,js} $(DOCDIR)/$$man;\\\n",
"+\tdone\n"));

FileString("debian/rules", Concatenation(
"#!/usr/bin/make -f\n",
"# Copyright ",year," ",maint,"\n",
"\n",
"build-indep-stamp:\n",
"\tmake -C doc && touch build-indep-stamp\n",
"build-indep: build-indep-stamp\n",
"build-arch:\n",
"build: build-indep\n",
"\n",
"clean:\n",
"\tdh_testdir\n",
"\tdh_testroot\n",
"\tmake -C doc clean\n",
"\trm -f build-indep-stamp\n",
"\tdh_clean\n",
"\n",
"install: build\n",
"\tdh_testdir\n",
"\tdh_testroot\n",
"\tdh_prep\n",
"\tdh_installdirs\n",
"\tdh_install -X README -X -stamp -X debian -X tst -X doc -X htm -X.pc . ",
              pkgbaseN,"\n",
"\tmake -C doc install DESTDIR=../debian/",binname,"\n",
"binary-arch: build-arch\n",
"binary-indep: build-indep install\n",
"\tdh_testdir\n",
"\tdh_testroot\n",
"\tdh_installdocs README\n",
"\tdh_installexamples\n",
"\tdh_installchangelogs\n",
"\tdh_link\n",
"\tdh_compress\n",
"\tdh_fixperms\n",
"\tdh_installdeb\n",
"\tdh_gencontrol\n",
"\tdh_md5sums\n",
"\tdh_builddeb\n",
"\n",
"binary: binary-indep binary-arch\n",
".PHONY: build clean binary-indep binary-arch binary install configure\n"));
QUIT;