Mercurial > octave
annotate scripts/pkg/private/build.m @ 21518:2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
* pkg/private/build.m: this functions prepares a "binary" package. This
rewrite is triggered to fix bug #45369 (do not move installed PKG_ADD and
PKG_DEL files into root of the binary package) but changes the whole
underlying logic of binary packages.
Previously, "pkg build" would install a package into a specific directory
and then created a package by making a tarball of it. This worked because
the build files would go into a arch dependent directory inside inst/ which
is just copied. Anyway, this is a complex process and sometimes almost
impossible because all files besides the .m and .oct files need to be moved
back to their original place. The main current problem is with PKG_ADD and
PKG_DEL files (see bugs #45362, #45091, and #45369).
In addition, it can also lead to duplication of PKG_ADD commands (because the
process of installing a package parses .m files for PKG_ADD directives so they
will appear on a PKG_ADD file. During installation of the binary package, the
PKG_ADD directives would be readded to the file).
Another issue is that it only works because the arch dependent directory is
nested within the arch independent directory. Since that should not be, it
will stop work once that gets fixed.
Anyway, the whole reason for a "binary" package is to avoid a build which may
require mkoctfile and C++ compilers (in theory it could also avoid generating
doc-cache but in practice that is currently not done). So all we have to do
is: do the build, remove the configure and Makefile, repackage everything with
the oct and mex files.
* pkg/private/repackage.m: remove unused function (it was used by build()) to
create a binary package from an installed package.
* pkg/private/configure_make.m: split into two parts. The first (which remains
configure_make()) only really calls configure and make (and is used by build()).
The rest is moved to the new function copy_built_files(). The split allows this
function to be used by build.
* pkg/private/copy_built_files.m: new function with the code moved from
configure_make (it is used in install() only).
* pkg/private/install.m: add call to copy_built_files which was previously
part of configure_make.
* pkg.m: adjust call to build().
* pkg/module.mk: remove repackage.m; add copy_built_files.m.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Mon, 21 Mar 2016 00:02:43 +0000 |
parents | 516bb87ea72e |
children | f7f97d7e9294 |
rev | line source |
---|---|
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
1 ## Copyright (C) 2005-2015 Søren Hauberg |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
2 ## Copyright (C) 2010 VZLU Prague, a.s. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
3 ## |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
4 ## This file is part of Octave. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
5 ## |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
6 ## Octave is free software; you can redistribute it and/or modify it |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
7 ## under the terms of the GNU General Public License as published by |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
9 ## your option) any later version. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
10 ## |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
11 ## Octave is distributed in the hope that it will be useful, but |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
14 ## General Public License for more details. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
15 ## |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
16 ## You should have received a copy of the GNU General Public License |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
17 ## along with Octave; see the file COPYING. If not, see |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
18 ## <http://www.gnu.org/licenses/>. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
19 |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
20 ## -*- texinfo -*- |
21518
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
21 ## @deftypefn {} {} build (@var{builddir}, @var{tarballs}, @var{verbose}) |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
22 ## Prepare binary packages from Octave source packages. |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
23 ## |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
24 ## Boils down to (for each in @var{tarballs}): |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
25 ## |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
26 ## @enumerate |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
27 ## @item untar the tarball in @var{builddir}; |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
28 ## @item build anything necessary (configure and make); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
29 ## @item repackage specifying the build arch in the tarball filename. |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
30 ## @end enumerate |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
31 ## |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
32 ## @end deftypefn |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
33 |
21518
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
34 function build (builddir, tarballs, verbose) |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
35 if (nargin != 3) |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
36 print_usage (); |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
37 endif |
21518
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
38 |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
39 if (! exist (builddir, "dir")) |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
40 warning ("creating build directory %s", builddir); |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
41 [status, msg] = mkdir (builddir); |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
42 if (status != 1) |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
43 error ("could not create installation directory: %s", msg); |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
44 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
45 endif |
21518
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
46 |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
47 for i = 1:numel(tarballs) |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
48 filelist = unpack (tarballs{i}, builddir); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
49 [~, root_idx] = min (cellfun ("numel", filelist)); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
50 package_root = filelist{root_idx}; |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
51 build_root = fullfile (builddir, filelist{root_idx}); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
52 |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
53 desc = get_description (fullfile (build_root, "DESCRIPTION")); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
54 |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
55 ## If there is no configure or Makefile within src/, there is nothing |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
56 ## to do to prepare a "binary" package. We only repackage to add more |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
57 ## info on the filename (version and arch). |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
58 if (! exist (fullfile (build_root, "src", "configure"), "file") |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
59 && ! exist (fullfile (build_root, "src", "Makefile"), "file")) |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
60 arch_abi = "any-none"; |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
61 else |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
62 arch_abi = getarch (); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
63 configure_make (desc, build_root, verbose); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
64 unlink (fullfile (build_root, "src", "configure")); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
65 unlink (fullfile (build_root, "src", "Makefile")); |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
66 endif |
21518
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
67 tfile = [desc.name "-" desc.version "-" arch_abi ".tar"]; |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
68 |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
69 init_wd = pwd (); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
70 unwind_protect |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
71 chdir (builddir); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
72 try |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
73 tar (tfile, package_root); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
74 rmdir (package_root, "s"); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
75 gzip (tfile); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
76 unlink (tfile); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
77 catch |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
78 warning ("failed to create and compress %s", tfile); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
79 end_try_catch |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
80 unwind_protect_cleanup |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
81 chdir (init_wd); |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
82 end_unwind_protect |
2ee20a290d61
pkg build: complete rewrite of the logic behind binary packages.
Carnë Draug <carandraug@octave.org>
parents:
20852
diff
changeset
|
83 endfor |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
84 endfunction |