Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 481766 - freebsd-sources-9.2_rc1: When a version older than 9.2_rc1 is installed, file collisions occurs.
Summary: freebsd-sources-9.2_rc1: When a version older than 9.2_rc1 is installed, file...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: FreeBSD (show other bugs)
Hardware: All FreeBSD
: Normal enhancement (vote)
Assignee: Gentoo/BSD Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-20 15:50 UTC by Yuta SATOH
Modified: 2015-05-24 12:17 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
sample patch for freebsd-sources-9.2_rc1.ebuild (481766.patch,430 bytes, patch)
2013-08-20 15:57 UTC, Yuta SATOH
Details | Diff
patch (481766-new.patch,822 bytes, patch)
2013-08-21 16:52 UTC, Yuta SATOH
Details | Diff
patch for freebsd-sources-9.2.ebuild (481766-correct.patch,463 bytes, patch)
2013-11-20 14:49 UTC, Yuta SATOH
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuta SATOH 2013-08-20 15:50:27 UTC
When the old version is installed, I think following code not running properly.

pkg_preinst() {
        if [[ -L "${ROOT}/usr/src/sys" ]]; then
                einfo "/usr/src/sys is a symlink, removing it..."
                rm -f "${ROOT}/usr/src/sys"
        fi


Reproducible: Always

Steps to Reproduce:
1. emerge -C freebsd-sources
2. rm -rf /usr/src/*
3. emerge --nodeps =freebsd-sources-9.1-r3
4. ls -lha /usr/src
total 48
drwxr-xr-x   3 root  wheel   512B Aug 21 00:29 .
drwxr-xr-x  17 root  wheel   512B Aug 21 00:29 ..
lrwxr-xr-x   1 root  wheel     7B Aug 21 00:29 sys -> sys-9.1
drwxr-xr-x  57 root  wheel   1.0k Aug 21 00:29 sys-9.1

5. USE="-*" emerge =freebsd-sources-9.2_rc1

Detected file collision(s):

 *      /usr/src/sys/Makefile
 *      /usr/src/sys/amd64/Makefile
 *      /usr/src/sys/amd64/ia32/ia32_syscall.c
 *      /usr/src/sys/amd64/ia32/ia32_reg.c
<snip>
 *      /usr/src/sys/amd64/include/sigframe.h
 *      /usr/src/sys/amd64/include/stdarg.h
 *      /usr/src/sys/amd64/include/vmparam.h
 *
 * Package 'sys-freebsd/freebsd-sources-9.2_rc1' NOT merged due to file
 * collisions. If necessary, refer to your elog messages for the whole
 * content of the above message.
 *
 * The following package has failed to build or install:
Comment 1 Yuta SATOH 2013-08-20 15:57:31 UTC
Created attachment 356508 [details, diff]
sample patch for freebsd-sources-9.2_rc1.ebuild

Sample patch to detect the old version and BLOCK.

# USE="-*" emerge -pv =freebsd-sources-9.2_rc1

Calculating dependencies... done!
[ebuild  NS   #] sys-freebsd/freebsd-sources-9.2_rc1:0 [9.1-r3:9.1] USE="-build-generic -dtrace -profile" 0 kB
[blocks B      ] <sys-freebsd/freebsd-sources-9.2_rc1 ("<sys-freebsd/freebsd-sources-9.2_rc1" is blocking sys-freebsd/freebsd-sources-9.2_rc1)

Total: 1 package (1 in new slot), Size of downloads: 0 kB
Conflict: 1 block (1 unsatisfied)

 * Error: The above package list contains packages which cannot be
 * installed at the same time on the same system.

  (sys-freebsd/freebsd-sources-9.2_rc1::gentoo, ebuild scheduled for merge) pulled in by
    =freebsd-sources-9.2_rc1

  (sys-freebsd/freebsd-sources-9.1-r3::gentoo, installed) pulled in by
    sys-freebsd/freebsd-sources:9.1 required by @selected


For more information about Blocked Packages, please refer to the following
section of the Gentoo Linux x86 Handbook (architecture is irrelevant):

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?full=1#blocked

Howto Upgrade (I'll update the wiki in future.)
1. emerge -C '<sys-freebsd/freebsd-sources-9.2_rc1'
2. emerge sys-freebsd/freebsd-sources
Comment 2 Alexis Ballier gentoo-dev 2013-08-21 13:08:03 UTC
hmmm but why does that code fail ? imho this should be fixed instead
Comment 3 Yuta SATOH 2013-08-21 16:52:38 UTC
Created attachment 356612 [details, diff]
patch

When check symlink in src_install(), I noticed that to succeed it.
The new patch just moved.

Maybe, the cause is in the following order...

...
src_compile
src_test
src_install
pkg_preinst
...

FYI,
https://devmanual.gentoo.org/ebuild-writing/functions/index.html
Comment 4 Alexis Ballier gentoo-dev 2013-08-21 19:04:51 UTC
this will certainly not work since src_install is in the sandbox and not used for binary packages :/
Comment 5 Yuta SATOH 2013-08-21 21:04:52 UTC
(In reply to Alexis Ballier from comment #4)
> this will certainly not work since src_install is in the sandbox and not
> used for binary packages :/

thanks, I had forgot binpkg.
How about checking the symlink in both src_install and pkg_preinst ?

check_old_symlink(){
	if [[ -L "${ROOT}/usr/src/sys" ]]; then
		einfo "/usr/src/sys is a symlink, removing it..."
		rm -f "${ROOT}/usr/src/sys"
	fi
}

src_install() {
	# For FEATURES="-sandbox". fix file collisions bug 481766
	# Gentoo/FreeBSD doesn't support sandbox. Force set FEATURES="-sandbox" in profile.
	check_old_symlink
	...
}

pkg_preinst() {
	# For binary packages. It's not call src_install().
	check_old_symlink
	...
}
Comment 6 Alexis Ballier gentoo-dev 2013-08-21 21:09:22 UTC
you can't modify the filesystem at src_install, so its no good either


actually, since I've de-slotted fbsd-sources starting at 9.2 it makes sense to add the blocker you were suggesting at the beginning, but still the symlink will remain as you report and the files will end up in the wrong directory...
Comment 7 Yuta SATOH 2013-08-21 21:37:35 UTC
(In reply to Alexis Ballier from comment #6)
> you can't modify the filesystem at src_install, so its no good either
ok.

> actually, since I've de-slotted fbsd-sources starting at 9.2 it makes sense
> to add the blocker you were suggesting at the beginning, but still the
> symlink will remain as you report and the files will end up in the wrong
> directory...

Detects file collisions in src_install, then die.
If file collisions is not detected in the src_install, pkg_preinst is called correctly.
Yes. Symbolic link is removed!

Sorry to confuse you.


# emerge -C '<freebsd-sources-9.2_rc1'
# USE="-*" emerge =freebsd-sources-9.2_rc1
<snip>
>>> Installing (1 of 1) sys-freebsd/freebsd-sources-9.2_rc1
 * Removing /usr/lib/systemd
 * /usr/src/sys is a symlink, removing it...

>>> Recording sys-freebsd/freebsd-sources:0 in "world" favorites file...
# ls -lha /usr/src
total 64
drwxr-xr-x   4 root  wheel   512B Aug 22 06:23 .
drwxr-xr-x  17 root  wheel   512B Aug 22 06:18 ..
drwxr-xr-x  58 root  wheel   1.0k Aug 22 06:23 sys
drwxr-xr-x   3 root  wheel   1.0k Aug 22 06:20 sys-9.1
Comment 8 Yuta SATOH 2013-11-20 14:49:43 UTC
Created attachment 363662 [details, diff]
patch for freebsd-sources-9.2.ebuild

Correct patch. will remove the old version with SLOT automatically.
Comment 9 Yuta SATOH 2015-05-24 12:17:05 UTC
9.2 removed.