aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2003-10-10 04:38:07 +0000
committerJason Woodward2003-10-10 04:38:07 +0000
commit5250252c6e30d8bfbf8915dc29bcf9c050e8d759 (patch)
tree08dd43d7daeb491fe1c4067f4bbfca96de031382 /src
parent4d1e3246139c2afcb7eaa82dce2a6bd5d3ee2ff7 (diff)
downloadslapt-get-5250252c6e30d8bfbf8915dc29bcf9c050e8d759.tar.gz
--no-md5 option to ignore md5 check sum of downloaded packages
Diffstat (limited to 'src')
-rw-r--r--src/configuration.c1
-rw-r--r--src/configuration.h1
-rw-r--r--src/curl.c65
-rw-r--r--src/main.c5
4 files changed, 44 insertions, 28 deletions
diff --git a/src/configuration.c b/src/configuration.c
index 45ad356..6dbee5f 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -92,6 +92,7 @@ rc_config *read_rc_config(const char *file_name){
global_config->download_only = 0;
global_config->simulate = 0;
global_config->ignore_excludes = 0;
+ global_config->no_md5_check = 0;
return global_config;
}
diff --git a/src/configuration.h b/src/configuration.h
index cf30dd6..e0c4c1d 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -35,6 +35,7 @@ struct _configuration {
int re_install;
struct exclude_list *exclude_list;
int ignore_excludes;
+ int no_md5_check;
};
typedef struct _configuration rc_config;
diff --git a/src/curl.c b/src/curl.c
index eb14d9e..7a19bec 100644
--- a/src/curl.c
+++ b/src/curl.c
@@ -179,19 +179,22 @@ char *download_pkg(const rc_config *global_config,pkg_info_t *pkg){
file_name = strncat(file_name,pkg->version,strlen(pkg->version));
file_name = strncat(file_name,".tgz",strlen(".tgz"));
- /*
- * here we will use the md5sum to see if the file is already present and valid
- */
- if( ( fh_test = fopen(file_name,"r") ) != NULL){
- /* check to see if the md5sum is correct */
- gen_md5_sum_of_file(fh_test,md5_sum_of_file);
- fclose(fh_test);
- if( strcmp(md5_sum_of_file,md5_sum) == 0 ){
- printf("Using cached copy of %s\n",pkg->name);
- free(md5_sum);
- free(md5_sum_of_file);
- return file_name;
+ if( global_config->no_md5_check == 0 ){
+ /*
+ * here we will use the md5sum to see if the file is already present and valid
+ */
+ if( ( fh_test = fopen(file_name,"r") ) != NULL){
+ /* check to see if the md5sum is correct */
+ gen_md5_sum_of_file(fh_test,md5_sum_of_file);
+ fclose(fh_test);
+ if( strcmp(md5_sum_of_file,md5_sum) == 0 ){
+ printf("Using cached copy of %s\n",pkg->name);
+ free(md5_sum);
+ free(md5_sum_of_file);
+ return file_name;
+ }
}
+ /* */
}
/* build the url */
@@ -237,31 +240,37 @@ char *download_pkg(const rc_config *global_config,pkg_info_t *pkg){
fclose(fh);
- /* check to see if the md5sum is correct */
fh = open_file(file_name,"r");
gen_md5_sum_of_file(fh,md5_sum_of_file);
fclose(fh);
- printf("verifying %s md5 sum...",pkg->name);
- if( strcmp(md5_sum_of_file,md5_sum) != 0 ){
- fprintf(stderr,"md5 sum for %s is not correct!\n",pkg->name);
+
+ if( global_config->no_md5_check == 0 ){
+
+ /* check to see if the md5sum is correct */
+ printf("verifying %s md5 sum...",pkg->name);
+ if( strcmp(md5_sum_of_file,md5_sum) != 0 ){
+ fprintf(stderr,"md5 sum for %s is not correct!\n",pkg->name);
#if DEBUG == 1
- fprintf(stderr,"MD5 found: [%s]\n",md5_sum_of_file);
- fprintf(stderr,"MD5 expected: [%s]\n",md5_sum);
- fprintf(stderr,"File: %s/%s\n",global_config->working_dir,file_name);
+ fprintf(stderr,"MD5 found: [%s]\n",md5_sum_of_file);
+ fprintf(stderr,"MD5 expected: [%s]\n",md5_sum);
+ fprintf(stderr,"File: %s/%s\n",global_config->working_dir,file_name);
#endif
#if DO_NOT_UNLINK_BAD_FILES == 0
- /* if the checksum fails, unlink the bogus file */
- if( unlink(file_name) == -1 ){
- fprintf(stderr,"Failed to unlink %s\n",file_name);
- if( errno ){
- perror("unlink");
+ /* if the checksum fails, unlink the bogus file */
+ if( unlink(file_name) == -1 ){
+ fprintf(stderr,"Failed to unlink %s\n",file_name);
+ if( errno ){
+ perror("unlink");
+ }
}
- }
#endif
- return NULL;
- }else{
- printf("Done\n");
+ return NULL;
+ }else{
+ printf("Done\n");
+ }
+ /* end md5 */
}
+
free(md5_sum);
free(md5_sum_of_file);
diff --git a/src/main.c b/src/main.c
index 92d010e..df62d69 100644
--- a/src/main.c
+++ b/src/main.c
@@ -40,6 +40,7 @@ int main( int argc, char *argv[] ){
{"no-prompt", 0, 0, 'b'},
{"reinstall", 0, 0, 'n'},
{"ignore-excludes", 0, 0, 'x'},
+ {"no-md5", 0, 0, '5'},
};
int option_index = 0;
/* */
@@ -124,6 +125,9 @@ int main( int argc, char *argv[] ){
case 'x': /* ignore-excludes */
global_config->ignore_excludes = 1;
break;
+ case '5': /* no-md5 */
+ global_config->no_md5_check = 1;
+ break;
default:
usage();
break;
@@ -160,6 +164,7 @@ void usage(){
printf(" --no-prompt - do not prompt during upgrade\n");
printf(" --reinstall - re-install the pkg even if installed\n");
printf(" --ignore-excludes - install excludes anyway\n");
+ printf(" --no-md5 - do not perform md5 check sum\n");
}
void version_info(void){