2008-08-03 20:50:29

by Satish Eerpini

[permalink] [raw]
Subject: Kernel Installer

Hello everyone , :

i have been writing a kernel installer which may make the kernel
installation process a lot more easier for noobs , (don ask me why
noobs would like to compile a kernel) , but atleast till they learn
to do it the good way !

i have written some code which is below , well i am stuck at one thing , ...
once the .config file is set , is there any method to compute the
exact no of files that are going to be compiled ??
lack of this knowledge is clearly visible in the use of a "while(1)"
in the code below :




#include <stdio.h>


int main(int argc, char * argv[]) {

char buf[100],syscommand[100];
FILE *fp;
int i=0,j=0,k=0,l=0;
int checking_done=0;
strcpy(buf,"\0");

fflush(stdout);

strcpy(syscommand,"make -C ");
if(argc==2){
strcat(syscommand,argv[1]);
}
else{

printf("The program accepts the kernel source \n directory as
the single argument.\n Please provide necessary arguments\n");
return ;
}



printf("\n\n\t\t\t\t\t\t Kernel Installer V1.0\n\n ");


fp= popen(syscommand,"r");
do{

fscanf(fp,"%s",buf);

if(checking_done!=1){

if(strcmp(buf,"CHK")==0){
fscanf(fp,"%s",buf);
printf("\rChecking file : %-30s\t\n",buf);


}
if(strcmp(buf,"CALL")==0){
fscanf(fp,"%s",buf);

printf("\rCalling script : %s\t\n",buf);

}
}

if(strcmp(buf,"LD")==0){
fscanf(fp,"%s",buf);


printf("\rLinking File : %s\t",buf);
l++;
checking_done=1;

}

if(strcmp(buf,"CC")==0){
fscanf(fp,"%s",buf);
if(strcmp(buf,"[M]")==0){
fscanf(fp,"%s",buf);
printf("\rCompiling module (%-4d files, %-4d
modules compiled): %-60s\t",i,l,buf);
l++;
}
else
printf("\rCompiling (%-4d files, %-4d
modules compiled) : %-60s\t",i,l,buf);
i++;

switch(i%4){
case 0:
printf(" | ");
break;
case 1:
printf(" / ");
break;
case 2:
printf(" - ");
break;
case 3:
printf(" \\ ");
break;
}
for(k=0;k<j;k++)
printf("=");
printf(">");

if((i%100)==0 && i!=0){
j++;
}

checking_done=1;

}
fflush(stdout);
}while(1);
pclose(fp);

return 0;

}

there is some more work that i remain to add, like being able to start
from the kernel source , that is just provide the path to the archive
and it does everything else and so on ,
but for now i am stuck here !

Thanks
Satish

--
http://satish.playdrupal.com


2008-08-03 21:02:17

by Adrian Bunk

[permalink] [raw]
Subject: Re: Kernel Installer

On Mon, Aug 04, 2008 at 02:20:19AM +0530, Satish Eerpini wrote:
> Hello everyone , :
>
> i have been writing a kernel installer which may make the kernel
> installation process a lot more easier for noobs , (don ask me why
> noobs would like to compile a kernel) , but atleast till they learn
> to do it the good way !
>
> i have written some code which is below , well i am stuck at one thing , ...
> once the .config file is set , is there any method to compute the
> exact no of files that are going to be compiled ??
>...

Replacing the normal build output with something different doesn't make
anything easier.

Especially considering that your "once the .config file is set" seems to
assume the user already configured the kernel himself...

> Thanks
> Satish

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2008-08-04 03:47:09

by Satish Eerpini

[permalink] [raw]
Subject: Re: Kernel Installer

> Replacing the normal build output with something different doesn't make
> anything easier.
>
> Especially considering that your "once the .config file is set" seems to
> assume the user already configured the kernel himself...
>

i am not just trying to replace the output , i am not a stupid to
waste my weekend sitting just to replace the output :-),
if u are interested , u can check out the entire TODO for the app here
http://satish.playdrupal.com/?q=node/2

but in the process i am stuck at deciding the no of files that will be
compiled , given that representing the entire compilation
process as a progress bar , would give a clear idea of " how much is
over" and "how much is left" !!!


Thanks
Satish



--
http://satish.playdrupal.com

2008-08-04 05:03:46

by Bob van Manen

[permalink] [raw]
Subject: Re: Kernel Installer

Hi Satish,

I don't know much about the kernel build process, so I don't know
whether it would work or not.

But you could try running make with the -n option first to see the
commands that are going to be executed. That way you can figure out
how many files are going to be compiled.

I hope that works for you.

Regards,

bob

