Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
eselect is wrong and I can not run menuconfig
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
dman777
l33t
l33t


Joined: 10 Jan 2007
Posts: 982

PostPosted: Fri Apr 20, 2018 12:13 am    Post subject: eselect is wrong and I can not run menuconfig Reply with quote

It appears that my directory seems to be messed up.

1) eselect shows the wrong softlink
2) When I manually go into my correct kernel directory I can not make menuconfig

Any ideas what is wrong?


Code:

localhost / # eselect kernel list
Available kernel symlink targets:
  [1]   linux-4.9.76-gentoo-r1

localhost / # cd /usr/src/
localhost /usr/src # lr
total 16K
drwxr-xr-x  4 root root 4.0K Jan 21 15:16 .
drwxr-xr-x 13 root root 4.0K Dec 14 21:19 ..
-rw-r--r--  1 root root    0 Dec  8 12:17 .keep
lrwxrwxrwx  1 root root   20 Dec 15 21:51 linux -> linux-4.12.12-gentoo
drwxr-xr-x 22 root root 4.0K Jan 21 17:06 linux-4.12.12-gentoo
drwxr-xr-x 25 root root 4.0K Apr 19 14:05 linux-4.9.76-gentoo-r1
localhost /usr/src # uname -a
Linux localhost 4.12.12-gentoo #10 SMP Wed Dec 27 19:27:43 CST 2017 x86_64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz GenuineIntel GNU/Linux
localhost /usr/src # cd linux-4.12.12-gentoo
localhost /usr/src/linux-4.12.12-gentoo # make menuconfig
make: *** No rule to make target 'menuconfig'.  Stop.
localhost /usr/src/linux-4.12.12-gentoo # lr
total 128M
drwxr-xr-x 22 root root 4.0K Jan 21 17:06 .
drwxr-xr-x  4 root root 4.0K Jan 21 15:16 ..
-rw-r--r--  1 root root 116K Dec 27 19:17 .config
-rw-r--r--  1 root root 111K Dec 24 14:25 .config.old
-rw-r--r--  1 root root  485 Dec 27 19:18 .missing-syscalls.d
-rw-r--r--  1 root root 3.6M Dec 27 19:27 .tmp_System.map
-rw-r--r--  1 root root 4.2M Dec 27 19:27 .tmp_kallsyms1.S
-rw-r--r--  1 root root 717K Dec 27 19:27 .tmp_kallsyms1.o
-rw-r--r--  1 root root 4.2M Dec 27 19:27 .tmp_kallsyms2.S
-rw-r--r--  1 root root 717K Dec 27 19:27 .tmp_kallsyms2.o
drwxr-xr-x  2 root root 4.0K Dec 27 19:27 .tmp_versions
-rwxr-xr-x  1 root root  34M Dec 27 19:27 .tmp_vmlinux1
-rwxr-xr-x  1 root root  34M Dec 27 19:27 .tmp_vmlinux2
-rw-r--r--  1 root root    3 Dec 27 19:27 .version
-rw-r--r--  1 root root   97 Dec 27 19:27 .vmlinux.cmd
-rw-r--r--  1 root root 521K Dec 27 19:27 Module.symvers
-rw-r--r--  1 root root 3.6M Dec 27 19:27 System.map
drwxr-xr-x  4 root root 4.0K Jan 21 17:06 arch
drwxr-xr-x  3 root root 4.0K Jan 21 17:06 block
drwxr-xr-x  2 root root 4.0K Jan 21 17:06 certs
drwxr-xr-x  2 root root  12K Jan 21 17:06 crypto
drwxr-xr-x 63 root root 4.0K Jan 21 17:06 drivers
drwxr-xr-x  4 root root 4.0K Jan 21 17:06 firmware
drwxr-xr-x 25 root root  12K Jan 21 17:06 fs
drwxr-xr-x  4 root root 4.0K Jan 21 17:06 include
drwxr-xr-x  2 root root 4.0K Jan 21 17:06 init
drwxr-xr-x  2 root root 4.0K Jan 21 17:06 ipc
drwxr-xr-x 14 root root  12K Jan 21 17:06 kernel
drwxr-xr-x  8 root root  20K Jan 21 17:06 lib
drwxr-xr-x  2 root root  12K Jan 21 17:06 mm
-rw-r--r--  1 root root  11K Dec 27 19:27 modules.builtin
-rw-r--r--  1 root root  828 Dec 27 19:27 modules.order
drwxr-xr-x 20 root root 4.0K Jan 21 17:06 net
drwxr-xr-x  6 root root 4.0K Jan 21 17:06 scripts
drwxr-xr-x  4 root root 4.0K Jan 21 17:06 security
drwxr-xr-x 22 root root 4.0K Jan 21 17:06 sound
drwxr-xr-x  2 root root 4.0K Jan 21 17:06 usr
drwxr-xr-x  3 root root 4.0K Jan 21 17:06 virt
-rwxr-xr-x  1 root root  34M Dec 27 19:27 vmlinux
-rw-r--r--  1 root root  29M Dec 27 19:27 vmlinux.o
localhost /usr/src/linux-4.12.12-gentoo #

