[gentoo-portage-dev] [PATCH] install.py: ignore -Z / --context

2019-11-07 Thread Mike Gilbert
The --context option accepts an optional argument, but only if it is
passed via --context=arg. The argparse module does not deal with this
properly.

To work around this, have argparse ignore this option, and filter out
any remaining arguments that start with a hyphen.

Bug: https://bugs.gentoo.org/699548
Signed-off-by: Mike Gilbert 
---
 bin/install.py | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/bin/install.py b/bin/install.py
index d3789ed96..e56475ff1 100755
--- a/bin/install.py
+++ b/bin/install.py
@@ -111,12 +111,6 @@ def parse_args(args):
action="store_true",
dest="no_target_directory"
)
-   parser.add_argument(
-   "--context",
-   "-Z",
-   action="store",
-   dest="context"
-   )
parser.add_argument(
"--verbose",
"-v",
@@ -147,7 +141,7 @@ def parse_args(args):
 
opts  = parsed_args[0]
files = parsed_args[1]
-   files = [f for f in files if f != "--"] # filter out "--"
+   files = [f for f in files if not f.startswith("-")] # filter unknown 
options
 
return (opts, files)
 
-- 
2.24.0




[gentoo-portage-dev] [PATCH v2] install.py: ignore -Z / --context

2019-11-07 Thread Mike Gilbert
The --context option accepts an optional argument, but only if it is
passed via --context=arg. The argparse module does not deal with this
properly.

To work around this, have argparse ignore this option, and filter out
any remaining arguments that start with a hyphen and do not occur after
a "--" delimiter.

Bug: https://bugs.gentoo.org/699548
Signed-off-by: Mike Gilbert 
---

If there is a cleaner way to do this, suggestions are welcome.

diff --git a/bin/install.py b/bin/install.py
index d3789ed96..495534d33 100755
--- a/bin/install.py
+++ b/bin/install.py
@@ -111,12 +111,6 @@ def parse_args(args):
action="store_true",
dest="no_target_directory"
)
-   parser.add_argument(
-   "--context",
-   "-Z",
-   action="store",
-   dest="context"
-   )
parser.add_argument(
"--verbose",
"-v",
@@ -143,11 +137,21 @@ def parse_args(args):
# for known options in order for argparse to correctly
# separate option arguments from file arguments in all
# cases (it also allows for optparse compatibility).
-   parsed_args = parser.parse_known_args()
+   (opts, args) = parser.parse_known_args(args)
+
+   files = []
+   i = 0
+   while i < len(args):
+   if args[i] == "--":
+   i += 1
+   break
+   if not args[i].startswith("-"):
+   files.append(args[i])
+   i += 1
 
-   opts  = parsed_args[0]
-   files = parsed_args[1]
-   files = [f for f in files if f != "--"] # filter out "--"
+   while i < len(args):
+   files.append(args[i])
+   i += 1
 
return (opts, files)
 
-- 
2.24.0




[gentoo-portage-dev] [PATCH] emirrordist: fix DeletionTask to handle broken symlink

2019-11-07 Thread Zac Medico
After rename of a nonexistent symlink target fails, detect a
broken symlink and simply delete it.

Fixes: 0d34d89d5028 ("emirrordist: Implement mirror layout.conf support")
Bug: https://bugs.gentoo.org/699400
Signed-off-by: Zac Medico 
---
 lib/portage/_emirrordist/DeletionTask.py | 5 +
 1 file changed, 5 insertions(+)

diff --git a/lib/portage/_emirrordist/DeletionTask.py 
b/lib/portage/_emirrordist/DeletionTask.py
index 5eb01d840..49f13ddf7 100644
--- a/lib/portage/_emirrordist/DeletionTask.py
+++ b/lib/portage/_emirrordist/DeletionTask.py
@@ -28,6 +28,11 @@ class DeletionTask(CompositeTask):
recycle_path)
except OSError as e:
if e.errno != errno.EXDEV:
+   if 
os.path.islink(self.distfile_path) and not os.path.exists(self.distfile_path):
+   self._delete_links()
+   self._async_wait()
+   return
+
logging.error(("rename %s from 
distfiles to "
"recycle failed: %s") % 
(self.distfile, e))
else:
-- 
2.21.0