On Sun, Aug 3, 2008 at 1:50 PM, Satish Eerpini <[email protected]> wrote:
> Hello everyone , :
>
> i have been writing a kernel installer which may make the kernel
> installation process a lot more easier for noobs , (don ask me why
> noobs would like to compile a kernel) , but atleast till they learn
> to do it the good way !
>
> i have written some code which is below , well i am stuck at one thing , ...
> once the .config file is set , is there any method to compute the
> exact no of files that are going to be compiled ??
> lack of this knowledge is clearly visible in the use of a "while(1)"
> in the code below :
>
>
>
>
> #include <stdio.h>
>
>
> int main(int argc, char * argv[]) {
>
> char buf[100],syscommand[100];
> FILE *fp;
> int i=0,j=0,k=0,l=0;
> int checking_done=0;
> strcpy(buf,"\0");
>
> fflush(stdout);
>
> strcpy(syscommand,"make -C ");
> if(argc==2){
> strcat(syscommand,argv[1]);
> }
> else{
>
> printf("The program accepts the kernel source \n directory as
> the single argument.\n Please provide necessary arguments\n");
> return ;
> }
>
>
>
> printf("\n\n\t\t\t\t\t\t Kernel Installer V1.0\n\n ");
>
>
> fp= popen(syscommand,"r");
> do{
>
> fscanf(fp,"%s",buf);
>
> if(checking_done!=1){
>
> if(strcmp(buf,"CHK")==0){
> fscanf(fp,"%s",buf);
> printf("\rChecking file : %-30s\t\n",buf);
>
>
> }
> if(strcmp(buf,"CALL")==0){
> fscanf(fp,"%s",buf);
>
> printf("\rCalling script : %s\t\n",buf);
>
> }
> }
>
> if(strcmp(buf,"LD")==0){
> fscanf(fp,"%s",buf);
>
>
> printf("\rLinking File : %s\t",buf);
> l++;
> checking_done=1;
>
> }
>
> if(strcmp(buf,"CC")==0){
> fscanf(fp,"%s",buf);
> if(strcmp(buf,"[M]")==0){
> fscanf(fp,"%s",buf);
> printf("\rCompiling module (%-4d files, %-4d
> modules compiled): %-60s\t",i,l,buf);
> l++;
> }
> else
> printf("\rCompiling (%-4d files, %-4d
> modules compiled) : %-60s\t",i,l,buf);
> i++;
>
> switch(i%4){
> case 0:
> printf(" | ");
> break;
> case 1:
> printf(" / ");
> break;
> case 2:
> printf(" - ");
> break;
> case 3:
> printf(" \\ ");
> break;
> }
> for(k=0;k<j;k++)
> printf("=");
> printf(">");
>
> if((i%100)==0 && i!=0){
> j++;
> }
>
> checking_done=1;
>
> }
> fflush(stdout);
> }while(1);
> pclose(fp);
>
> return 0;
>
> }
>
> there is some more work that i remain to add, like being able to start
> from the kernel source , that is just provide the path to the archive
> and it does everything else and so on ,
> but for now i am stuck here !
>
> Thanks
> Satish
>
> --
> http://satish.playdrupal.com
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

2008-08-04 09:26:29

by Tejun Heo

[permalink] [raw]
Subject: Re: Kernel Installer

Satish Eerpini wrote:
>> Replacing the normal build output with something different doesn't make
>> anything easier.
>>
>> Especially considering that your "once the .config file is set" seems to
>> assume the user already configured the kernel himself...
>>
>
> i am not just trying to replace the output , i am not a stupid to
> waste my weekend sitting just to replace the output :-),
> if u are interested , u can check out the entire TODO for the app here
> http://satish.playdrupal.com/?q=node/2
>
> but in the process i am stuck at deciding the no of files that will be
> compiled , given that representing the entire compilation
> process as a progress bar , would give a clear idea of " how much is
> over" and "how much is left" !!!

make -n makes make do a dry-run but kbuild is a pretty complex beast and
you might have to jump through some loops to get the information you want.

--
tejun

2008-08-04 11:00:31

by Satish Eerpini

[permalink] [raw]
Subject: Re: Kernel Installer

using make -n does not work well for my purpose , because with that ,
the neat kernel compilation output is gone , and i think it is far
more work to make sense out of the entire details make -n gives .

I rather came up with this idea , though i think it is more time consuming , :

--> enter each directory recursively and parse the Makefile for the
files that would be compiled ,
--> this can be done by comparing the "CONFIG_" options which have
been enabled in .config
--> and then should also make note of the other 'objs' being compiled
for the required objects .

but all this has to be done in a way which minimises the amount of CPU
time the installer takes , because while we are running the make for
the compilation , it itself consumes a lot of CPU cyles . (CC
actually) ,........

another obstacle i have faced is recognising when the Linux image is
being built , and when the compiling enters into the second stage ,
viz , building modules ........ but knowing the total no of modules to
be compiled is simple as it is already given out by kbuild.

what i need to know , is there any method by which the total no of
files to be compiled can be computed internally in the kbuild process
itself , ......
or the second method would be to "echo" markers (basically text
messages) after each stage of the compilation which can be caught by
the installer , ... but i am sure this is not the best of the methods
to be followed , ..........

is this possible ?


