Changeset 4882
- Timestamp:
- Jan 8, 2001, 8:51:59 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/tools/DailyBuild/odin32ftp2.cmd ¶
r3861 r4882 1 /* $Id: odin32ftp2.cmd,v 1. 4 2000-07-19 12:08:50bird Exp $1 /* $Id: odin32ftp2.cmd,v 1.5 2001-01-08 19:51:59 bird Exp $ 2 2 * 3 3 * Uploads the relase and debug builds to the FTP sites. 4 4 * 5 * Copyright (c) 1999-200 0knut st. osmundsen (knut.stange.osmundsen@mynd.no)5 * Copyright (c) 1999-2001 knut st. osmundsen (knut.stange.osmundsen@mynd.no) 6 6 * 7 7 * Project Odin Software License can be found in LICENSE.TXT … … 17 17 do i = 1 to 5 /* (Retries 5 times) */ 18 18 sFile = 'odin32bin-'|| DATE(S); 19 sDelete = 'odin32bin-'|| DateSub 7(DATE('S'));19 sDelete = 'odin32bin-'|| DateSub(DATE('S'), 7); 20 20 sFileDbg = sFile || '-debug.zip'; 21 21 sFileDbgWPI = sFile || '-debug.wpi'; … … 47 47 if (sLoc = '' | sLoc = 'os2') then 48 48 do 49 rc = deletefunction( '/daily/'sDeleteDbg, '/daily/'sDeleteRel, 'os2-delete', 'www.os2.org' , 'user', 'xxxxxxxx');50 rc = deletefunction('/daily/'sDeleteDbgWPI, '/daily/'sDeleteRelWPI, 'os2-delete-wpi', 'www.os2.org' , 'user', 'xxxxxxxx');51 rc = forwardSF(sFileDbg, 'os2-debug', '/daily', 'www.os2.org' , 'user', 'xxxxxxxx');52 rc = forwardSF(sFileRel, 'os2-release', '/daily', 'www.os2.org' , 'user', 'xxxxxxxx');53 rc = forwardSF(sFileDbgWPI, 'os2-debug-wpi', '/daily', 'www.os2.org' , 'user', 'xxxxxxxx');54 rc = forwardSF(sFileRelWPI, 'os2-release-wpi', '/daily', 'www.os2.org' , 'user', 'xxxxxxxx');55 rc = forwardSF(sChangeLog, 'os2-ChangeLog', '/daily', 'www.os2.org' , 'user', 'xxxxxxxx');49 rc = deletefunction( '/daily/'sDeleteDbg, '/daily/'sDeleteRel, 'os2-delete', 'www.os2.org'); 50 rc = deletefunction('/daily/'sDeleteDbgWPI, '/daily/'sDeleteRelWPI, 'os2-delete-wpi', 'www.os2.org'); 51 rc = forwardSF(sFileDbg, 'os2-debug', '/daily', 'www.os2.org'); 52 rc = forwardSF(sFileRel, 'os2-release', '/daily', 'www.os2.org'); 53 rc = forwardSF(sFileDbgWPI, 'os2-debug-wpi', '/daily', 'www.os2.org'); 54 rc = forwardSF(sFileRelWPI, 'os2-release-wpi', '/daily', 'www.os2.org'); 55 rc = forwardSF(sChangeLog, 'os2-ChangeLog', '/daily', 'www.os2.org'); 56 56 57 57 end … … 59 59 if (0 /*sLoc = '' | sLoc = 'netlabs'*/) then 60 60 do 61 /* ( sDeleteFile1, sDeleteFile2, sLockFile, sSite , sUser, sPasswd); */62 rc = deletefunction( '/odinftp/daily/'sDeleteDbg, '/odinftp/daily/'sDeleteRel, 'netlabs-delete', 'ftp.netlabs.org' , 'user', 'xxxxxxxx');63 rc = deletefunction('/odinftp/daily/'sDeleteDbgWPI, '/odinftp/daily/'sDeleteRelWPI, 'netlabs-delete-wpi', 'ftp.netlabs.org' , 'user', 'xxxxxxxx');64 /* (sFile, sFileRemote, sLockFile, sSite , sUser, sPasswd); */65 rc = putfunction(sFileDbg, '/odinftp/daily', 'netlabs-debug', 'ftp.netlabs.org' , 'user', 'xxxxxxxx');66 rc = putfunction(sFileRel, '/odinftp/daily', 'netlabs-release', 'ftp.netlabs.org' , 'user', 'xxxxxxxx');67 rc = putfunction(sFileDbgWPI, '/odinftp/daily', 'netlabs-debug', 'ftp.netlabs.org' , 'user', 'xxxxxxxx');68 rc = putfunction(sFileRelWPI, '/odinftp/daily', 'netlabs-release', 'ftp.netlabs.org' , 'user', 'xxxxxxxx');69 rc = putfunction('ChangeLog', '/odinftp/daily', 'netlabs-ChangeLog', 'ftp.netlabs.org' , 'user', 'xxxxxxxx');61 /* ( sDeleteFile1, sDeleteFile2, sLockFile, sSite); */ 62 rc = deletefunction( '/odinftp/daily/'sDeleteDbg, '/odinftp/daily/'sDeleteRel, 'netlabs-delete', 'ftp.netlabs.org'); 63 rc = deletefunction('/odinftp/daily/'sDeleteDbgWPI, '/odinftp/daily/'sDeleteRelWPI, 'netlabs-delete-wpi', 'ftp.netlabs.org'); 64 /* (sFile, sFileRemote, sLockFile, sSite); */ 65 rc = putfunction(sFileDbg, '/odinftp/daily', 'netlabs-debug', 'ftp.netlabs.org'); 66 rc = putfunction(sFileRel, '/odinftp/daily', 'netlabs-release', 'ftp.netlabs.org'); 67 rc = putfunction(sFileDbgWPI, '/odinftp/daily', 'netlabs-debug', 'ftp.netlabs.org'); 68 rc = putfunction(sFileRelWPI, '/odinftp/daily', 'netlabs-release', 'ftp.netlabs.org'); 69 rc = putfunction('ChangeLog', '/odinftp/daily', 'netlabs-ChangeLog', 'ftp.netlabs.org'); 70 70 end 71 71 end … … 122 122 */ 123 123 forwardSF: procedure 124 parse arg sFile, sLockFile, sRemoteDir, sSite , sUser, sPasswd124 parse arg sFile, sLockFile, sRemoteDir, sSite 125 125 126 126 sSFDir = '/home/groups/ftp/pub/kTaskMgr/daily/'; … … 128 128 if (stream(sLockFile,'c','query exists') = '') then 129 129 do 130 /* get password */ 131 sPasswdString = GetPassword(sSite); 132 if (sPasswdString = '') then 133 do 134 call failure rc, 'Can''t find userid/password for' sSite'.', -1; 135 return -1; 136 end 137 parse var sPasswdString sUser':'sPasswd; 138 139 /* invoke forward process on SourceForge(t). */ 130 140 'cls' 131 141 say 'ssh -l stknut kTaskMgr.sourceforge.net upload' sUser sPasswd sSite sRemoteDir sFile; … … 147 157 */ 148 158 putfunction: procedure 149 parse arg sFile, sRemoteDir, sLockFile, sSite, sUser, sPasswd 159 parse arg sFile, sRemoteDir, sLockFile, sSite 160 161 /* check for done-lock */ 150 162 if stream(sLockFile,'c','query exists') = '' then 151 163 do 152 164 say '--- put' sFile '->' sRemoteDir'/'sFile '---'; 165 166 /* get password */ 167 sPasswdString = GetPassword(sSite); 168 if (sPasswdString = '') then 169 do 170 call failure rc, 'Can''t find userid/password for' sSite'.', -1; 171 return -1; 172 end 173 parse var sPasswdString sUser':'sPasswd; 174 175 /* debug logging */ 153 176 if 0 then 154 177 do … … 161 184 end 162 185 186 /* do the put */ 163 187 say 'ncftpput -u' sUser '-p' sPasswd '-z' sSite sRemoteDir sFile; 164 188 'ncftpput -u' sUser '-p' sPasswd '-z -F' sSite sRemoteDir sFile; … … 191 215 */ 192 216 deletefunction: procedure 193 parse arg sDeleteFile1, sDeleteFile2, sLockFile, sSite, sUser, sPasswd 217 parse arg sDeleteFile1, sDeleteFile2, sLockFile, sSite 218 219 /* 220 * On fridays we don't perform any deletetions. 221 */ 222 if (DATE('B')//7 = 5) then 223 return 0; 224 194 225 if stream(sLockFile,'c','query exists') = '' then 195 226 do 196 227 say '--- deleting old files('sDeleteFile1','sDeleteFile2') at 'sSite' ---' 228 229 /* get password */ 230 sPasswdString = GetPassword(sSite); 231 if (sPasswdString = '') then 232 do 233 call failure rc, 'Can''t find userid/password for' sSite'.', -1; 234 return -1; 235 end 236 parse var sPasswdString sUser':'sPasswd; 237 238 /* debug logging */ 197 239 if 0 then 198 240 do … … 205 247 end 206 248 249 /* start ftp'ing */ 207 250 rc = FtpSetUser(sSite, sUser, sPasswd); 208 251 if rc = 1 then … … 255 298 256 299 300 /* 301 * Reads the password file (passwd) in the script directory to 302 * get a password and userid for a given site. 303 * 304 * Format of the passwd file is: 305 * <site> <user> <password> 306 * Lines starting with '#' is ignored. 307 * 308 * @param sSite name of the site. 309 * @returns String on the form '<userid>:<passwd>' if found. 310 * Empty string if not found. 311 */ 312 GetPassword: procedure; 313 parse upper arg sSiteToFind 314 parse source sd1 sd2 sScript 315 sPasswd = filespec('drive', sScript) || filespec('path', sScript)||'\passwd'; 316 317 rc = stream(sPasswd, 'c', 'open read'); 318 if (pos('READY', rc) <> 1) then 319 do 320 say 'failed to open ftp password file - rc='rc; 321 return ''; 322 end 323 324 sRet = ''; 325 do while (lines(sPasswd) > 0) 326 sLine = strip(linein(sPasswd)); 327 if (sLine = '' | substr(sLine, 1, 1) = '#') then 328 iterate; 329 330 parse var sLine sSite' 'sUser' 'sPassword' 'sDummy 331 sSite = translate(strip(sSite)); 332 sUser = strip(sUser); 333 sPassword = strip(sPassword); 334 if (sSite = '' | sPassword = '' | sUser = '') then 335 say 'warning! misformed password line!'; 336 if (sSite = sSiteToFind) then 337 do 338 sRet = sUser||':'||sPassword; 339 leave 340 end 341 end 342 call stream sPasswd, 'c', 'close'; 343 return sRet; 344 345 346 testdatesub: 347 sDate='20010131'; 348 349 do i = 1 to 365*2+1 350 say sDate '-' i '=' DateSub(sDate, i); 351 end 352 exit; 353 257 354 258 355 /** 259 356 * Finds date seven days ago. 260 357 * @returns yyyymmdd date 261 * @param iDate Date on the yyyymmdd format. 262 */ 263 DateSub7: procedure 264 parse arg iDate 265 266 iDayInMonth = substr(iDate, 7, 2); 267 iMonth = substr(iDate, 5, 2); 268 iYear = substr(iDate, 1, 4); 269 270 if (iDayInMonth > 7) then 271 return iDate - 7; 272 else 273 do 274 if iMonth > 1 then 358 * @param sDate Date on the yyyymmdd format. 359 * @param cDays Number of days to subtract. 360 * @remark Works only for dates between 1000-01-01 and 9999-12-31 361 * including the limits. 362 */ 363 DateSub: procedure 364 parse arg sDate, cDays 365 366 /* subtraction loop which updates sDate and cDays for each iteration. */ 367 do while (cDays > 0) 368 /* 369 * Get the day in month of sDate. 370 * Do a simple subtraction is this is higher than the number of days to subtract. 371 */ 372 iDayInMonth = substr(sDate, 7, 2); 373 if (iDayInMonth > cDays) then 374 return sDate - cDays; 375 376 /* 377 * Determin previous month and the number of days in it. 378 */ 379 iMonth = substr(sDate, 5, 2); 380 iYear = substr(sDate, 1, 4); 381 if (iMonth > 1) then 275 382 iPrvMonth = iMonth - 1; 276 383 else 277 384 iPrvMonth = 12; 278 279 select 280 when iPrvMonth = 4 | iPrvMonth = 6 | iPrvMonth = 9 | iPrvMonth = 11 then 281 iDaysInPrevMonth = 30; 282 283 when iPrvMonth = 2 then 284 do 285 if ((iYear // 4) = 0) & (((iYear // 400) <> 0) | ((iYear // 2000) = 0)) then /*?*/ 286 iDaysInPrevMonth = 29; 287 else 288 iDaysInPrevMonth = 28; 289 end 290 291 otherwise 292 iDaysInPrevMonth = 31; 293 end /* select */ 294 295 say iDaysInPrevMonth 296 if iMonth > 1 then 297 return iDate - (100 - iDaysInPrevMonth) - 7; 385 cDaysPrvMonth = DateGetDaysInMonth(iYear, iPrvMonth); 386 387 /* 388 * Update date and days left to subtract. 389 */ 390 cDays = cDays - iDayInMonth; 391 if (iMonth > 1) then 392 sDate = sDate - iDayInMonth - 100 + cDaysPrvMonth; /* last day of previous month */ 298 393 else 299 return iDate - 8869 - 7; 300 end 301 end 302 303 return 00010101; 304 394 sDate = sDate - iDayInMonth - 8869; /* last day of last year */ 395 end 396 397 return sDate; 398 399 /* 400 * Gets the number of days in a given month. 401 * @param iYear the year. 402 * @param iMonth the month. 403 */ 404 DateGetDaysInMonth: procedure 405 parse arg iYear, iMonth 406 407 select 408 when (iMonth = 4 | iMonth = 6 | iMonth = 9 | iMonth = 11) then 409 cDays = 30; 410 411 when (iMonth = 2) then 412 do 413 if ((iYear // 4) = 0) & (((iYear // 400) <> 0) | ((iYear // 2000) = 0)) then 414 cDays = 29; 415 else 416 cDays = 28; 417 end 418 419 otherwise 420 cDays = 31; 421 end /* select */ 422 return cDays; 423
Note:
See TracChangeset
for help on using the changeset viewer.