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 |
|
---|
9 | function toolbox_export(toolbox,copyflag,exportdir)
|
---|
10 |
|
---|
11 |
|
---|
12 | if nargin < 3, exportdir = 'K:\insy\PRLab\Matlab\prtools_export'; end
|
---|
13 | if nargin < 2 || isempty(copyflag); copyflag = false; end
|
---|
14 |
|
---|
15 | % create temp dir
|
---|
16 | zipdir = fullfile(fileparts(which(mfilename)),'tmp');
|
---|
17 | if exist(zipdir,'dir') ~= 7
|
---|
18 | mkdir(zipdir);
|
---|
19 | end
|
---|
20 |
|
---|
21 | toolboxpath = fileparts(which(fullfile(toolbox,'Contents')));
|
---|
22 | [~,toolboxname] = fileparts(toolboxpath);
|
---|
23 | toolboxver = ver(toolboxpath);
|
---|
24 | fprintf(1,' Present %s version is %s\n',toolbox,toolboxver(end).Version);
|
---|
25 | pver_new = input([' Give new version number: [' toolboxver(end).Version '] '],'s');
|
---|
26 | if isempty(pver_new)
|
---|
27 | pver_new = toolboxver(end).Version;
|
---|
28 | end
|
---|
29 | set_version_in_Contents(toolboxpath,pver_new);
|
---|
30 | ztoolbox = fullfile(zipdir,[toolbox pver_new '.' today '.zip']);
|
---|
31 | zip(ztoolbox,{'*.m'},toolboxpath);
|
---|
32 | copyfile(ztoolbox,exportdir);
|
---|
33 |
|
---|
34 | if 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
|
---|
52 | else
|
---|
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');
|
---|
56 | end
|
---|
57 |
|
---|
58 | function set_version_in_Contents(toolbox,prtv)
|
---|
59 | if ~isstr(prtv)
|
---|
60 | error('Version should be given as string, e.g. ''3.2.7''')
|
---|
61 | end
|
---|
62 | contentfile = fullfile(toolbox,'Contents.m');
|
---|
63 | s = readf(contentfile);
|
---|
64 | n = findstr(s,prnewline);
|
---|
65 | r = [s(1:n(1)), '% Version ' prtv ' ' date s(n(2):end)];
|
---|
66 | writf(contentfile,r);
|
---|
67 | disp(' Contents.m rewritten with new version number') |
---|