localhost /usr/src/linux-4.12.12-gentoo # uname -a
Linux localhost 4.12.12-gentoo #10 SMP Wed Dec 27 19:27:43 CST 2017 x86_64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz GenuineIntel GNU/Linux

Mod edit: [code] tags added for readability. — JRG
_________________
<h5>Checkout <em>#grandmasboy</em> on <em>freenode</em>...chat with jayP bot from the movie!</h5>
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10387
Location: Somewhere over Atlanta, Georgia

PostPosted: Fri Apr 20, 2018 12:51 am    Post subject: Reply with quote

Probably your running kernel's source is no longer installed. Check with
Code:
equery list -i gentoo-sources
(which is part of app-portage/gentoolkit, by the way). Report back with results.

Problem is, your running kernel is no longer in the Portage tree. You feel up to transferring your kernel .config and rebuilding with new source? Or would you like some suggestions?

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
dman777
l33t
l33t


Joined: 10 Jan 2007
Posts: 982

PostPosted: Fri Apr 20, 2018 1:00 am    Post subject: Reply with quote

Code:

localhost /home/one # equery list -i gentoo-sources
 * Searching for gentoo-sources ...
[IP-] [  ] sys-kernel/gentoo-sources-4.9.76-r1:4.9.76-r1
localhost /home/one #



Why is the directory showing 4.12.12 with all the files?
_________________
<h5>Checkout <em>#grandmasboy</em> on <em>freenode</em>...chat with jayP bot from the movie!</h5>
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14386

PostPosted: Fri Apr 20, 2018 1:38 am    Post subject: Reply with quote

It isn't. None of those files are installed by sys-kernel/gentoo-sources. That output confirms JRG's suspicion. The shown files are all artifacts of building the kernel as root using an in-source build. Although easiest, that's rarely the best idea. Among other reasons, it leads to exactly this situation, where the sources have been removed, you did not remove the build artifacts, and the directory persists despite being orphaned.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3305
Location: Illinois, USA

PostPosted: Fri Apr 20, 2018 2:13 am    Post subject: Reply with quote

I recently wrote a script to do the post-depclean residue of the kernels.
Warning: use at your own risk.
Also, perhaps one of our script wizards could clean it up, if needed.
Code:
 $ cat /usr/local/sbin/cleankernels
#!/bin/bash