[gentoo-portage-dev] Re: [PATCH] emirrordist: fix DeletionTask to handle broken symlink

2019-11-07 Thread Zac Medico
On 11/7/19 1:01 PM, Zac Medico wrote:
> After rename of a nonexistent symlink target fails, detect a
> broken symlink and simply delete it.
> 
> Fixes: 0d34d89d5028 ("emirrordist: Implement mirror layout.conf support")
> Bug: https://bugs.gentoo.org/699400
> Signed-off-by: Zac Medico 
> ---
>  lib/portage/_emirrordist/DeletionTask.py | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/lib/portage/_emirrordist/DeletionTask.py 
> b/lib/portage/_emirrordist/DeletionTask.py
> index 5eb01d840..49f13ddf7 100644
> --- a/lib/portage/_emirrordist/DeletionTask.py
> +++ b/lib/portage/_emirrordist/DeletionTask.py
> @@ -28,6 +28,11 @@ class DeletionTask(CompositeTask):
>   recycle_path)
>   except OSError as e:
>   if e.errno != errno.EXDEV:
> + if 
> os.path.islink(self.distfile_path) and not os.path.exists(self.distfile_path):
> + self._delete_links()
> + self._async_wait()
> + return
> +
>   logging.error(("rename %s from 
> distfiles to "
>   "recycle failed: %s") % 
> (self.distfile, e))
>   else:
> 

Actually, I withdraw this patch since we shouldn't have a symlink here
since self.distfile_path was added:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=af9c77bd037694164755d06034a74456ec45e3ab
-- 
Thanks,
Zac



signature.asc
Description: OpenPGP digital signature


[gentoo-portage-dev] seed emerge with old /var/db/pkg ?

2019-11-07 Thread Joakim Tjernlund
I am looking for a way to seed emerge with an older pkg db so emerge can 
calculate
which packages needs to be rebuild/upgraded in order to get to the same state 
as the system pkg db,
Is that possible?

Also, is there some tool that allows med to copy just files needed for a 
profile?
Something like "cp" /etc/portage/make.profile /my/destination



Re: [gentoo-portage-dev] [PATCH v2] install.py: ignore -Z / --context

