Changeset 147
- Timestamp:
- 01/08/20 19:13:06 (5 years ago)
- Location:
- prextra
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
prextra/toolbox_export.m
r145 r147 7 7 % COPYFLAG: TRUE: copy, FALSE: just zip. default TRUE 8 8 9 function toolbox_export(toolbox,copyflag,exportdir )9 function toolbox_export(toolbox,copyflag,exportdir,exclude) 10 10 11 11 if nargin < 4, exclude = []; end 12 12 if nargin < 3, exportdir = 'K:\insy\PRLab\Matlab\prtools_export'; end 13 13 if nargin < 2 || isempty(copyflag); copyflag = false; end 14 if ischar(exclude), exclude = {exclude}; end 15 16 % check toolbox 17 s = which([toolbox '/Contents.m']); 18 if isempty(s) 19 error(['Toolbox ' toolbox ' is not found or has no Contents.m file']); 20 end 14 21 15 22 % create temp dir 16 23 zipdir = fullfile(fileparts(which(mfilename)),'tmp'); 17 if exist(zipdir,'dir') ~= 7 18 mkdir(zipdir); 19 end 24 makedir(zipdir); 20 25 21 toolboxpath = fileparts(which(fullfile(toolbox,'Contents'))); 26 % get names and version 27 today = datestr(date,'ddmmmyy'); 28 toolboxpath = fileparts(which(fullfile(toolbox,'Contents'))); 22 29 [~,toolboxname] = fileparts(toolboxpath); 23 toolboxver = ver(toolboxpath); 30 toolboxver = ver(toolboxpath); 31 32 % get and set possibly new version number in Content file 24 33 fprintf(1,' Present %s version is %s\n',toolbox,toolboxver(end).Version); 25 34 pver_new = input([' Give new version number: [' toolboxver(end).Version '] '],'s'); … … 28 37 end 29 38 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); 39 40 % zip 41 zfilename = [toolbox pver_new '_' today '.zip']; 42 ztoolbox = fullfile(zipdir,zfilename); 43 sdir = dirnames(toolboxpath); 44 if ~isempty(exclude) 45 for j=1:numel(exclude) 46 n = strmatch(exclude{j},sdir); 47 if isempty(n) 48 error(['Subdirectory ' exclude{j} ' does not exist']) 49 end 50 sdir(n) = []; 51 end 52 end 53 zip(ztoolbox,[{'*.m'} sdir{:}],toolboxpath); 54 55 % create specific archdir for this toolbox 56 archdir = fullfile(exportdir,toolboxname); 57 makedir(archdir); 33 58 34 59 if copyflag 60 % copy to website, use the @ftp package 35 61 ftpsite = ftp('prtools.tudelft.nl','prlab','0iX7&b3c'); 36 62 cd(ftpsite,'httpdocs/files'); 37 63 mput(ftpsite,ztoolbox); 38 rename(ftpsite,z toolbox,[toolboxname '.zip']);39 disp(' export files have been stored on the website.')64 rename(ftpsite,zfilename,[toolboxname '.zip']); 65 disp(' Export files have been stored on the website.') 40 66 disp(' Please check and adjust release notes and known problems on website') 67 webversion(pver_new,toolboxname,ftpsite); % reset the version file 41 68 close(ftpsite) 42 69 43 % backup p-files and m-files70 % backup in exportdir 44 71 fprintf(1,' Storing backups of mfiles and export files ... \n'); 45 [s,mess] = copyfile(ztoolbox, fullfile(exportdir,toolboxname));72 [s,mess] = copyfile(ztoolbox,archdir); 46 73 if s 47 delete(exppfiles); 48 disp([' export files have been backed-up in ' exportdir]) 74 disp([' export files have been backed-up in ' archdir]) 49 75 else 50 76 disp(mess); 51 77 end 52 78 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'); 79 copyfile(ztoolbox,archdir); 80 disp([' The zip-files have been created in ' archdir]); 81 disp([' They have not been copied to the website!']); 82 disp([' If needed, rerun with flag set']); 56 83 end 84 % cleanup 85 rmdir(zipdir,'s') 57 86 58 87 function set_version_in_Contents(toolbox,prtv) 88 59 89 if ~isstr(prtv) 60 90 error('Version should be given as string, e.g. ''3.2.7''') … … 62 92 contentfile = fullfile(toolbox,'Contents.m'); 63 93 s = readf(contentfile); 64 n = findstr(s, prnewline);94 n = findstr(s,newline); 65 95 r = [s(1:n(1)), '% Version ' prtv ' ' date s(n(2):end)]; 66 96 writf(contentfile,r); 67 97 disp(' Contents.m rewritten with new version number') 98 99 100 function [subdirs,files] = dirnames(dirname,ext) 101 %DIRNAMES 102 % 103 % [SUBDIRS,FILES]= DIRNAMES(DIR,EXT) 104 % 105 %Get names of all subdirs and files in direcotory DIR. 106 %Hidden files, . and .. and Thumbs.db neglected 107 108 if nargin == 0 109 dirname = '.'; 110 end 111 112 if nargin > 1 113 allnames = dir([dirname '/*.' ext]); 114 else 115 allnames = dir(dirname); 116 end 117 n = length(allnames); 118 subdirs = cell(1,n); 119 files = cell(1,n); 120 ns = 0; 121 nf = 0; 122 123 for j=1:n 124 name = deblank(allnames(j).name); 125 if (name(1) ~= '.') && ~strcmp(name,'Thumbs.db') % skip hidden files 126 if allnames(j).isdir 127 ns = ns+1; 128 subdirs{ns} = name; 129 else 130 nf = nf+1; 131 files{nf} = name; 132 end 133 end 134 end 135 136 if ns > 0 137 subdirs = char(subdirs(1:ns)); 138 subdirs = cellstr(subdirs); 139 else 140 subdirs = []; 141 end 142 if nf > 0 143 files = char(files(1:nf)); 144 files = cellstr(files); 145 else 146 files = []; 147 end 148 149 150 function makedir(name) 151 %MAKEDIR make directory if needed 152 153 if exist(name,'dir') ~= 7 154 mkdir(name) 155 end 156 157 function [s,n] = readf(file) 158 fid = fopen(file); 159 if fid < 0 160 error(['File ' file ' not found, probably wrong directory']) 161 end 162 [s,n] = fread(fid); 163 if isempty(s) 164 error(['File ' file ' could not be read']) 165 end 166 s = s(:)'; 167 fclose(fid); 168 169 function writf(file,s) 170 fid = fopen(file,'w'); 171 if fid < 0 172 error(['File ' file ' could not be opened for writing']) 173 end 174 fwrite(fid,s); 175 fclose(fid); -
prextra/webversion.m
r144 r147 1 1 %WEBVERSION Set version on website 2 2 % 3 % OUT = WEBVERSION(VERSION,TOOLBOX,FTPSITE ,DIR)3 % OUT = WEBVERSION(VERSION,TOOLBOX,FTPSITE) 4 4 % 5 %Creates a file TOOLBOX_version.txt containing just the VERSION number in a 6 %directory DIR of FTPSITE. 5 %Creates a file TOOLBOX_version.txt containing just the VERSION number on 6 %FTPSITE. FTPSITE should be created by the @FTP package andchanged to the 7 %proper directory. 7 8 8 9 function out = webversion(version,varargin) 9 10 10 [toolbox,ftpsite ,dir] = setdefaults(varargin,'prtools',[],'httpdocs/files');11 [toolbox,ftpsite] = setdefaults(varargin,'prtools',[]); 11 12 if isempty(ftpsite) 12 13 ftpsite = ftp('prtools.tudelft.nl','prlab','0iX7&b3c'); 14 cd(ftpsite,'httpdocs/files') 13 15 end 14 16 15 17 versionfile = fullfile(fileparts(which(mfilename)),[toolbox '_version.txt']); 16 18 fid = fopen(versionfile,'w'); 17 fprintf(fid, version);19 fprintf(fid,['Version ' version ' ' date]); 18 20 fclose(fid); 19 cd(ftpsite,dir);20 21 s = mput(ftpsite,versionfile); 21 22 delete(versionfile)
Note: See TracChangeset
for help on using the changeset viewer.