remove_old_kernel()
{
   echo $1 "wasn't installed"
#isolate kernel unique identifier
   num=$(echo ${1} | cut -f2 -d-) # isolate field 2 with delimiter "-"
   rm -r /usr/src/linux-${num}-gentoo ;
   rm -r /lib/modules/${num}-gentoo ;
   rm /boot/*-${num}-* ;
}

is_installed()
{
#   echo -n "${1}"
   for k in $(eselect --brief kernel list) ; do
      if [ "$k" == "$1" ]; then
#         echo  " is installed"
         return 0;  #true
      fi
   done
#   echo " is not installed"
   return 1; #false
}

## Main program
for i in $(ls /usr/src); do
   if [[ "${i}" == linux-4.* ]]; then
   if ! is_installed ${i}  ; then
      echo "removing uninstalled kernel " ${i}
      remove_old_kernel ${i}
   else
      echo $i "is installed - OK"
   fi
   fi
done

exit 0
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14386

PostPosted: Fri Apr 20, 2018 4:07 am    Post subject: Reply with quote

Personally, I use $KBUILD_OUTPUT so that all the build artifacts go to a separate structure, which I can them rm -r to wipe all trace. This also lets me run the build as an unprivileged user.

As for your script, you could replace the call to eselect kernel list by open-coding the relatively simple rule it uses to identify installed kernels: the presence of both Makefile and Kconfig as files in the top level of the candidate directory.

The below is based on the script Tony posted, but mine is completely untested. Further, users are advised to read and adapt to the big banner comment.
Code:
#!/bin/bash

set -e
cd /usr/src/
find . -maxdepth 1 -type d -name 'linux-4.*' -printf '%P\0' | while read -d '' i; do
   if [[ -f "$i/Makefile" && -f "$i/Kconfig" ]]; then   # kernel is installed
      echo "Found installed kernel directory $i"
   else
      echo "Removing artifacts associated with uninstalled kernel directory $i"
      # Remove the build directory
      rm -r "$i"
      # Removal of installed files should be here, but there are a few
      # problems:
      # - First, if the user set `CONFIG_LOCALVERSION` or
      # `CONFIG_LOCALVERSION_AUTO`, the target files have a suffix
      # that is inconvenient to derive here.
      # - Second, as a safety measure, we should not delete even an
      # uninstalled kernel if it is the default boot kernel.
      # - Third, while we can count on /lib/modules/ to be available,
      # we cannot generally assume /boot/ is mounted.  In extreme
      # cases (or when using some UEFI loaders), we cannot even assume
      # that the user uses /boot/ as the mountpoint for the filesystem
      # that holds bootable kernels.
      #
      # Due to these issues, users should replace the below no-op
      # statement with removals appropriate to the local environment.
      true
   fi
done
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7197

PostPosted: Fri Apr 20, 2018 11:20 am    Post subject: Reply with quote

Tony0945 wrote:

num=$(echo ${1} | cut -f2 -d-) # isolate field 2 with delimiter "-"
rm -r /usr/src/linux-${num}-gentoo ;

linux-4.12.3-gentoo is install
linux-4.12.3 is not
-> say goodbye to linux-4.12.3-gentoo :D
better going with cut -f2-
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Fri Apr 20, 2018 12:09 pm    Post subject: Reply with quote

Tony0945 ... some general comments in addition to the suggestions made by Hu.

Tony0945 wrote:
Code:
   num=$(echo ${1} | cut -f2 -d-) # isolate field 2 with delimiter "-"
   rm -r /usr/src/linux-${num}-gentoo ;
   rm -r /lib/modules/${num}-gentoo ;
   rm /boot/*-${num}-* ;

Bash provides parameter expansion for such cases ... so having $var you can get the parts of the string you need ... for example:

test:
#!/bin/bash
cd /usr/src/
for k in linux-*
do
    echo ${k}
    echo ${k:6}
    string=${k%-*}
    echo ${string#*-}
done

Code:
% bash ./test
linux-3.12.72-ck
3.12.72-ck
3.12.72
linux-4.16_p1-pf
4.16_p1-pf
4.16_p1

Tony0945 wrote:
Code:
for i in $(ls /usr/src); do

You don't need a substitution there 'for i in /usr/src/linux-*' will work perfectly fine.

HTH & best ... khay
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3305
Location: Illinois, USA

PostPosted: Fri Apr 20, 2018 1:13 pm    Post subject: Reply with quote

I knew it could be improved. I'm very much a tyro at shell. Thanks to all. I didn't mean to hijack the thread but that problem of portage leaving detritus behind has bugged me for a long time. I maintain three kernels all the time. At the present time, the tips of 4.14, 4.9 and 4.4
This wasn't a problem to maintain manually until all of them began changing weekly and I started accidentally removing parts of installed kernels.

dman777,
Was this a help or a distraction?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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