2019-11-07 Thread Zac Medico
On 11/7/19 1:18 PM, Mike Gilbert wrote:
> The --context option accepts an optional argument, but only if it is
> passed via --context=arg. The argparse module does not deal with this
> properly.
> 
> To work around this, have argparse ignore this option, and filter out
> any remaining arguments that start with a hyphen and do not occur after
> a "--" delimiter.
> 
> Bug: https://bugs.gentoo.org/699548
> Signed-off-by: Mike Gilbert 
> ---
> 
> If there is a cleaner way to do this, suggestions are welcome.
> 
> diff --git a/bin/install.py b/bin/install.py
> index d3789ed96..495534d33 100755
> --- a/bin/install.py
> +++ b/bin/install.py
> @@ -111,12 +111,6 @@ def parse_args(args):
>   action="store_true",
>   dest="no_target_directory"
>   )
> - parser.add_argument(
> - "--context",
> - "-Z",
> - action="store",
> - dest="context"
> - )
>   parser.add_argument(
>   "--verbose",
>   "-v",
> @@ -143,11 +137,21 @@ def parse_args(args):
>   # for known options in order for argparse to correctly
>   # separate option arguments from file arguments in all
>   # cases (it also allows for optparse compatibility).
> - parsed_args = parser.parse_known_args()
> + (opts, args) = parser.parse_known_args(args)
> +
> + files = []
> + i = 0
> + while i < len(args):
> + if args[i] == "--":
> + i += 1
> + break
> + if not args[i].startswith("-"):
> + files.append(args[i])
> + i += 1
>  
> - opts  = parsed_args[0]
> - files = parsed_args[1]
> - files = [f for f in files if f != "--"] # filter out "--"
> + while i < len(args):
> + files.append(args[i])
> + i += 1
>  
>   return (opts, files)
>  
> 

Looks good. Please merge.
-- 
Thanks,
Zac



Re: [gentoo-portage-dev] [PATCH] install.py: ignore -Z / --context

2019-11-07 Thread Zac Medico
On 11/7/19 10:22 AM, Mike Gilbert wrote:
> The --context option accepts an optional argument, but only if it is
> passed via --context=arg. The argparse module does not deal with this
> properly.
> 
> To work around this, have argparse ignore this option, and filter out
> any remaining arguments that start with a hyphen.
> 
> Bug: https://bugs.gentoo.org/699548
> Signed-off-by: Mike Gilbert 
> ---
>  bin/install.py | 8 +---
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/bin/install.py b/bin/install.py
> index d3789ed96..e56475ff1 100755
> --- a/bin/install.py
> +++ b/bin/install.py
> @@ -111,12 +111,6 @@ def parse_args(args):
>   action="store_true",
>   dest="no_target_directory"
>   )
> - parser.add_argument(
> - "--context",
> - "-Z",
> - action="store",
> - dest="context"
> - )
>   parser.add_argument(
>   "--verbose",
>   "-v",
> @@ -147,7 +141,7 @@ def parse_args(args):
>  
>   opts  = parsed_args[0]
>   files = parsed_args[1]
> - files = [f for f in files if f != "--"] # filter out "--"
> + files = [f for f in files if not f.startswith("-")] # filter unknown 
> options
>  
>   return (opts, files)
>  
> 

Technically, shouldn't we pass through any "files" that start with "-"
and come after the "--" separator?
-- 
Thanks,
Zac



signature.asc
Description: OpenPGP digital signature


Re: [gentoo-portage-dev] [PATCH] install.py: ignore -Z / --context

2019-11-07 Thread Mike Gilbert
On Thu, Nov 7, 2019 at 3:31 PM Zac Medico  wrote:
>
> On 11/7/19 10:22 AM, Mike Gilbert wrote:
> > The --context option accepts an optional argument, but only if it is
> > passed via --context=arg. The argparse module does not deal with this
> > properly.
> >
> > To work around this, have argparse ignore this option, and filter out
> > any remaining arguments that start with a hyphen.
> >
> > Bug: https://bugs.gentoo.org/699548
> > Signed-off-by: Mike Gilbert 
> > ---
> >  bin/install.py | 8 +---
> >  1 file changed, 1 insertion(+), 7 deletions(-)
> >
> > diff --git a/bin/install.py b/bin/install.py
> > index d3789ed96..e56475ff1 100755
> > --- a/bin/install.py
> > +++ b/bin/install.py
> > @@ -111,12 +111,6 @@ def parse_args(args):
> >   action="store_true",
> >   dest="no_target_directory"
> >   )
> > - parser.add_argument(
> > - "--context",
> > - "-Z",
> > - action="store",
> > - dest="context"
> > - )
> >   parser.add_argument(
> >   "--verbose",
> >   "-v",
> > @@ -147,7 +141,7 @@ def parse_args(args):
> >
> >   opts  = parsed_args[0]
> >   files = parsed_args[1]
> > - files = [f for f in files if f != "--"] # filter out "--"
> > + files = [f for f in files if not f.startswith("-")] # filter unknown 
> > options
> >
> >   return (opts, files)
> >
> >
>
> Technically, shouldn't we pass through any "files" that start with "-"
> and come after the "--" separator?

Ah, yes. I will revise it.