On Mon, Aug 4, 2008 at 2:55 PM, Tejun Heo <[email protected]> wrote:
> Satish Eerpini wrote:
>>> Replacing the normal build output with something different doesn't make
>>> anything easier.
>>>
>>> Especially considering that your "once the .config file is set" seems to
>>> assume the user already configured the kernel himself...
>>>
>>
>> i am not just trying to replace the output , i am not a stupid to
>> waste my weekend sitting just to replace the output :-),
>> if u are interested , u can check out the entire TODO for the app here
>> http://satish.playdrupal.com/?q=node/2
>>
>> but in the process i am stuck at deciding the no of files that will be
>> compiled , given that representing the entire compilation
>> process as a progress bar , would give a clear idea of " how much is
>> over" and "how much is left" !!!
>
> make -n makes make do a dry-run but kbuild is a pretty complex beast and
> you might have to jump through some loops to get the information you want.
>
> --
> tejun
>

Thanks
Satish
--
http://satish.playdrupal.com

2008-08-04 14:04:05

by Jeff Dike

[permalink] [raw]
Subject: Re: Kernel Installer

On Mon, Aug 04, 2008 at 09:16:52AM +0530, Satish Eerpini wrote:
> but in the process i am stuck at deciding the no of files that will be
> compiled , given that representing the entire compilation
> process as a progress bar , would give a clear idea of " how much is
> over" and "how much is left" !!!

Look at make -n. I suspect that its output won't match reality
perfectly, but it's probably good enough for a progress bar.

Jeff

--
Work email - jdike at linux dot intel dot com

2008-08-04 21:31:56

by Satish Eerpini

[permalink] [raw]
Subject: Re: Kernel Installer

yes i have been looking at make -n . but now , collectively parsing
the .config file and the Make files seems to be more useful , ...
what say ?

On Mon, Aug 4, 2008 at 7:33 PM, Jeff Dike <[email protected]> wrote:
> On Mon, Aug 04, 2008 at 09:16:52AM +0530, Satish Eerpini wrote:
>> but in the process i am stuck at deciding the no of files that will be
>> compiled , given that representing the entire compilation
>> process as a progress bar , would give a clear idea of " how much is
>> over" and "how much is left" !!!
>
> Look at make -n. I suspect that its output won't match reality
> perfectly, but it's probably good enough for a progress bar.
>
> Jeff
>
> --
> Work email - jdike at linux dot intel dot com
>



--
http://satish.playdrupal.com

2008-08-04 21:32:57

by Satish Eerpini

[permalink] [raw]
Subject: Re: Kernel Installer

lot more work needs to be done , before the kernel installer would be
useful for a newbie , and the GUI front end would be the major part of
it !

Thanks
Satish

On Mon, Aug 4, 2008 at 7:28 PM, GNU Boi <[email protected]> wrote:
> hey man thanks as u have started a kernel installer i (we newbie) like
> it ........
>
> On 8/3/08, Satish Eerpini <[email protected]> wrote:
>> using make -n does not work well for my purpose , because with that ,
>> the neat kernel compilation output is gone , and i think it is far
>> more work to make sense out of the entire details make -n gives .
>>
>> I rather came up with this idea , though i think it is more time consuming ,
>> :
>>
>> --> enter each directory recursively and parse the Makefile for the
>> files that would be compiled ,
>> --> this can be done by comparing the "CONFIG_" options which have
>> been enabled in .config
>> --> and then should also make note of the other 'objs' being compiled
>> for the required objects .
>>
>> but all this has to be done in a way which minimises the amount of CPU
>> time the installer takes , because while we are running the make for
>> the compilation , it itself consumes a lot of CPU cyles . (CC
>> actually) ,........
>>
>> another obstacle i have faced is recognising when the Linux image is
>> being built , and when the compiling enters into the second stage ,
>> viz , building modules ........ but knowing the total no of modules to
>> be compiled is simple as it is already given out by kbuild.
>>
>> what i need to know , is there any method by which the total no of
>> files to be compiled can be computed internally in the kbuild process
>> itself , ......
>> or the second method would be to "echo" markers (basically text
>> messages) after each stage of the compilation which can be caught by
>> the installer , ... but i am sure this is not the best of the methods
>> to be followed , ..........
>>
>> is this possible ?
>>
>>
>> On Mon, Aug 4, 2008 at 2:55 PM, Tejun Heo <[email protected]> wrote:
>>> Satish Eerpini wrote:
>>>>> Replacing the normal build output with something different doesn't make
>>>>> anything easier.
>>>>>
>>>>> Especially considering that your "once the .config file is set" seems to
>>>>> assume the user already configured the kernel himself...
>>>>>
>>>>
>>>> i am not just trying to replace the output , i am not a stupid to
>>>> waste my weekend sitting just to replace the output :-),
>>>> if u are interested , u can check out the entire TODO for the app here
>>>> http://satish.playdrupal.com/?q=node/2
>>>>
>>>> but in the process i am stuck at deciding the no of files that will be
>>>> compiled , given that representing the entire compilation
>>>> process as a progress bar , would give a clear idea of " how much is
>>>> over" and "how much is left" !!!
>>>
>>> make -n makes make do a dry-run but kbuild is a pretty complex beast and
>>> you might have to jump through some loops to get the information you want.
>>>
>>> --
>>> tejun
>>>
>>
>> Thanks
>> Satish
>> --
>> http://satish.playdrupal.com
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://www.tux.org/lkml/
>>
>



--
http://satish.playdrupal.com