Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to recover from empty files in /etc after --usepkg?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
lekto
Apprentice
Apprentice


Joined: 20 Sep 2014
Posts: 212
Location: Ancient Rome

PostPosted: Sun Dec 01, 2024 6:49 pm    Post subject: How to recover from empty files in /etc after --usepkg? Reply with quote

Hi, I'm trying to fix what happened in my last thread (https://forums.gentoo.org/viewtopic-t-1171964.html).

Basicly, I have a Gentoo in a chroot that grabs installed packages from a host Gentoo and builds a few packages inside the chroot that are not in the host. I wanted to rebuild every package that is built inside the chroot, but instead of manually typing a list of packages to rebuild, I ran emerge -e @world, and it started to replace files in /etc with "empty files" until Gemato broke and emerge stopped working.

Now I have a few broken files:
Code:
chroot ~ # grep -r "empty file" /etc/
/etc/mime.types:# empty file because --include-config=n when `quickpkg` was used
/etc/python-exec/python-exec.conf:# empty file because --include-config=n when `quickpkg` was used
/etc/netconfig:# empty file because --include-config=n when `quickpkg` was used
/etc/lsb-release:# empty file because --include-config=n when `quickpkg` was used
/etc/profile.d/gawk.sh:# empty file because --include-config=n when `quickpkg` was used
/etc/profile.d/gawk.csh:# empty file because --include-config=n when `quickpkg` was used
/etc/sgml/sgml.conf:# empty file because --include-config=n when `quickpkg` was used
/etc/sgml/sgml-ent.cat:# empty file because --include-config=n when `quickpkg` was used
/etc/bash_completion.d/gentoo-style-init:# empty file because --include-config=n when `quickpkg` was used
/etc/bindresvport.blacklist:# empty file because --include-config=n when `quickpkg` was used
/etc/conf.d/pydoc-3.12:# empty file because --include-config=n when `quickpkg` was used
/etc/conf.d/pydoc-3.13:# empty file because --include-config=n when `quickpkg` was used
/etc/fonts/conf.avail/60-liberation.conf:# empty file because --include-config=n when `quickpkg` was used
/etc/security/access.conf:# empty file because --include-config=n when `quickpkg` was used
/etc/security/capability.conf:# empty file because --include-config=n when `quickpkg` was used
/etc/security/limits.conf:# empty file because --include-config=n when `quickpkg` was used
/etc/security/faillock.conf:# empty file because --include-config=n when `quickpkg` was used
/etc/security/group.conf:# empty file because --include-config=n when `quickpkg` was used
/etc/security/time.conf:# empty file because --include-config=n when `quickpkg` was used
/etc/security/namespace.conf:# empty file because --include-config=n when `quickpkg` was used
/etc/security/pwhistory.conf:# empty file because --include-config=n when `quickpkg` was used
/etc/security/namespace.init:# empty file because --include-config=n when `quickpkg` was used
/etc/security/pam_env.conf:# empty file because --include-config=n when `quickpkg` was used
/etc/xattr.conf:# empty file because --include-config=n when `quickpkg` was used
/etc/rhashrc:# empty file because --include-config=n when `quickpkg` was used
/etc/environment:# empty file because --include-config=n when `quickpkg` was used
/etc/ssl/ct_log_list.cnf:# empty file because --include-config=n when `quickpkg` was used
/etc/ssl/certs/.keep_dev-libs_openssl-0:# empty file because --include-config=n when `quickpkg` was used
/etc/ssl/ct_log_list.cnf.dist:# empty file because --include-config=n when `quickpkg` was used
/etc/ssl/openssl.cnf:# empty file because --include-config=n when `quickpkg` was used
/etc/ssl/private/.keep_dev-libs_openssl-0:# empty file because --include-config=n when `quickpkg` was used
/etc/ssl/misc/tsget.pl:# empty file because --include-config=n when `quickpkg` was used
/etc/ssl/misc/CA.pl:# empty file because --include-config=n when `quickpkg` was used
/etc/ssl/openssl.cnf.dist:# empty file because --include-config=n when `quickpkg` was used
/etc/init.d/pydoc-3.13:# empty file because --include-config=n when `quickpkg` was used
/etc/init.d/kmod-static-nodes:# empty file because --include-config=n when `quickpkg` was used
/etc/init.d/pydoc-3.12:# empty file because --include-config=n when `quickpkg` was used


