public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
From: "W. Trevor King" <wking@tremily.us>
To: gentoo-catalyst@lists.gentoo.org
Subject: [gentoo-catalyst] Re: [PATCH] Remove some troublesome trailing slashes from paths
Date: Sat, 11 Jan 2014 18:58:59 -0800	[thread overview]
Message-ID: <20140112025858.GG18522@odin.tremily.us> (raw)
In-Reply-To: <1389469387-29010-2-git-send-email-dolsen@gentoo.org>

[-- Attachment #1: Type: text/plain, Size: 3388 bytes --]

On Sat, Jan 11, 2014 at 11:43:07AM -0800, Brian Dolbec wrote:
> -		self.settings["target_path"]=normpath(self.settings["storedir"]+\
> -			"/builds/"+self.settings["target_subpath"]+".tar.bz2")
> +		self.settings["target_path"] = normpath(self.settings["storedir"] +
> +			"/builds/" + self.settings["target_subpath"].rstrip('/') +
> +			".tar.bz2")

I find it hard to imagine target_subpath ending with a slash.  If it
did, I think that would be a bug where it's set, not something we
should try to work around here.  In the current master (e5a9e20):

  $ git grep -A2 'target_subpath.*=' | cat
  modules/generic_stage_target.py:                self.settings["target_subpath"]=self.settings["rel_type"]+"/"+\
  modules/generic_stage_target.py-                                self.settings["target"]+"-"+self.settings["subarch"]+"-"+\
  modules/generic_stage_target.py-                                self.settings["version_stamp"]
  --
  modules/snapshot_target.py:             self.settings["target_subpath"]="portage"
  modules/snapshot_target.py-             st=self.settings["storedir"]
  modules/snapshot_target.py-             self.settings["snapshot_path"] = normpath(st + "/snapshots/"

so we should be safe without this change.

> -			self.settings["source_path"]=normpath(self.settings["storedir"]+\
> -				"/builds/"+self.settings["source_subpath"]+".tar.bz2")
> +			self.settings["source_path"] = normpath(self.settings["storedir"] +
> +				"/builds/" + self.settings["source_subpath"].rstrip("/") +
> +				".tar.bz2")

source_subpath comes from the spec file, but I think we should check
for trailing slashes (and error out if we find them) when we load the
spec file, not here.  This also holds for the later source_subpath and
snapshot stripping.

>  			self.settings["snapshot_cache_path"]=\
>  				normpath(self.settings["snapshot_cache"]+"/"+\
> -				self.settings["snapshot"]+"/")
> +				self.settings["snapshot"])

Looks good to me, but doesn't this need a corresponding update to:

    if "SNAPCACHE" in self.settings:
        snapshot_cache_hash=\
            read_from_clst(self.settings["snapshot_cache_path"]+\
            "catalyst-hash")

and also to:

    if "SNAPCACHE" in self.settings:
        myf=open(self.settings["snapshot_cache_path"]+"catalyst-hash","w")
        myf.write(self.settings["snapshot_path_hash"])
        myf.close()

These will still *work* without a properly joined path, but they won't
use their intended …/catalyst-hash file (and may not be cleaned up
correctly).

>  		self.settings["chroot_path"]=normpath(self.settings["storedir"]+\
> -			"/tmp/"+self.settings["target_subpath"]+"/")
> +			"/tmp/"+self.settings["target_subpath"])

Looks good to me, but grepping for chroot_path gives lots of hits, and
I didn't check them all.

> -	local destdir=".${subdir}/tmp"
> +	local destdir="${subdir}/tmp"

Looks good to me, but…

>  	echo "Running ${file_name} in chroot ${chroot_path}"
> -	${clst_CHROOT} ${chroot_path} ${destdir}/${file_name} || exit 1
> +	${clst_CHROOT} ${chroot_path} .${destdir}/${file_name} || exit 1

…do we really need this dot?  I'll test and find out ;).

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

      reply	other threads:[~2014-01-12  2:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-11 19:43 [gentoo-catalyst] Start bringing consistent format to paths Brian Dolbec
2014-01-11 19:43 ` [gentoo-catalyst] [PATCH] Remove some troublesome trailing slashes from paths Brian Dolbec
2014-01-12  2:58   ` W. Trevor King [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140112025858.GG18522@odin.tremily.us \
    --to=wking@tremily.us \
    --cc=gentoo-catalyst@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox