source: prextra/toolbox_export.m @ 145

Last change on this file since 145 was 145, checked in by bduin, 5 years ago
File size: 2.3 KB
Line 
1%TOOLBOX_EXPORT Prepare toolbox for export, archive and send to website
2%
3% TOOLBOX_EXPORT(TOOLBOX,COPYFLAG,EXPORTDIR)
4%
5% zip and copy toolbox to PRTools server and erchive in EXPORTDIR
6%
7% COPYFLAG:  TRUE: copy, FALSE: just zip. default TRUE
8
9function toolbox_export(toolbox,copyflag,exportdir)
10
11
12if nargin < 3, exportdir = 'K:\insy\PRLab\Matlab\prtools_export'; end
13if nargin < 2 || isempty(copyflag); copyflag = false; end
14
15% create temp dir
16zipdir = fullfile(fileparts(which(mfilename)),'tmp');
17if exist(zipdir,'dir') ~= 7
18  mkdir(zipdir);
19end
20
21toolboxpath = fileparts(which(fullfile(toolbox,'Contents')));
22[~,toolboxname] = fileparts(toolboxpath);
23toolboxver = ver(toolboxpath);
24fprintf(1,'    Present %s version is %s\n',toolbox,toolboxver(end).Version);
25pver_new = input(['    Give new version number: [' toolboxver(end).Version '] '],'s');
26if isempty(pver_new)
27  pver_new = toolboxver(end).Version;
28end
29set_version_in_Contents(toolboxpath,pver_new);
30ztoolbox = fullfile(zipdir,[toolbox pver_new '.' today '.zip']);
31zip(ztoolbox,{'*.m'},toolboxpath);
32copyfile(ztoolbox,exportdir);
33
34if copyflag
35  ftpsite = ftp('prtools.tudelft.nl','prlab','0iX7&b3c');
36  cd(ftpsite,'httpdocs/files');
37  mput(ftpsite,ztoolbox);
38  rename(ftpsite,ztoolbox,[toolboxname '.zip']);
39  disp('    export files have been stored on the website.')
40  disp('    Please check and adjust release notes and known problems on website')
41  close(ftpsite)
42 
43  % backup p-files and m-files
44  fprintf(1,'    Storing backups of mfiles and export files ... \n');
45  [s,mess] = copyfile(ztoolbox,fullfile(exportdir,toolboxname));
46  if s
47    delete(exppfiles);
48    disp(['    export files have been backed-up in ' exportdir])
49  else
50    disp(mess);
51  end
52else
53  fprintf(1,'    The zip-files have been created in exportdir.\n');
54  fprintf(1,'    They have not been copied to the website!\n');
55  fprintf(1,'    If needed, rerun with flag set.\n');
56end
57
58function set_version_in_Contents(toolbox,prtv)
59if ~isstr(prtv)
60        error('Version should be given as string, e.g. ''3.2.7''')
61end
62contentfile = fullfile(toolbox,'Contents.m');
63s = readf(contentfile);
64n = findstr(s,prnewline);
65r = [s(1:n(1)), '% Version ' prtv ' ' date s(n(2):end)];
66writf(contentfile,r);
67disp('    Contents.m rewritten with new version number')
Note: See TracBrowser for help on using the repository browser.