Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 598116 - Autounmask fails when there is no file in /etc/portage/package.*/
Summary: Autounmask fails when there is no file in /etc/portage/package.*/
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: Portage team
: 485346 (view as bug list)
Depends on:
Blocks: autounmask 604854
  Show dependency tree
Reported: 2016-10-26 11:46 UTC by terabit.funtoo
Modified: 2017-05-23 00:43 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description terabit.funtoo 2016-10-26 11:46:59 UTC
--autounmask-write fails with the following error:

The following problems occurred while writing autounmask changes:
!!! No file to write for '/etc/portage/package.keywords'

# file /etc/portage/package.keywords
/etc/portage/package.keywords: directory

there was no file in /etc/portage/package.keywords/
The following fixes this condition:

# touch file etc/portage/package.keywords/somefile

Reproducible: Always

Steps to Reproduce:
1.emerge a masked package with the --autounmask-write option while /etc/portage/package.keywords/ is empty
Actual Results:  
Full portage output

Expected Results:  
autounmask-changes should be written for etc-update or dispatch-conf to commit.

Talked to veremit in #gentoo-portage and a bug report was recommended for this behavior.
Comment 1 terabit.funtoo 2016-10-26 22:41:52 UTC
The function find_config_file in , when the file_name is a directory , it returns the last file (excluding '.','..' and '~') in the list returned by os.listdir() , it does not take into account the possibility of there not being any file at all. 

In my case it was returning 'None' which was the root cause of the bug. 

The following patch fixes the problem for me:

---     2016-10-27 03:04:45.150732927 +0000
+++ 2016-10-27 03:01:10.630713632 +0000
@@ -8187,7 +8187,10 @@
                                                                stack.append(os.path.join(p, child))
+                       if last_file_path == None:
+                               last_file_path=file_path+"/"+file_name+".default"
+                               with open(last_file_path,"a+") as default:
+                                       default.write("#"+file_name)
                        return last_file_path
                write_to_file = autounmask_write and not pretend
Comment 2 Brian Dolbec gentoo-dev 2016-11-01 01:41:52 UTC
I have the patches in my local repo so far.  Needs a bit more testing for other package.* directories still.
Comment 4 Zac Medico gentoo-dev 2017-02-10 18:52:02 UTC
Fixed in portage-2.3.3.
Comment 5 Zac Medico gentoo-dev 2017-05-23 00:43:43 UTC
*** Bug 485346 has been marked as a duplicate of this bug. ***