Let qemubuilder cache downloaded debs.

Werner Mahr werner at vollstreckernet.de
Tue Nov 20 10:14:06 UTC 2012


Junichi Uekawa wrote:

> At Tue, 16 Oct 2012 13:17:08 +0200,
> Werner Mahr wrote:
>> 
>> commit 272927a92e751505c6b94d3ecd464eddde7ce1d3
>> Author: Vollstrecker <amule at vollstreckernet.de>
>> Date:   Tue Oct 16 13:13:03 2012 +0200
>> 
>>     Added usage of apt-cache and fixed buildplace getting //
>> 
>> diff --git a/parameter.c b/parameter.c
[...]
>> +	  else if (!strcmp(long_options[index_point].name,"aptcache"))
>> +	    {
>> +	      /* this is for qemubuilder */
>> +	      pc.apt_cache=strdup(optarg);

>>        char* buildplace_ = pc.buildplace;
>> +      char* last_char;
>>        mkdir(buildplace_,0777); /* create if it does not exist */
>>        /* Bug: 573126 This adds '//' if buildplace already ends with / */
>> -      asprintf(&(pc.buildplace), "%s/%s.%i",
>> +      asprintf(&last_char, "%c", buildplace_[strlen(buildplace_)-1]);
> 
> why are you doing a strdup here?

As this is the last strdup I can find, why not? All strdups are duplications 
of the already existing code for params handling. I didn't really think 
about it, I just copied your code and replaced the var.

> last_char isn't freed anywhere.

Sorry, I forgot all freeing.
 
> if (buildplace_[strlen(buildplace_)-1] == '/')
> would be more reasonable, no?

That's what I tried first, but for some reason I changed it later. I just 
can't remember why. Maybe it's been some kind of string-literal versus local 
charset encoding. Maybe it was just a compile warning I wanted to avoid.
 
> something like:
>           asprintf(&(pc.buildplace), "%s%s%s.%i",
> buildplace_,
> (buildplace_[strlen(buildplace_)-1] == '/')?"/":""
> keyword, (int)getpid());
> 
> is probably better but I don't know if it's worth the change.

If it works (or just looks) better for you, feel free to use that part. As 
there is a bug report for it, I'm sure it's worth the change, and as I 
wouldn't touch this part when trying to get a cache for the pkg's, I'm 
pretty sure something didn't work before.

>> +  system(savecache);
> where do you free savecache?

As stated already, I forgot all freeing. Feel free to just add it after 
usage of the vars.





More information about the Pbuilder-maint mailing list