New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #12629: macports-remotetime.patch

File macports-remotetime.patch, 3.6 KB (added by afb@…, 6 years ago)

macports-remotetime.patch

  • configure.ac

     
    7979AC_HEADER_SYS_WAIT 
    8080AC_HEADER_STAT 
    8181AC_CHECK_HEADERS([limits.h paths.h sys/file.h crt_externs.h fcntl.h sys/fcntl.h sys/cdefs.h err.h libgen.h sys/socket.h \ 
    82         readline/readline.h readline/history.h pwd.h sys/paths.h]) 
     82        readline/readline.h readline/history.h pwd.h sys/paths.h utime.h]) 
    8383 
    8484INCLUDES="-I.. -I. $INCLUDES" 
    8585 
  • src/pextlib1.0/curl.c

     
    4343#include <string.h> 
    4444#endif 
    4545 
     46#ifdef HAVE_UTIME_H 
     47#include <utime.h> 
     48#endif 
     49 
    4650#include <curl/curl.h> 
    4751 
    4852#include <tcl.h> 
     
    124128/** 
    125129 * curl fetch subcommand entry point. 
    126130 * 
    127  * syntax: curl fetch [-v] [--disable-epsv] [--ignore-ssl-cert] [-u userpass] [--effective-url lasturlvar] url filename 
     131 * syntax: curl fetch [-v] [--disable-epsv] [--ignore-ssl-cert] [--remote-time] [-u userpass] [--effective-url lasturlvar] url filename 
    128132 * 
    129133 * @param interp                current interpreter 
    130134 * @param objc                  number of parameters 
     
    142146                int noprogress = 1; 
    143147                int useepsv = 1; 
    144148                int ignoresslcert = 0; 
     149                int remotetime = 0; 
    145150                const char* theUserPassString = NULL; 
    146151                const char* effectiveURLVarName = NULL; 
    147152                char* effectiveURL = NULL; 
     
    149154                int lastoption; 
    150155                const char* theURL; 
    151156                const char* theFilePath; 
     157                long theFileTime = 0; 
    152158                CURLcode theCurlCode; 
    153159                struct curl_slist *headers = NULL; 
    154160                 
     
    167173                                useepsv = 0; 
    168174                        } else if (strcmp(theOption, "--ignore-ssl-cert") == 0) { 
    169175                                ignoresslcert = 1; 
     176                        } else if (strcmp(theOption, "--remote-time") == 0) { 
     177                                remotetime = 1; 
    170178                        } else if (strcmp(theOption, "-u") == 0) { 
    171179                                /* check we also have the parameter */ 
    172180                                if (optioncrsr < lastoption) { 
     
    296304                        } 
    297305                } 
    298306 
     307                /* we want/don't want remote time */ 
     308                theCurlCode = curl_easy_setopt(theHandle, CURLOPT_FILETIME, remotetime); 
     309                if (theCurlCode != CURLE_OK) { 
     310                        theResult = SetResultFromCurlErrorCode(interp, theCurlCode); 
     311                        break; 
     312                } 
     313 
    299314                /* set the l/p, if any */ 
    300315                if (theUserPassString) { 
    301316                        theCurlCode = curl_easy_setopt(theHandle, CURLOPT_USERPWD, theUserPassString); 
     
    324339                (void) fclose( theFile ); 
    325340                theFile = NULL; 
    326341                 
     342#ifdef HAVE_UTIME_H 
     343                if (remotetime) { 
     344                        theCurlCode = curl_easy_getinfo(theHandle, CURLINFO_FILETIME, &theFileTime); 
     345                        if (theFileTime > 0) { 
     346                                struct utimbuf times; 
     347                                times.actime = (time_t)theFileTime; 
     348                                times.modtime = (time_t)theFileTime; 
     349                                utime(theFilePath, &times); /* set the time we got */ 
     350                        } 
     351                } 
     352#endif /*HAVE_UTIME_H*/ 
     353                 
    327354                /* free header memory */ 
    328355                curl_slist_free_all(headers); 
    329356 
  • src/port1.0/portfetch.tcl

     
    433433                                ui_msg "$UI_PREFIX [format [msgcat::mc "Attempting to fetch %s from %s"] $distfile $site]" 
    434434                                set file_url [portfetch::assemble_url $site $distfile] 
    435435                                set effectiveURL "" 
    436                                 if {![catch {eval curl fetch --effective-url effectiveURL $fetch_options {$file_url} ${distpath}/${distfile}.TMP} result] && 
     436                                if {![catch {eval curl fetch --remote-time --effective-url effectiveURL $fetch_options {$file_url} ${distpath}/${distfile}.TMP} result] && 
    437437                                        ![catch {system "mv ${distpath}/${distfile}.TMP ${distpath}/${distfile}"}]} { 
    438438 
    439439                                        # Special hack to check for sourceforge mirrors, which don't return a proper error code on failure