Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Symbolic copy of source directory? -- solved
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
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2569

PostPosted: Mon Feb 01, 2016 7:21 pm    Post subject: Symbolic copy of source directory? -- solved Reply with quote

Hi,

Trying to get back something I used years ago, can't find the command args that work.

When I'm building a kernel I copy the raw kernel sources (in this case hardened-sources) over to a work directory.

I used to do something like:
Code:
cp -rs linux-4.3.3-hardened-r4 linux-4.3.3-hardened-r4-k01

This would copy the directory structure to a new root folder, but each real file would be a symbolic link to the original, thereby saving space. I lost this some time back, and haven't done much about it because of plentiful disk space and not so many kernels. Now though I'm facing a single directory structure supporting the host and several VMs, each of which want a different kernel.

Right now when I do this, I get a bunch of:
Code:

cp: ‘linux-4.3.3-hardened-r4-k01/firmware/radeon/RV770_me.bin.ihex’: can make relative symbolic links only in current directory
cp: ‘linux-4.3.3-hardened-r4-k01/firmware/radeon/RV770_pfp.bin.ihex’: can make relative symbolic links only in current directory
cp: ‘linux-4.3.3-hardened-r4-k01/firmware/sb16/alaw_main.csp.ihex’: can make relative symbolic links only in current directory
cp: ‘linux-4.3.3-hardened-r4-k01/firmware/sb16/ima_adpcm_capture.csp.ihex’: can make relative symbolic links only in current directory
cp: ‘linux-4.3.3-hardened-r4-k01/firmware/sb16/ima_adpcm_init.csp.ihex’: can make relative symbolic links only in current directory
cp: ‘linux-4.3.3-hardened-r4-k01/firmware/sb16/ima_adpcm_playback.csp.ihex’: can make relative symbolic links only in current directory
cp: ‘linux-4.3.3-hardened-r4-k01/firmware/sb16/mulaw_main.csp.ihex’: can make relative symbolic links only in current directory
cp: ‘linux-4.3.3-hardened-r4-k01/firmware/sun/cassini.bin.ihex’: can make relative symbolic links only in current directory
cp: ‘linux-4.3.3-hardened-r4-k01/firmware/tehuti/bdx.bin.ihex’: can make relative symbolic links only in current directory
cp: ‘linux-4.3.3-hardened-r4-k01/firmware/ti_3410.fw.ihex’: can make relative symbolic links only in current directory


Anyone know this off-hand? It would be very helpful right now. I have 4.3g in /usr/src, and there's really no need for it IMO.


Last edited by 1clue on Mon Feb 01, 2016 7:41 pm; edited 1 time in total
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2569

PostPosted: Mon Feb 01, 2016 7:41 pm    Post subject: Reply with quote

I guess I worked around it by using an absolute path for the source directory.
Back to top
View user's profile Send private message
Syl20
l33t
l33t


Joined: 04 Aug 2005
Posts: 619
Location: France

PostPosted: Tue Feb 02, 2016 1:54 pm    Post subject: Reply with quote

Visibly, the source and the destination directories are on the same filesystem. So why not using hard links (cp -rl), instead of symbolic ones (cp -rs) ?
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2569

PostPosted: Tue Feb 02, 2016 4:35 pm    Post subject: Reply with quote

It may be a petty reason, but there is one.

I prefer the nature of the file (link/not link) to be obvious when I list the files. Hard links are by their nature difficult to determine that way.

I have in the past edited the linked files thinking they were for my current version of the source when in fact my changes altered other projects I had going. Not so much with kernel source, but with source in general.
Back to top
View user's profile Send private message
s4e8
Guru
Guru


Joined: 29 Jul 2006
Posts: 311

PostPosted: Wed Feb 03, 2016 11:20 am    Post subject: Reply with quote

Symlink a directory structure is "lndir" command, "emerge lndir" to get it.
To compile kernel out of source tree:
Code:

mkdir newdir
bash /path/to/kernel-source-tree/scripts/mkmakefile /path/to/kernel-source-tree newdir
cd newdir
make menuconfig
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2569

PostPosted: Wed Feb 03, 2016 4:13 pm    Post subject: Reply with quote

s4e8 wrote:
Symlink a directory structure is "lndir" command, "emerge lndir" to get it.
To compile kernel out of source tree:
Code:

mkdir newdir
bash /path/to/kernel-source-tree/scripts/mkmakefile /path/to/kernel-source-tree newdir
cd newdir
make menuconfig


This is awesome. Never imagined it, it's exactly what I'm after. Thanks!
Back to top
View user's profile Send private message
netfab
Veteran
Veteran


Joined: 03 Mar 2005
Posts: 1891
Location: 127.0.0.1

PostPosted: Wed Feb 03, 2016 5:18 pm    Post subject: Reply with quote

Quote:

Now though I'm facing a single directory structure supporting the host and several VMs, each of which want a different kernel.


If your goal is to compile the same kernel version using multiple different .config, you should try to use the in-kernel mechanism by using the KBUILD_OUTPUT env variable :

Change directory to your kernel tree :
Code:

 # cd /usr/src/linux


Prepare the build environment for your host, and compile the kernel :
Code:

 # mkdir build-host
 # export KBUILD_OUTPUT="/usr/src/linux/build-host"
 # cp /path/to/your/host/config ${KBUILD_OUTPUT}/.config
 # make

All generated files (including built kernel) will be in build-host/ subdirectory.

Prepare the build environment for your vm-1, and compile the kernel :
Code:

 # mkdir build-vm-1
 # export KBUILD_OUTPUT="/usr/src/linux/build-vm-1"
 # cp /path/to/your/vm-1/config ${KBUILD_OUTPUT}/.config
 # make

All generated files (including built kernel) will be in build-vm-1/ subdirectory.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3112

PostPosted: Wed Feb 03, 2016 8:06 pm    Post subject: Reply with quote

Quote:
cp -rs linux-4.3.3-hardened-r4 linux-4.3.3-hardened-r4-k01

How 'bout rsync?
Quote:
rsync -a --link-dest=/usr/src/linux/ /usr/src/linux/ /usr/src/newdir/

Has 2 advantages: it comes with gentoo by default, and it creates hard links (so you won't break your shadow copy when you delete the original).
The disadvantage is you must stay within a single filesystem (because hard links refer to files' inode and not to the name like softlinks do)

Code:
Quad src # du -hs linux/
1.3G   linux/
Quad src # du -hs linux/ newdir/
1.3G   linux/
18M   newdir/
Quad src # du -hs newdir/
1.3G   newdir/


I must say I like
Quote:

If your goal is to compile the same kernel version using multiple different .config, you should try to use the in-kernel mechanism by using the KBUILD_OUTPUT env variable :
though. Pretty much what I have been looking for :lol:
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2569

PostPosted: Wed Feb 03, 2016 9:31 pm    Post subject: Reply with quote

My real goal has been to have multiple kernels compiled from the same source without interfering with other kernels in any way.

I should have figured that the kernel development people would need this much more than I do and would have a fantastic mechanism already in place.

The mkmakefile process that s4e8 mentioned sounds best to me.

Thanks.
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