Packages are shared by binding /var/cache/binpkgs inside the chroot.

EMERGE_DEFAULT_OPTS from the host:
EMERGE_DEFAULT_OPTS="--load-average 6 --buildpkg --usepkg --with-bdeps=y"

EMERGE_DEFAULT_OPTS from the chroot:
EMERGE_DEFAULT_OPTS="--load-average 6 --usepkg"

How to fix this mess and how to make sure it won't happen again in the future?­
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1033
Location: Somewhere in Denmark

PostPosted: Sun Dec 01, 2024 7:02 pm    Post subject: Reply with quote

You could use
Code:
grep -r "empty file" /etc/ | awk -F':' '{print $1}' | xargs emerge -av1
for emerging the packages with emtpy files in /etc/, but you would first have to rebuild the binaries and include configs to them if that's what you want.

Also per this - https://forums.gentoo.org/viewtopic-t-1064850-start-0.html - the config-files shouldn't be empty if the packages were build with FEATURES=buildpkg


Last edited by freke on Sun Dec 01, 2024 7:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54603
Location: 56N 3W

PostPosted: Sun Dec 01, 2024 7:08 pm    Post subject: Reply with quote

lekto,

Go back to the host that built those packages.
For each file discover the package that owns it
Code:
$ equery b /etc/mime.types
 * Searching for /etc/mime.types ...
app-misc/mime-types-2.1.54 (/etc/mime.types)


Run
Code:
emerge --buildpkgonly  app-misc/mime-types
or whatever the package is.
This will save a binary package with the default config file(s).

Now you can unpick the binary package and copy over the pristine missing files.

Do not use quickpkg.
--include-config=y is less than ideal as it saves the installed config files, not the pristine pre edit files.
e.g. You probably don't want you /etc/shadow and so on packaged that way.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
lekto
Apprentice
Apprentice


Joined: 20 Sep 2014
Posts: 212
Location: Ancient Rome

PostPosted: Sun Dec 01, 2024 7:54 pm    Post subject: Reply with quote

Okay, rebuilding packages in the host and then reemerging them in the chroot fixed it.

When I started building the chroot, I ran quickpkg */* in the host to have all binpkgs ready, then I added --buildpkg to make sure they are up to date. Using quickpkg caused some binpkgs to have empty /etc files, but those binpackages were later fixed when updating them with emerge --buildpkg. Which fixed every package because first I run update in the host (to build binpkgs), and then in the chroot (to use binpkgs). And those empty files are from first binpackages that were created with quickpkg back in may and were never updated with emerge --buildpkg. Am I understanding this correctly?


Also, I'm checking differences between FEATURES=buildpkg and --buildpkg, and according to this: https://wiki.gentoo.org/wiki/Handbook:AMD64/Working/Features#Creating_prebuilt_packages they are equal, but also equal to quickpkg:
Quote:
Creating prebuilt packages
Portage supports the installation of prebuilt packages.
To create a prebuilt package use the quickpkg command if the package is already installed on the system, or emerge with the --buildpkg or --buildpkgonly options.
To have Portage create prebuilt packages of every single package that gets installed, add buildpkg to the FEATURES variable.
More extended support for creating prebuilt package sets can be obtained with catalyst. For more information on catalyst please read the Catalyst FAQ.

Which from my issue isn't correct.

Also, in my system /etc/shadow doesn't belong go any package. I thought it belonged to sys-apps/shadow or sys-libs/glibc. But, on the other hand, in LFS I had to create it from scratch, so it makes sense it doesn't belong to any packages.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54603
Location: 56N 3W

PostPosted: Sun Dec 01, 2024 9:44 pm    Post subject: Reply with quote

The FEATURE and portage option both do exactly the same thing.
They cause portage to save a binary package just before the install phase, so it's as built.

quickpkg cannot do that.
It either does not save configurations, the default, or saves configurations as modified by the user on the install. That can be nasty.
e.g. /etc/fstab
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum