Mercurial > octave
comparison scripts/pkg/private/get_description.m @ 21615:9ccd64201b4d
pkg: remove excessive number of private function files.
pkg() makes use of many subfunctions, themselves with several subfunctions.
They used to all be in a single file which became difficult to hack so it
was split into one file per function (even though they all remained private).
This change merges some of those functions back together so that only the
functions used by pkg itself, as well as subfunctions used by more than one
of those, remain as separate files.
* copy_built_files.m, copy_files.m, create_pkgadddel.m, extract_pkg.m,
finish_installation.m, generate_lookfor_cache.m, prepare_installation.m,
verify_directory.m: merged this functions into install.m since they are
only used by it.
* fix_depends.m, fix_version.m: merged this functions into get_description.m
since they are only used by it.
* getarchprefix.m: merged into create_pkgadddel.m which then got merged
into install.m.
* is_architecture_dependent.m: merged into copy_built_files.m which then got
merged into install.m.
* load_package_dirs.m: merged into load_packages_and_dependencies.m
* packinfo_copy_file.m, write_index.m: merged into copy_files.m which then
then got merged into install.m.
* parse_pkg_idx, print_package_description.m: merged into describe.m
* shell.m: merged into configure_make.m
* pkg/module.mk: update with removed files.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Tue, 12 Apr 2016 17:46:20 +0100 |
parents | 516bb87ea72e |
children | 32cd60419b61 |
comparison
equal
deleted
inserted
replaced
21614:9bb39b754ab1 | 21615:9ccd64201b4d |
---|---|
76 desc.depends = ""; | 76 desc.depends = ""; |
77 endif | 77 endif |
78 desc.name = tolower (desc.name); | 78 desc.name = tolower (desc.name); |
79 endfunction | 79 endfunction |
80 | 80 |
81 | |
82 ## Make sure the version string v is a valid x.y.z version string | |
83 ## Examples: "0.1" => "0.1.0", "monkey" => error(...). | |
84 function out = fix_version (v) | |
85 if (regexp (v, '^\d+(\.\d+){1,2}$') == 1) | |
86 parts = ostrsplit (v, '.', true); | |
87 if (numel (parts) == 2) | |
88 out = [v ".0"]; | |
89 else | |
90 out = v; | |
91 endif | |
92 else | |
93 error ("bad version string: %s", v); | |
94 endif | |
95 endfunction | |
96 | |
97 | |
98 ## Make sure the depends field is of the right format. | |
99 ## This function returns a cell of structures with the following fields: | |
100 ## package, version, operator | |
101 function deps_cell = fix_depends (depends) | |
102 deps = strtrim (ostrsplit (tolower (depends), ",")); | |
103 deps_cell = cell (1, length (deps)); | |
104 dep_pat = ... | |
105 '\s*(?<name>[-\w]+)\s*(\(\s*(?<op>[<>=]+)\s*(?<ver>\d+\.\d+(\.\d+)*)\s*\))*\s*'; | |
106 | |
107 ## For each dependency. | |
108 for i = 1:length (deps) | |
109 dep = deps{i}; | |
110 [start, nm] = regexp (dep, dep_pat, 'start', 'names'); | |
111 ## Is the dependency specified | |
112 ## in the correct format? | |
113 if (! isempty (start)) | |
114 package = tolower (strtrim (nm.name)); | |
115 ## Does the dependency specify a version | |
116 ## Example: package(>= version). | |
117 if (! isempty (nm.ver)) | |
118 operator = nm.op; | |
119 if (! any (strcmp (operator, {">", ">=", "<=", "<", "=="}))) | |
120 error ("unsupported operator: %s", operator); | |
121 endif | |
122 version = fix_version (nm.ver); | |
123 ## If no version is specified for the dependency | |
124 ## we say that the version should be greater than | |
125 ## or equal to "0.0.0". | |
126 else | |
127 package = tolower (strtrim (dep)); | |
128 operator = ">="; | |
129 version = "0.0.0"; | |
130 endif | |
131 deps_cell{i} = struct ("package", package, | |
132 "operator", operator, | |
133 "version", version); | |
134 else | |
135 error ("incorrect syntax for dependency '%s' in the DESCRIPTION file\n", | |
136 dep); | |
137 endif | |
138 endfor | |
139 endfunction |