O 'update-alternatives --config' simplesmente usa 'ln' para criar hard links?

0

O update-alternatives --config simplesmente usa ln para criar links físicos? Por exemplo,

$ sudo update-alternatives --config javaws
There are 3 choices for the alternative javaws (providing /usr/bin/javaws).

  Selection    Path                                             Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/javaws   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/javaws   1061      manual mode
  2            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/javaws   1060      manual mode
  3            /usr/lib/jvm/jdk1.7.0_67/bin/javaws               1         manual mode

Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/jvm/jdk1.7.0_67/bin/javaws to provide /usr/bin/javaws (javaws) in manual mode.
    
por Tim 08.10.2014 / 00:00

1 resposta

1

Não são links físicos, mas links simbólicos / suaves:

$ stat /etc/alternatives/default.plymouth
File: ‘/etc/alternatives/default.plymouth’ -> ‘/lib/plymouth/themes/ubuntu-logo/ubuntu-logo-scale-2.plymouth’
  Size: 61          Blocks: 8          IO Block: 4096   symbolic link
Device: 801h/2049d  Inode: 174731      Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)

(Isso controla o tema mostrado durante a inicialização.)

update-alternatives usa o unlink e symlink chamadas do sistema:

$ sudo strace update-alternatives --config default.plymouth 
execve("/usr/bin/update-alternatives", ["update-alternatives", "--config", "default.plymouth"], [/* 18 vars */]) = 0
brk(0)                                  = 0x18c3000
...
write(1, "Press enter to keep the current "..., 69Press enter to keep the current choice[*], or type selection number: ) = 69
fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 17), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8d4c8a2000
read(0, 1
"1\n", 1024) 
...
unlink("/etc/alternatives/default.plymouth.dpkg-tmp") = -1 ENOENT (No such file or directory)
symlink("/lib/plymouth/themes/ubuntu-logo/ubuntu-logo-scale-2.plymouth", "/etc/alternatives/default.plymouth.dpkg-tmp") = 0
lstat("/lib/plymouth/themes/default.plymouth", {st_mode=S_IFLNK|0777, st_size=34, ...}) = 0
lstat("/lib/plymouth/themes/default.plymouth", {st_mode=S_IFLNK|0777, st_size=34, ...}) = 0
readlink("/lib/plymouth/themes/default.plymouth", "/etc/alternatives/default.plymou"..., 34) = 34
stat("/lib/plymouth/themes/ubuntu-logo/ubuntu-logo.grub", {st_mode=S_IFREG|0644, st_size=47, ...}) = 0
unlink("/etc/alternatives/default.plymouth.grub.dpkg-tmp") = -1 ENOENT (No such file or directory)
symlink("/lib/plymouth/themes/ubuntu-logo/ubuntu-logo.grub", 
...
exit_group(0)                           = ?
+++ exited with 0 +++

As alternativas são todas ligações realmente simbólicas, IIRC. Você poderia ligá-los manualmente, se desejar. O que update-alternatives faz é gerenciar o que esses links podem apontar, atribuindo prioridades e oferecendo opções.

Na verdade, o primeiro parágrafo da página do manual:

update-alternatives   creates,   removes,   maintains   and    displays
   information about the symbolic links comprising the Debian alternatives
   system.
    
por muru 08.10.2014 / 00:24