Patchwork Fix mklog to support running from arbitrary folder

login
register
mail settings
Submitter Yury Gribov
Date July 21, 2014, 8:32 a.m.
Message ID <53CCD02D.3070009@samsung.com>
Download mbox | patch
Permalink /patch/372007/
State New
Headers show

Comments

Yury Gribov - July 21, 2014, 8:32 a.m.
Hi all,

Current mklog works only if run from GCC top-level folder. The patch 
allows running from arbitrary directory.

I've used Linux directory separators which is probably ok because script 
already expects Linux environment (dirname, basename, etc.).

Ok to commit?

-Y
Diego Novillo - July 31, 2014, 5:57 p.m.
On Mon, Jul 21, 2014 at 4:32 AM, Yury Gribov <y.gribov@samsung.com> wrote:
> Hi all,
>
> Current mklog works only if run from GCC top-level folder. The patch allows
> running from arbitrary directory.
>
> I've used Linux directory separators which is probably ok because script
> already expects Linux environment (dirname, basename, etc.).
>
> Ok to commit?

OK.  Thanks.


Diego.
Yury Gribov - Aug. 1, 2014, 4:22 a.m.
On 07/31/2014 09:57 PM, Diego Novillo wrote:
>> Current mklog works only if run from GCC top-level folder. The patch allows
>> running from arbitrary directory.
>>
>> I've used Linux directory separators which is probably ok because script
>> already expects Linux environment (dirname, basename, etc.).
>>
>> Ok to commit?
>
> OK.  Thanks.

Done, r213401.

-Y

Patch

commit aa8d7cd3db1f1eba8ee77b902cff1b2ab2a3f83a
Author: Yury Gribov <y.gribov@samsung.com>
Date:   Mon Jul 21 12:05:10 2014 +0400

    2014-07-21  Yury Gribov  <y.gribov@samsung.com>
    
    	* mklog: Allow running from arbitrary folder.

diff --git a/contrib/mklog b/contrib/mklog
index cdc6455..3d17dc5 100755
--- a/contrib/mklog
+++ b/contrib/mklog
@@ -30,16 +30,15 @@ 
 $username = $ENV{'USER'};
 $name = `finger $username | grep -o 'Name: .*'`;
 @n = split(/: /, $name);
-$name = @n[1]; chop($name);
+$name = $n[1]; chop($name);
 $addr = $username . "\@my.domain.org";
 $date = `date +%Y-%m-%d`; chop ($date);
 
 $gcc_root = $0;
 $gcc_root =~ s/[^\\\/]+$/../;
-chdir $gcc_root;
 
 # if this is a git tree then take name and email from the git configuration
-if (-d .git) {
+if (-d "$gcc_root/.git") {
   $gitname = `git config user.name`;
   chomp($gitname);
   if ($gitname) {
@@ -80,7 +79,7 @@  sub get_clname ($) {
 	my $dirname = $_[0];
 	while ($dirname) {
 		my $clname = "$dirname/ChangeLog";
-		if (-f $clname) {
+		if (-f "$gcc_root/$clname") {
 			my $relname = substr ($_[0], length ($dirname) + 1);
 			return ($clname, $relname);
 		} else {