The source code of official foundation Raspbian images
is scattered over few places :
source of the customised Linux kernel : http://www.github.com/raspberrypi/linux
source of most packages : use the apt-get source command
source of some modified packages : browse https://github.com/raspberrypi?tab=repositories
Don't forget that foundation images also ...
Installing the kernel headers
Your /etc/apt/sources.list.d/raspi.list is misconfigurated , you should have
deb http://archive.raspberrypi.org/debian/ buster main
(which provide the raspberrypi-kernel-headers package.)
instead of :
deb http://deb.debian.org/debian/ unstable main
(debian unstable repository, it will break your system if an apt-preferences ...
The script rpi-source extract the gcc version parsing /proc/version with :
gcc_ver_kernel = re.findall(r'\d\.\d\.\d', proc_version)
And use the first matching occurrence as the gcc release of the current kernel.
This works only if the kernel version doesn't match '\d.\d.\d' and gcc release does. It is correct till the kernel identification have almost one ...
When rpi-source is run and the source is installed, it says so and quits:
*** Kernel source already installed: /home/pi/linux-342abe67d0e1f12eae17562bfe7615143d2618d1
Deleting this directory, makes rpi-source unpack and prepare the source again:
$ rm -rf /home/pi/linux-342abe67d0e1f12eae17562bfe7615143d2618d1
The kernel headers are usually installed via the package manager apt. If you manually removed them then the package manager will still think you have them installed you need to reinstall.
do aptitude search linux-header lines beginning with i show install packages.
then sudo aptitude reinstall linux-header… probably just sudo aptitude reinstall linux-...