Fossil SCM
Change the ZIP file generator so that it sets the execute bit approprately. Ticket [baf9b6b11e08c1d].
Commit
b57bc473b0cf7632bf02aaa8d79a4ef60fac870f
Parent
3c39caac39b3d89…
1 file changed
+7
-7
+7
-7
| --- src/zip.c | ||
| +++ src/zip.c | ||
| @@ -104,11 +104,11 @@ | ||
| 104 | 104 | } |
| 105 | 105 | if( j>=nDir ){ |
| 106 | 106 | nDir++; |
| 107 | 107 | azDir = fossil_realloc(azDir, sizeof(azDir[0])*nDir); |
| 108 | 108 | azDir[j] = mprintf("%s", zName); |
| 109 | - zip_add_file(zName, 0); | |
| 109 | + zip_add_file(zName, 0, 0); | |
| 110 | 110 | } |
| 111 | 111 | zName[i+1] = c; |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | } |
| @@ -117,11 +117,11 @@ | ||
| 117 | 117 | ** Append a single file to a growing ZIP archive. |
| 118 | 118 | ** |
| 119 | 119 | ** pFile is the file to be appended. zName is the name |
| 120 | 120 | ** that the file should be saved as. |
| 121 | 121 | */ |
| 122 | -void zip_add_file(const char *zName, const Blob *pFile){ | |
| 122 | +void zip_add_file(const char *zName, const Blob *pFile, int isExe){ | |
| 123 | 123 | z_stream stream; |
| 124 | 124 | int nameLen; |
| 125 | 125 | int toOut = 0; |
| 126 | 126 | int iStart; |
| 127 | 127 | int iCRC = 0; |
| @@ -139,11 +139,11 @@ | ||
| 139 | 139 | /* Fill in as much of the header as we know. |
| 140 | 140 | */ |
| 141 | 141 | nBlob = pFile ? blob_size(pFile) : 0; |
| 142 | 142 | if( nBlob>0 ){ |
| 143 | 143 | iMethod = 8; |
| 144 | - iMode = 0100644; | |
| 144 | + iMode = isExe ? 0100755 : 0100644; | |
| 145 | 145 | }else{ |
| 146 | 146 | iMethod = 0; |
| 147 | 147 | iMode = 040755; |
| 148 | 148 | } |
| 149 | 149 | nameLen = strlen(zName); |
| @@ -287,11 +287,11 @@ | ||
| 287 | 287 | } |
| 288 | 288 | zip_open(); |
| 289 | 289 | for(i=3; i<g.argc; i++){ |
| 290 | 290 | blob_zero(&file); |
| 291 | 291 | blob_read_from_file(&file, g.argv[i]); |
| 292 | - zip_add_file(g.argv[i], &file); | |
| 292 | + zip_add_file(g.argv[i], &file, file_isexe(g.argv[i])); | |
| 293 | 293 | blob_reset(&file); |
| 294 | 294 | } |
| 295 | 295 | zip_close(&zip); |
| 296 | 296 | blob_write_to_file(&zip, g.argv[2]); |
| 297 | 297 | } |
| @@ -341,18 +341,18 @@ | ||
| 341 | 341 | zip_set_timedate(pManifest->rDate); |
| 342 | 342 | if( db_get_boolean("manifest", 0) ){ |
| 343 | 343 | blob_append(&filename, "manifest", -1); |
| 344 | 344 | zName = blob_str(&filename); |
| 345 | 345 | zip_add_folders(zName); |
| 346 | - zip_add_file(zName, &mfile); | |
| 346 | + zip_add_file(zName, &mfile, 0); | |
| 347 | 347 | sha1sum_blob(&mfile, &hash); |
| 348 | 348 | blob_reset(&mfile); |
| 349 | 349 | blob_append(&hash, "\n", 1); |
| 350 | 350 | blob_resize(&filename, nPrefix); |
| 351 | 351 | blob_append(&filename, "manifest.uuid", -1); |
| 352 | 352 | zName = blob_str(&filename); |
| 353 | - zip_add_file(zName, &hash); | |
| 353 | + zip_add_file(zName, &hash, 0); | |
| 354 | 354 | blob_reset(&hash); |
| 355 | 355 | } |
| 356 | 356 | manifest_file_rewind(pManifest); |
| 357 | 357 | while( (pFile = manifest_file_next(pManifest,0))!=0 ){ |
| 358 | 358 | int fid = uuid_to_rid(pFile->zUuid, 0); |
| @@ -360,11 +360,11 @@ | ||
| 360 | 360 | content_get(fid, &file); |
| 361 | 361 | blob_resize(&filename, nPrefix); |
| 362 | 362 | blob_append(&filename, pFile->zName, -1); |
| 363 | 363 | zName = blob_str(&filename); |
| 364 | 364 | zip_add_folders(zName); |
| 365 | - zip_add_file(zName, &file); | |
| 365 | + zip_add_file(zName, &file, manifest_file_mperm(pFile)); | |
| 366 | 366 | blob_reset(&file); |
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | }else{ |
| 370 | 370 | blob_reset(&mfile); |
| 371 | 371 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -104,11 +104,11 @@ | |
| 104 | } |
| 105 | if( j>=nDir ){ |
| 106 | nDir++; |
| 107 | azDir = fossil_realloc(azDir, sizeof(azDir[0])*nDir); |
| 108 | azDir[j] = mprintf("%s", zName); |
| 109 | zip_add_file(zName, 0); |
| 110 | } |
| 111 | zName[i+1] = c; |
| 112 | } |
| 113 | } |
| 114 | } |
| @@ -117,11 +117,11 @@ | |
| 117 | ** Append a single file to a growing ZIP archive. |
| 118 | ** |
| 119 | ** pFile is the file to be appended. zName is the name |
| 120 | ** that the file should be saved as. |
| 121 | */ |
| 122 | void zip_add_file(const char *zName, const Blob *pFile){ |
| 123 | z_stream stream; |
| 124 | int nameLen; |
| 125 | int toOut = 0; |
| 126 | int iStart; |
| 127 | int iCRC = 0; |
| @@ -139,11 +139,11 @@ | |
| 139 | /* Fill in as much of the header as we know. |
| 140 | */ |
| 141 | nBlob = pFile ? blob_size(pFile) : 0; |
| 142 | if( nBlob>0 ){ |
| 143 | iMethod = 8; |
| 144 | iMode = 0100644; |
| 145 | }else{ |
| 146 | iMethod = 0; |
| 147 | iMode = 040755; |
| 148 | } |
| 149 | nameLen = strlen(zName); |
| @@ -287,11 +287,11 @@ | |
| 287 | } |
| 288 | zip_open(); |
| 289 | for(i=3; i<g.argc; i++){ |
| 290 | blob_zero(&file); |
| 291 | blob_read_from_file(&file, g.argv[i]); |
| 292 | zip_add_file(g.argv[i], &file); |
| 293 | blob_reset(&file); |
| 294 | } |
| 295 | zip_close(&zip); |
| 296 | blob_write_to_file(&zip, g.argv[2]); |
| 297 | } |
| @@ -341,18 +341,18 @@ | |
| 341 | zip_set_timedate(pManifest->rDate); |
| 342 | if( db_get_boolean("manifest", 0) ){ |
| 343 | blob_append(&filename, "manifest", -1); |
| 344 | zName = blob_str(&filename); |
| 345 | zip_add_folders(zName); |
| 346 | zip_add_file(zName, &mfile); |
| 347 | sha1sum_blob(&mfile, &hash); |
| 348 | blob_reset(&mfile); |
| 349 | blob_append(&hash, "\n", 1); |
| 350 | blob_resize(&filename, nPrefix); |
| 351 | blob_append(&filename, "manifest.uuid", -1); |
| 352 | zName = blob_str(&filename); |
| 353 | zip_add_file(zName, &hash); |
| 354 | blob_reset(&hash); |
| 355 | } |
| 356 | manifest_file_rewind(pManifest); |
| 357 | while( (pFile = manifest_file_next(pManifest,0))!=0 ){ |
| 358 | int fid = uuid_to_rid(pFile->zUuid, 0); |
| @@ -360,11 +360,11 @@ | |
| 360 | content_get(fid, &file); |
| 361 | blob_resize(&filename, nPrefix); |
| 362 | blob_append(&filename, pFile->zName, -1); |
| 363 | zName = blob_str(&filename); |
| 364 | zip_add_folders(zName); |
| 365 | zip_add_file(zName, &file); |
| 366 | blob_reset(&file); |
| 367 | } |
| 368 | } |
| 369 | }else{ |
| 370 | blob_reset(&mfile); |
| 371 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -104,11 +104,11 @@ | |
| 104 | } |
| 105 | if( j>=nDir ){ |
| 106 | nDir++; |
| 107 | azDir = fossil_realloc(azDir, sizeof(azDir[0])*nDir); |
| 108 | azDir[j] = mprintf("%s", zName); |
| 109 | zip_add_file(zName, 0, 0); |
| 110 | } |
| 111 | zName[i+1] = c; |
| 112 | } |
| 113 | } |
| 114 | } |
| @@ -117,11 +117,11 @@ | |
| 117 | ** Append a single file to a growing ZIP archive. |
| 118 | ** |
| 119 | ** pFile is the file to be appended. zName is the name |
| 120 | ** that the file should be saved as. |
| 121 | */ |
| 122 | void zip_add_file(const char *zName, const Blob *pFile, int isExe){ |
| 123 | z_stream stream; |
| 124 | int nameLen; |
| 125 | int toOut = 0; |
| 126 | int iStart; |
| 127 | int iCRC = 0; |
| @@ -139,11 +139,11 @@ | |
| 139 | /* Fill in as much of the header as we know. |
| 140 | */ |
| 141 | nBlob = pFile ? blob_size(pFile) : 0; |
| 142 | if( nBlob>0 ){ |
| 143 | iMethod = 8; |
| 144 | iMode = isExe ? 0100755 : 0100644; |
| 145 | }else{ |
| 146 | iMethod = 0; |
| 147 | iMode = 040755; |
| 148 | } |
| 149 | nameLen = strlen(zName); |
| @@ -287,11 +287,11 @@ | |
| 287 | } |
| 288 | zip_open(); |
| 289 | for(i=3; i<g.argc; i++){ |
| 290 | blob_zero(&file); |
| 291 | blob_read_from_file(&file, g.argv[i]); |
| 292 | zip_add_file(g.argv[i], &file, file_isexe(g.argv[i])); |
| 293 | blob_reset(&file); |
| 294 | } |
| 295 | zip_close(&zip); |
| 296 | blob_write_to_file(&zip, g.argv[2]); |
| 297 | } |
| @@ -341,18 +341,18 @@ | |
| 341 | zip_set_timedate(pManifest->rDate); |
| 342 | if( db_get_boolean("manifest", 0) ){ |
| 343 | blob_append(&filename, "manifest", -1); |
| 344 | zName = blob_str(&filename); |
| 345 | zip_add_folders(zName); |
| 346 | zip_add_file(zName, &mfile, 0); |
| 347 | sha1sum_blob(&mfile, &hash); |
| 348 | blob_reset(&mfile); |
| 349 | blob_append(&hash, "\n", 1); |
| 350 | blob_resize(&filename, nPrefix); |
| 351 | blob_append(&filename, "manifest.uuid", -1); |
| 352 | zName = blob_str(&filename); |
| 353 | zip_add_file(zName, &hash, 0); |
| 354 | blob_reset(&hash); |
| 355 | } |
| 356 | manifest_file_rewind(pManifest); |
| 357 | while( (pFile = manifest_file_next(pManifest,0))!=0 ){ |
| 358 | int fid = uuid_to_rid(pFile->zUuid, 0); |
| @@ -360,11 +360,11 @@ | |
| 360 | content_get(fid, &file); |
| 361 | blob_resize(&filename, nPrefix); |
| 362 | blob_append(&filename, pFile->zName, -1); |
| 363 | zName = blob_str(&filename); |
| 364 | zip_add_folders(zName); |
| 365 | zip_add_file(zName, &file, manifest_file_mperm(pFile)); |
| 366 | blob_reset(&file); |
| 367 | } |
| 368 | } |
| 369 | }else{ |
| 370 | blob_reset(&mfile); |
| 371 |