public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] RFC: kernel-2.eclass Prefix support
@ 2016-06-11 15:02 Benda Xu
  2016-06-11 15:15 ` Zac Medico
  2016-06-12  1:19 ` [gentoo-dev] " Göktürk Yüksek
  0 siblings, 2 replies; 14+ messages in thread
From: Benda Xu @ 2016-06-11 15:02 UTC (permalink / raw
  To: gentoo-dev

Hi Fellows,

This is a trivial patch for kernel-2.eclass to support Prefix.  Does it
look good to be commited?

Thanks,
Benda

Bug: 478436
--- kernel-2.eclass	2016-02-17 22:46:25.235543840 +0900
+++ kernel-2.eclass	2016-05-24 01:14:22.246809021 +0900
@@ -539,8 +522,8 @@
 #==============================================================
 kernel_header_destdir() {
 	[[ ${CTARGET} == ${CHOST} ]] \
-		&& echo /usr/include \
-		|| echo /usr/${CTARGET}/usr/include
+		&& echo "${EPREFIX}"/usr/include \
+		|| echo "${EPREFIX}"/usr/${CTARGET}/usr/include
 }
 
 cross_pre_c_headers() {
@@ -667,7 +650,7 @@
 
 		# autoconf.h isnt generated unless it already exists. plus, we have
 		# no guarantee that any headers are installed on the system...
-		[[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
+		[[ -f ${EROOT}/usr/include/linux/autoconf.h ]] \
 			|| touch include/linux/autoconf.h
 
 		# if K_DEFCONFIG isn't set, force to "defconfig"
@@ -741,15 +724,15 @@
 	# Do not use "linux/*" as that can cause problems with very long
 	# $S values where the cmdline to cp is too long
 	pushd "${S}" >/dev/null
-	dodir ${ddir}/linux
+	dodir ${ddir#${EPREFIX}}/linux
 	cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
 	rm -rf "${D}"/${ddir}/linux/modules
 
-	dodir ${ddir}/asm
-	cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
+	dodir ${ddir#${EPREFIX}}/asm
+	cp -pPR "${S}"/include/asm/* "${ED}"/${ddir}/asm
 
 	if kernel_is 2 6 ; then
-		dodir ${ddir}/asm-generic
+		dodir ${ddir#${EPREFIX}}/asm-generic
 		cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
 	fi
 
@@ -784,7 +767,7 @@
 			> "${S}"/patches.txt
 	fi
 
-	mv ${WORKDIR}/linux* "${D}"/usr/src
+	mv ${WORKDIR}/linux* "${ED}"/usr/src
 
 	if [[ -n "${UNIPATCH_DOCS}" ]] ; then
 		for i in ${UNIPATCH_DOCS}; do
@@ -819,22 +799,22 @@
 
 	# if we are to forcably symlink, delete it if it already exists first.
 	if [[ ${K_SYMLINK} > 0 ]]; then
-		[[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
+		[[ -h ${EROOT}usr/src/linux ]] && rm ${EROOT}usr/src/linux
 		MAKELINK=1
 	fi
 
 	# if the link doesnt exist, lets create it
-	[[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
+	[[ ! -h ${EROOT}usr/src/linux ]] && MAKELINK=1
 
 	if [[ ${MAKELINK} == 1 ]]; then
-		cd "${ROOT}"usr/src
+		cd "${EROOT}"usr/src
 		ln -sf linux-${KV_FULL} linux
 		cd ${OLDPWD}
 	fi
 
 	# Don't forget to make directory for sysfs
-	[[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
+	[[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && mkdir ${EROOT}sys
 
 	echo
 	elog "If you are upgrading from a previous kernel, you may be interested"
 	elog "in the following document:"
@@ -1353,11 +1310,11 @@
 	[[ ${ETYPE} == headers ]] && return 0
 
 	# If there isn't anything left behind, then don't complain.
-	[[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0
+	[[ -e ${EROOT}usr/src/linux-${KV_FULL} ]] || return 0
 	echo
 	ewarn "Note: Even though you have successfully unmerged "
 	ewarn "your kernel package, directories in kernel source location: "
-	ewarn "${ROOT}usr/src/linux-${KV_FULL}"
+	ewarn "${EROOT}usr/src/linux-${KV_FULL}"
 	ewarn "with modified files will remain behind. By design, package managers"
 	ewarn "will not remove these modified files and the directories they reside in."
 	echo


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-dev] RFC: kernel-2.eclass Prefix support
  2016-06-11 15:02 [gentoo-dev] RFC: kernel-2.eclass Prefix support Benda Xu
@ 2016-06-11 15:15 ` Zac Medico
  2016-06-12  2:54   ` [gentoo-dev] " Benda Xu
  2016-06-12  1:19 ` [gentoo-dev] " Göktürk Yüksek
  1 sibling, 1 reply; 14+ messages in thread
From: Zac Medico @ 2016-06-11 15:15 UTC (permalink / raw
  To: gentoo-dev

On 06/11/2016 08:02 AM, Benda Xu wrote:
> Hi Fellows,
> 
> This is a trivial patch for kernel-2.eclass to support Prefix.  Does it
> look good to be commited?

The EPREFIX and EROOT variables are undefined prior to EAPI 3, so the
eclass should die if the EAPI is 0, 1, or 2.
-- 
Thanks,
Zac


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-dev] RFC: kernel-2.eclass Prefix support
  2016-06-11 15:02 [gentoo-dev] RFC: kernel-2.eclass Prefix support Benda Xu
  2016-06-11 15:15 ` Zac Medico
@ 2016-06-12  1:19 ` Göktürk Yüksek
  1 sibling, 0 replies; 14+ messages in thread
From: Göktürk Yüksek @ 2016-06-12  1:19 UTC (permalink / raw
  To: gentoo-dev

Benda Xu:
> Hi Fellows,
> 
> This is a trivial patch for kernel-2.eclass to support Prefix.  Does it
> look good to be commited?
> 
> Thanks,
> Benda
> 
> Bug: 478436
> --- kernel-2.eclass	2016-02-17 22:46:25.235543840 +0900
> +++ kernel-2.eclass	2016-05-24 01:14:22.246809021 +0900
> @@ -539,8 +522,8 @@
>  #==============================================================
>  kernel_header_destdir() {
>  	[[ ${CTARGET} == ${CHOST} ]] \
> -		&& echo /usr/include \
> -		|| echo /usr/${CTARGET}/usr/include
> +		&& echo "${EPREFIX}"/usr/include \
> +		|| echo "${EPREFIX}"/usr/${CTARGET}/usr/include
>  }
>  
>  cross_pre_c_headers() {
> @@ -667,7 +650,7 @@
>  
>  		# autoconf.h isnt generated unless it already exists. plus, we have
>  		# no guarantee that any headers are installed on the system...
> -		[[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
> +		[[ -f ${EROOT}/usr/include/linux/autoconf.h ]] \
EROOT already ends with a trailing slash.

Also there are inconsistencies in the rest of the patch w.r.t. quoting
EROOT and EPREFIX.

>  			|| touch include/linux/autoconf.h
>  
>  		# if K_DEFCONFIG isn't set, force to "defconfig"
> @@ -741,15 +724,15 @@
>  	# Do not use "linux/*" as that can cause problems with very long
>  	# $S values where the cmdline to cp is too long
>  	pushd "${S}" >/dev/null
> -	dodir ${ddir}/linux
> +	dodir ${ddir#${EPREFIX}}/linux
>  	cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
>  	rm -rf "${D}"/${ddir}/linux/modules
>  
> -	dodir ${ddir}/asm
> -	cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
> +	dodir ${ddir#${EPREFIX}}/asm
> +	cp -pPR "${S}"/include/asm/* "${ED}"/${ddir}/asm
>  
>  	if kernel_is 2 6 ; then
> -		dodir ${ddir}/asm-generic
> +		dodir ${ddir#${EPREFIX}}/asm-generic
>  		cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
>  	fi
>  
> @@ -784,7 +767,7 @@
>  			> "${S}"/patches.txt
>  	fi
>  
> -	mv ${WORKDIR}/linux* "${D}"/usr/src
> +	mv ${WORKDIR}/linux* "${ED}"/usr/src
>  
>  	if [[ -n "${UNIPATCH_DOCS}" ]] ; then
>  		for i in ${UNIPATCH_DOCS}; do
> @@ -819,22 +799,22 @@
>  
>  	# if we are to forcably symlink, delete it if it already exists first.
>  	if [[ ${K_SYMLINK} > 0 ]]; then
> -		[[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
> +		[[ -h ${EROOT}usr/src/linux ]] && rm ${EROOT}usr/src/linux
>  		MAKELINK=1
>  	fi
>  
>  	# if the link doesnt exist, lets create it
> -	[[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
> +	[[ ! -h ${EROOT}usr/src/linux ]] && MAKELINK=1
>  
>  	if [[ ${MAKELINK} == 1 ]]; then
> -		cd "${ROOT}"usr/src
> +		cd "${EROOT}"usr/src
>  		ln -sf linux-${KV_FULL} linux
>  		cd ${OLDPWD}
>  	fi
>  
>  	# Don't forget to make directory for sysfs
> -	[[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
> +	[[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && mkdir ${EROOT}sys
>  
>  	echo
>  	elog "If you are upgrading from a previous kernel, you may be interested"
>  	elog "in the following document:"
> @@ -1353,11 +1310,11 @@
>  	[[ ${ETYPE} == headers ]] && return 0
>  
>  	# If there isn't anything left behind, then don't complain.
> -	[[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0
> +	[[ -e ${EROOT}usr/src/linux-${KV_FULL} ]] || return 0
>  	echo
>  	ewarn "Note: Even though you have successfully unmerged "
>  	ewarn "your kernel package, directories in kernel source location: "
> -	ewarn "${ROOT}usr/src/linux-${KV_FULL}"
> +	ewarn "${EROOT}usr/src/linux-${KV_FULL}"
>  	ewarn "with modified files will remain behind. By design, package managers"
>  	ewarn "will not remove these modified files and the directories they reside in."
>  	echo
> 



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support
  2016-06-11 15:15 ` Zac Medico
@ 2016-06-12  2:54   ` Benda Xu
  2016-06-12  5:01     ` Ulrich Mueller
  0 siblings, 1 reply; 14+ messages in thread
From: Benda Xu @ 2016-06-12  2:54 UTC (permalink / raw
  To: gentoo-dev

Thanks Zac, Göktürk,

I have added EPREFIX logics for EAPI<3 and improved the trailing slashes
and quotes.

Benda

--- kernel-2.eclass	2016-02-17 22:46:25.235543840 +0900
+++ kernel-2.eclass	2016-06-12 11:48:19.843801138 +0900
@@ -105,6 +105,8 @@
 HOMEPAGE="https://www.kernel.org/ https://www.gentoo.org/ ${HOMEPAGE}"
 : ${LICENSE:="GPL-2"}
 
+has "${EAPI:-0}" 0 1 2 && ED=${D} EPREFIX= EROOT=${ROOT}
+
 # This is the latest KV_PATCH of the deblob tool available from the
 # libre-sources upstream. If you bump this, you MUST regenerate the Manifests
 # for ALL kernel-2 consumer packages where deblob is available.
@@ -667,7 +669,7 @@
 
 		# autoconf.h isnt generated unless it already exists. plus, we have
 		# no guarantee that any headers are installed on the system...
-		[[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
+		[[ -f "${EROOT}"usr/include/linux/autoconf.h ]] \
 			|| touch include/linux/autoconf.h
 
 		# if K_DEFCONFIG isn't set, force to "defconfig"
@@ -731,10 +733,10 @@
 	# of this crap anymore :D
 	if kernel_is ge 2 6 18 ; then
 		env_setup_xmakeopts
-		emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
+		emake headers_install INSTALL_HDR_PATH="${ED}"${ddir}/.. ${xmakeopts} || die
 
 		# let other packages install some of these headers
-		rm -rf "${D}"/${ddir}/scsi  #glibc/uclibc/etc...
+		rm -rf "${ED}"${ddir}/scsi  #glibc/uclibc/etc...
 		return 0
 	fi
 
@@ -742,15 +744,15 @@
 	# $S values where the cmdline to cp is too long
 	pushd "${S}" >/dev/null
 	dodir ${ddir}/linux
-	cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
-	rm -rf "${D}"/${ddir}/linux/modules
+	cp -pPR "${S}"/include/linux "${ED}"${ddir}/ || die
+	rm -rf "${ED}"${ddir}/linux/modules
 
 	dodir ${ddir}/asm
-	cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
+	cp -pPR "${S}"/include/asm/* "${ED}"${ddir}/asm
 
 	if kernel_is 2 6 ; then
 		dodir ${ddir}/asm-generic
-		cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
+		cp -pPR "${S}"/include/asm-generic/* "${ED}"${ddir}/asm-generic
 	fi
 
 	# clean up
@@ -784,7 +786,7 @@
 			> "${S}"/patches.txt
 	fi
 
-	mv ${WORKDIR}/linux* "${D}"/usr/src
+	mv ${WORKDIR}/linux* "${ED}"usr/src
 
 	if [[ -n "${UNIPATCH_DOCS}" ]] ; then
 		for i in ${UNIPATCH_DOCS}; do
@@ -797,8 +799,8 @@
 #==============================================================
 preinst_headers() {
 	local ddir=$(kernel_header_destdir)
-	[[ -L ${ddir}/linux ]] && rm ${ddir}/linux
-	[[ -L ${ddir}/asm ]] && rm ${ddir}/asm
+	[[ -L "${EPREFIX}"${ddir}/linux ]] && rm "${EPREFIX}"${ddir}/linux
+	[[ -L "${EPREFIX}"${ddir}/asm ]] && rm "${EPREFIX}"${ddir}/asm
 }
 
 # pkg_postinst functions
@@ -819,21 +821,21 @@
 
 	# if we are to forcably symlink, delete it if it already exists first.
 	if [[ ${K_SYMLINK} > 0 ]]; then
-		[[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
+		[[ -h "${EROOT}"usr/src/linux ]] && rm "${EROOT}"usr/src/linux
 		MAKELINK=1
 	fi
 
 	# if the link doesnt exist, lets create it
-	[[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
+	[[ ! -h "${EROOT}"usr/src/linux ]] && MAKELINK=1
 
 	if [[ ${MAKELINK} == 1 ]]; then
-		cd "${ROOT}"usr/src
+		cd "${EROOT}"usr/src
 		ln -sf linux-${KV_FULL} linux
 		cd ${OLDPWD}
 	fi
 
 	# Don't forget to make directory for sysfs
-	[[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
+	[[ ! -d "${EROOT}"sys ]] && kernel_is 2 6 && mkdir "${EROOT}"sys
 
 	echo
 	elog "If you are upgrading from a previous kernel, you may be interested"
@@ -1353,11 +1355,11 @@
 	[[ ${ETYPE} == headers ]] && return 0
 
 	# If there isn't anything left behind, then don't complain.
-	[[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0
+	[[ -e "${EROOT}"usr/src/linux-${KV_FULL} ]] || return 0
 	echo
 	ewarn "Note: Even though you have successfully unmerged "
 	ewarn "your kernel package, directories in kernel source location: "
-	ewarn "${ROOT}usr/src/linux-${KV_FULL}"
+	ewarn "${EROOT}usr/src/linux-${KV_FULL}"
 	ewarn "with modified files will remain behind. By design, package managers"
 	ewarn "will not remove these modified files and the directories they reside in."
 	echo


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support
  2016-06-12  2:54   ` [gentoo-dev] " Benda Xu
@ 2016-06-12  5:01     ` Ulrich Mueller
  2016-06-12  9:02       ` Benda Xu
  0 siblings, 1 reply; 14+ messages in thread
From: Ulrich Mueller @ 2016-06-12  5:01 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 504 bytes --]

>>>>> On Sun, 12 Jun 2016, Benda Xu wrote:

> I have added EPREFIX logics for EAPI<3 and improved the trailing
> slashes and quotes.

> -		[[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
> +		[[ -f "${EROOT}"usr/include/linux/autoconf.h ]] \

Inside [[ ]] quotes are generally not needed. (There are several other
instances of this.)

> -	mv ${WORKDIR}/linux* "${D}"/usr/src
> +	mv ${WORKDIR}/linux* "${ED}"usr/src

It was like that before your patch, but still ${WORKDIR} should be
quoted here.

Ulrich

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support
  2016-06-12  5:01     ` Ulrich Mueller
@ 2016-06-12  9:02       ` Benda Xu
  2016-06-12  9:07         ` Zac Medico
  2016-06-12  9:29         ` Ulrich Mueller
  0 siblings, 2 replies; 14+ messages in thread
From: Benda Xu @ 2016-06-12  9:02 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 5262 bytes --]

Hi Ulrich,

Ulrich Mueller <ulm@gentoo.org> writes:

>> I have added EPREFIX logics for EAPI<3 and improved the trailing
>> slashes and quotes.
>
>> -		[[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
>> +		[[ -f "${EROOT}"usr/include/linux/autoconf.h ]] \
>
> Inside [[ ]] quotes are generally not needed. (There are several other
> instances of this.)

I thought so too, but with an experiment:

bash --version
GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)

bash -l
$ [[ -f a b ]] && echo hi
bash: syntax error in conditional expression
bash: syntax error near `b'
$ [[ -f "a b" ]] && echo hi
hi

So it seems that [[ ]] does need quotes.

>> -	mv ${WORKDIR}/linux* "${D}"/usr/src
>> +	mv ${WORKDIR}/linux* "${ED}"usr/src
>
> It was like that before your patch, but still ${WORKDIR} should be
> quoted here.

Yeah, updated.

Benda

--- /home/heroxbd/dev/repo/eclass/kernel-2.eclass	2016-02-17 22:46:25.235543840 +0900
+++ kernel-2.eclass	2016-06-12 17:58:55.971551222 +0900
@@ -105,6 +105,8 @@
 HOMEPAGE="https://www.kernel.org/ https://www.gentoo.org/ ${HOMEPAGE}"
 : ${LICENSE:="GPL-2"}
 
+has "${EAPI:-0}" 0 1 2 && ED=${D} EPREFIX= EROOT=${ROOT}
+
 # This is the latest KV_PATCH of the deblob tool available from the
 # libre-sources upstream. If you bump this, you MUST regenerate the Manifests
 # for ALL kernel-2 consumer packages where deblob is available.
@@ -345,7 +347,7 @@
 	KV_FULL=${OKV}${EXTRAVERSION}
 
 	# we will set this for backwards compatibility.
-	S=${WORKDIR}/linux-${KV_FULL}
+	S="${WORKDIR}"/linux-${KV_FULL}
 	KV=${KV_FULL}
 
 	# -rc-git pulls can be achieved by specifying CKV
@@ -667,7 +669,7 @@
 
 		# autoconf.h isnt generated unless it already exists. plus, we have
 		# no guarantee that any headers are installed on the system...
-		[[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
+		[[ -f "${EROOT}"usr/include/linux/autoconf.h ]] \
 			|| touch include/linux/autoconf.h
 
 		# if K_DEFCONFIG isn't set, force to "defconfig"
@@ -731,10 +733,10 @@
 	# of this crap anymore :D
 	if kernel_is ge 2 6 18 ; then
 		env_setup_xmakeopts
-		emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
+		emake headers_install INSTALL_HDR_PATH="${ED}"${ddir}/.. ${xmakeopts} || die
 
 		# let other packages install some of these headers
-		rm -rf "${D}"/${ddir}/scsi  #glibc/uclibc/etc...
+		rm -rf "${ED}"${ddir}/scsi  #glibc/uclibc/etc...
 		return 0
 	fi
 
@@ -742,15 +744,15 @@
 	# $S values where the cmdline to cp is too long
 	pushd "${S}" >/dev/null
 	dodir ${ddir}/linux
-	cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
-	rm -rf "${D}"/${ddir}/linux/modules
+	cp -pPR "${S}"/include/linux "${ED}"${ddir}/ || die
+	rm -rf "${ED}"${ddir}/linux/modules
 
 	dodir ${ddir}/asm
-	cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
+	cp -pPR "${S}"/include/asm/* "${ED}"${ddir}/asm
 
 	if kernel_is 2 6 ; then
 		dodir ${ddir}/asm-generic
-		cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
+		cp -pPR "${S}"/include/asm-generic/* "${ED}"${ddir}/asm-generic
 	fi
 
 	# clean up
@@ -784,7 +786,7 @@
 			> "${S}"/patches.txt
 	fi
 
-	mv ${WORKDIR}/linux* "${D}"/usr/src
+	mv "${WORKDIR}"/linux* "${ED}"usr/src
 
 	if [[ -n "${UNIPATCH_DOCS}" ]] ; then
 		for i in ${UNIPATCH_DOCS}; do
@@ -797,8 +799,8 @@
 #==============================================================
 preinst_headers() {
 	local ddir=$(kernel_header_destdir)
-	[[ -L ${ddir}/linux ]] && rm ${ddir}/linux
-	[[ -L ${ddir}/asm ]] && rm ${ddir}/asm
+	[[ -L "${EPREFIX}"${ddir}/linux ]] && rm "${EPREFIX}"${ddir}/linux
+	[[ -L "${EPREFIX}"${ddir}/asm ]] && rm "${EPREFIX}"${ddir}/asm
 }
 
 # pkg_postinst functions
@@ -819,21 +821,21 @@
 
 	# if we are to forcably symlink, delete it if it already exists first.
 	if [[ ${K_SYMLINK} > 0 ]]; then
-		[[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
+		[[ -h "${EROOT}"usr/src/linux ]] && rm "${EROOT}"usr/src/linux
 		MAKELINK=1
 	fi
 
 	# if the link doesnt exist, lets create it
-	[[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
+	[[ ! -h "${EROOT}"usr/src/linux ]] && MAKELINK=1
 
 	if [[ ${MAKELINK} == 1 ]]; then
-		cd "${ROOT}"usr/src
+		cd "${EROOT}"usr/src
 		ln -sf linux-${KV_FULL} linux
 		cd ${OLDPWD}
 	fi
 
 	# Don't forget to make directory for sysfs
-	[[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
+	[[ ! -d "${EROOT}"sys ]] && kernel_is 2 6 && mkdir "${EROOT}"sys
 
 	echo
 	elog "If you are upgrading from a previous kernel, you may be interested"
@@ -1353,11 +1355,11 @@
 	[[ ${ETYPE} == headers ]] && return 0
 
 	# If there isn't anything left behind, then don't complain.
-	[[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0
+	[[ -e "${EROOT}"usr/src/linux-${KV_FULL} ]] || return 0
 	echo
 	ewarn "Note: Even though you have successfully unmerged "
 	ewarn "your kernel package, directories in kernel source location: "
-	ewarn "${ROOT}usr/src/linux-${KV_FULL}"
+	ewarn "${EROOT}usr/src/linux-${KV_FULL}"
 	ewarn "with modified files will remain behind. By design, package managers"
 	ewarn "will not remove these modified files and the directories they reside in."
 	echo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support
  2016-06-12  9:02       ` Benda Xu
@ 2016-06-12  9:07         ` Zac Medico
  2016-06-12  9:21           ` Benda Xu
  2016-06-12  9:29         ` Ulrich Mueller
  1 sibling, 1 reply; 14+ messages in thread
From: Zac Medico @ 2016-06-12  9:07 UTC (permalink / raw
  To: gentoo-dev

On 06/12/2016 02:02 AM, Benda Xu wrote:
> Hi Ulrich,
> 
> Ulrich Mueller <ulm@gentoo.org> writes:
> 
>>> I have added EPREFIX logics for EAPI<3 and improved the trailing
>>> slashes and quotes.
>>
>>> -		[[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
>>> +		[[ -f "${EROOT}"usr/include/linux/autoconf.h ]] \
>>
>> Inside [[ ]] quotes are generally not needed. (There are several other
>> instances of this.)
> 
> I thought so too, but with an experiment:
> 
> bash --version
> GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)
> 
> bash -l
> $ [[ -f a b ]] && echo hi
> bash: syntax error in conditional expression
> bash: syntax error near `b'
> $ [[ -f "a b" ]] && echo hi
> hi
> 
> So it seems that [[ ]] does need quotes.

However, it behaves differently when you have a variable with "a b" as
its content.

foo="a b"
[[ -f ${foo} ]] && echo hi
-- 
Thanks,
Zac


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support
  2016-06-12  9:07         ` Zac Medico
@ 2016-06-12  9:21           ` Benda Xu
  2016-06-12 12:21             ` Michael Orlitzky
  0 siblings, 1 reply; 14+ messages in thread
From: Benda Xu @ 2016-06-12  9:21 UTC (permalink / raw
  To: gentoo-dev

Zac Medico <zmedico@gentoo.org> writes:

> However, it behaves differently when you have a variable with "a b" as
> its content.
>
> foo="a b"
> [[ -f ${foo} ]] && echo hi

Yeah, that's correct.  My mistake.

--- kernel-2.eclass	2016-02-17 22:46:25.235543840 +0900
+++ kernel-2.eclass	2016-06-12 18:17:15.983538859 +0900
@@ -105,6 +105,8 @@
 HOMEPAGE="https://www.kernel.org/ https://www.gentoo.org/ ${HOMEPAGE}"
 : ${LICENSE:="GPL-2"}
 
+has "${EAPI:-0}" 0 1 2 && ED=${D} EPREFIX= EROOT=${ROOT}
+
 # This is the latest KV_PATCH of the deblob tool available from the
 # libre-sources upstream. If you bump this, you MUST regenerate the Manifests
 # for ALL kernel-2 consumer packages where deblob is available.
@@ -345,7 +347,7 @@
 	KV_FULL=${OKV}${EXTRAVERSION}
 
 	# we will set this for backwards compatibility.
-	S=${WORKDIR}/linux-${KV_FULL}
+	S="${WORKDIR}"/linux-${KV_FULL}
 	KV=${KV_FULL}
 
 	# -rc-git pulls can be achieved by specifying CKV
@@ -667,7 +669,7 @@
 
 		# autoconf.h isnt generated unless it already exists. plus, we have
 		# no guarantee that any headers are installed on the system...
-		[[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
+		[[ -f ${EROOT}usr/include/linux/autoconf.h ]] \
 			|| touch include/linux/autoconf.h
 
 		# if K_DEFCONFIG isn't set, force to "defconfig"
@@ -731,10 +733,10 @@
 	# of this crap anymore :D
 	if kernel_is ge 2 6 18 ; then
 		env_setup_xmakeopts
-		emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
+		emake headers_install INSTALL_HDR_PATH="${ED}"${ddir}/.. ${xmakeopts} || die
 
 		# let other packages install some of these headers
-		rm -rf "${D}"/${ddir}/scsi  #glibc/uclibc/etc...
+		rm -rf "${ED}"${ddir}/scsi  #glibc/uclibc/etc...
 		return 0
 	fi
 
@@ -742,15 +744,15 @@
 	# $S values where the cmdline to cp is too long
 	pushd "${S}" >/dev/null
 	dodir ${ddir}/linux
-	cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
-	rm -rf "${D}"/${ddir}/linux/modules
+	cp -pPR "${S}"/include/linux "${ED}"${ddir}/ || die
+	rm -rf "${ED}"${ddir}/linux/modules
 
 	dodir ${ddir}/asm
-	cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
+	cp -pPR "${S}"/include/asm/* "${ED}"${ddir}/asm
 
 	if kernel_is 2 6 ; then
 		dodir ${ddir}/asm-generic
-		cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
+		cp -pPR "${S}"/include/asm-generic/* "${ED}"${ddir}/asm-generic
 	fi
 
 	# clean up
@@ -784,7 +786,7 @@
 			> "${S}"/patches.txt
 	fi
 
-	mv ${WORKDIR}/linux* "${D}"/usr/src
+	mv "${WORKDIR}"/linux* "${ED}"usr/src
 
 	if [[ -n "${UNIPATCH_DOCS}" ]] ; then
 		for i in ${UNIPATCH_DOCS}; do
@@ -797,8 +799,8 @@
 #==============================================================
 preinst_headers() {
 	local ddir=$(kernel_header_destdir)
-	[[ -L ${ddir}/linux ]] && rm ${ddir}/linux
-	[[ -L ${ddir}/asm ]] && rm ${ddir}/asm
+	[[ -L ${EPREFIX}${ddir}/linux ]] && rm "${EPREFIX}"${ddir}/linux
+	[[ -L ${EPREFIX}${ddir}/asm ]] && rm "${EPREFIX}"${ddir}/asm
 }
 
 # pkg_postinst functions
@@ -819,21 +821,21 @@
 
 	# if we are to forcably symlink, delete it if it already exists first.
 	if [[ ${K_SYMLINK} > 0 ]]; then
-		[[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
+		[[ -h ${EROOT}usr/src/linux ]] && rm "${EROOT}"usr/src/linux
 		MAKELINK=1
 	fi
 
 	# if the link doesnt exist, lets create it
-	[[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
+	[[ ! -h ${EROOT}usr/src/linux ]] && MAKELINK=1
 
 	if [[ ${MAKELINK} == 1 ]]; then
-		cd "${ROOT}"usr/src
+		cd "${EROOT}"usr/src
 		ln -sf linux-${KV_FULL} linux
 		cd ${OLDPWD}
 	fi
 
 	# Don't forget to make directory for sysfs
-	[[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
+	[[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && mkdir "${EROOT}"sys
 
 	echo
 	elog "If you are upgrading from a previous kernel, you may be interested"
@@ -1153,7 +1155,7 @@
 	local tmp
 	for x in ${KPATCH_DIR}; do
 		for i in ${UNIPATCH_DOCS}; do
-			if [[ -f "${x}/${i}" ]] ; then
+			if [[ -f ${x}/${i} ]] ; then
 				tmp="${tmp} ${i}"
 				cp -f "${x}/${i}" "${T}"/
 			fi
@@ -1353,11 +1355,11 @@
 	[[ ${ETYPE} == headers ]] && return 0
 
 	# If there isn't anything left behind, then don't complain.
-	[[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0
+	[[ -e ${EROOT}usr/src/linux-${KV_FULL} ]] || return 0
 	echo
 	ewarn "Note: Even though you have successfully unmerged "
 	ewarn "your kernel package, directories in kernel source location: "
-	ewarn "${ROOT}usr/src/linux-${KV_FULL}"
+	ewarn "${EROOT}usr/src/linux-${KV_FULL}"
 	ewarn "with modified files will remain behind. By design, package managers"
 	ewarn "will not remove these modified files and the directories they reside in."
 	echo


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support
  2016-06-12  9:02       ` Benda Xu
  2016-06-12  9:07         ` Zac Medico
@ 2016-06-12  9:29         ` Ulrich Mueller
  1 sibling, 0 replies; 14+ messages in thread
From: Ulrich Mueller @ 2016-06-12  9:29 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 661 bytes --]

>>>>> On Sun, 12 Jun 2016, Benda Xu wrote:

>> Inside [[ ]] quotes are generally not needed. (There are several other
>> instances of this.)

> I thought so too, but with an experiment:

> bash --version
> GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)

> bash -l
> $ [[ -f a b ]] && echo hi
> bash: syntax error in conditional expression
> bash: syntax error near `b'
> $ [[ -f "a b" ]] && echo hi
> hi

Wrong experiment, so you get wrong results. :)

$ foo="a b"
$ [[ -f ${foo} ]] && echo yes || echo no
no
$ touch "a b"
$ [[ -f ${foo} ]] && echo yes || echo no
yes

> So it seems that [[ ]] does need quotes.

I doesn't around a variable.

Ulrich

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support
  2016-06-12  9:21           ` Benda Xu
@ 2016-06-12 12:21             ` Michael Orlitzky
  2016-06-13  1:12               ` Benda Xu
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Orlitzky @ 2016-06-12 12:21 UTC (permalink / raw
  To: gentoo-dev

On 06/12/2016 05:21 AM, Benda Xu wrote:
>  		# let other packages install some of these headers
> -		rm -rf "${D}"/${ddir}/scsi  #glibc/uclibc/etc...
> +		rm -rf "${ED}"${ddir}/scsi  #glibc/uclibc/etc...

Every rm, cp, mv, mkdir, dodir, cd, etc. needs "|| die".



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support
  2016-06-12 12:21             ` Michael Orlitzky
@ 2016-06-13  1:12               ` Benda Xu
  2016-06-13  2:42                 ` Michael Orlitzky
  0 siblings, 1 reply; 14+ messages in thread
From: Benda Xu @ 2016-06-13  1:12 UTC (permalink / raw
  To: gentoo-dev

Michael Orlitzky <mjo@gentoo.org> writes:

> On 06/12/2016 05:21 AM, Benda Xu wrote:
>>  		# let other packages install some of these headers
>> -		rm -rf "${D}"/${ddir}/scsi  #glibc/uclibc/etc...
>> +		rm -rf "${ED}"${ddir}/scsi  #glibc/uclibc/etc...
>
> Every rm, cp, mv, mkdir, dodir, cd, etc. needs "|| die".

Thanks, updated.

--- kernel-2.eclass	2016-02-17 22:46:25.235543840 +0900
+++ kernel-2.eclass	2016-06-13 10:04:55.966899800 +0900
@@ -105,6 +105,8 @@
 HOMEPAGE="https://www.kernel.org/ https://www.gentoo.org/ ${HOMEPAGE}"
 : ${LICENSE:="GPL-2"}
 
+has "${EAPI:-0}" 0 1 2 && ED=${D} EPREFIX= EROOT=${ROOT}
+
 # This is the latest KV_PATCH of the deblob tool available from the
 # libre-sources upstream. If you bump this, you MUST regenerate the Manifests
 # for ALL kernel-2 consumer packages where deblob is available.
@@ -345,7 +347,7 @@
 	KV_FULL=${OKV}${EXTRAVERSION}
 
 	# we will set this for backwards compatibility.
-	S=${WORKDIR}/linux-${KV_FULL}
+	S="${WORKDIR}"/linux-${KV_FULL}
 	KV=${KV_FULL}
 
 	# -rc-git pulls can be achieved by specifying CKV
@@ -667,7 +669,7 @@
 
 		# autoconf.h isnt generated unless it already exists. plus, we have
 		# no guarantee that any headers are installed on the system...
-		[[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
+		[[ -f ${EROOT}usr/include/linux/autoconf.h ]] \
 			|| touch include/linux/autoconf.h
 
 		# if K_DEFCONFIG isn't set, force to "defconfig"
@@ -688,7 +690,7 @@
 		# symlink in /usr/include/, and make defconfig will fail, so we have
 		# to force an include path with $S.
 		HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
-		ln -sf asm-${KARCH} "${S}"/include/asm
+		ln -sf asm-${KARCH} "${S}"/include/asm || die
 		cross_pre_c_headers && return 0
 
 		make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})"
@@ -705,7 +707,7 @@
 	# .config based upon any info we may have
 	case ${CTARGET} in
 	sh*)
-		sed -i '/CONFIG_CPU_SH/d' .config
+		sed -i '/CONFIG_CPU_SH/d' .config || die
 		echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config
 		return 0;;
 	esac
@@ -731,10 +733,10 @@
 	# of this crap anymore :D
 	if kernel_is ge 2 6 18 ; then
 		env_setup_xmakeopts
-		emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
+		emake headers_install INSTALL_HDR_PATH="${ED}"${ddir}/.. ${xmakeopts} || die
 
 		# let other packages install some of these headers
-		rm -rf "${D}"/${ddir}/scsi  #glibc/uclibc/etc...
+		rm -rf "${ED}"${ddir}/scsi || die #glibc/uclibc/etc...
 		return 0
 	fi
 
@@ -742,15 +744,15 @@
 	# $S values where the cmdline to cp is too long
 	pushd "${S}" >/dev/null
 	dodir ${ddir}/linux
-	cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
-	rm -rf "${D}"/${ddir}/linux/modules
+	cp -pPR "${S}"/include/linux "${ED}"${ddir}/ || die
+	rm -rf "${ED}"${ddir}/linux/modules || die
 
 	dodir ${ddir}/asm
-	cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
+	cp -pPR "${S}"/include/asm/* "${ED}"${ddir}/asm || die
 
 	if kernel_is 2 6 ; then
 		dodir ${ddir}/asm-generic
-		cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
+		cp -pPR "${S}"/include/asm-generic/* "${ED}"${ddir}/asm-generic || die
 	fi
 
 	# clean up
@@ -784,7 +786,7 @@
 			> "${S}"/patches.txt
 	fi
 
-	mv ${WORKDIR}/linux* "${D}"/usr/src
+	mv "${WORKDIR}"/linux* "${ED}"usr/src || die
 
 	if [[ -n "${UNIPATCH_DOCS}" ]] ; then
 		for i in ${UNIPATCH_DOCS}; do
@@ -797,8 +799,8 @@
 #==============================================================
 preinst_headers() {
 	local ddir=$(kernel_header_destdir)
-	[[ -L ${ddir}/linux ]] && rm ${ddir}/linux
-	[[ -L ${ddir}/asm ]] && rm ${ddir}/asm
+	[[ -L ${EPREFIX}${ddir}/linux ]] && { rm "${EPREFIX}"${ddir}/linux || die; }
+	[[ -L ${EPREFIX}${ddir}/asm ]] && { rm "${EPREFIX}"${ddir}/asm || die; }
 }
 
 # pkg_postinst functions
@@ -819,21 +821,19 @@
 
 	# if we are to forcably symlink, delete it if it already exists first.
 	if [[ ${K_SYMLINK} > 0 ]]; then
-		[[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
+		[[ -h ${EROOT}usr/src/linux ]] && { rm "${EROOT}"usr/src/linux || die; }
 		MAKELINK=1
 	fi
 
 	# if the link doesnt exist, lets create it
-	[[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
+	[[ ! -h ${EROOT}usr/src/linux ]] && MAKELINK=1
 
 	if [[ ${MAKELINK} == 1 ]]; then
-		cd "${ROOT}"usr/src
-		ln -sf linux-${KV_FULL} linux
-		cd ${OLDPWD}
+		ln -sf linux-${KV_FULL} "${EROOT}"usr/src/linux || die
 	fi
 
 	# Don't forget to make directory for sysfs
-	[[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
+	[[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && mkdir "${EROOT}"sys
 
 	echo
 	elog "If you are upgrading from a previous kernel, you may be interested"
@@ -1095,7 +1095,7 @@
 					ebegin "Applying ${i/*\//} (-p1)"
 					if [ $(patch -p1 --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -le 2 ]; then
 						eend 0
-						rm ${STDERR_T}
+						rm ${STDERR_T} || die
 						break
 					else
 						eend 1
@@ -1119,7 +1119,7 @@
 					echo "=======================================================" >> ${STDERR_T}
 					if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
 						eend 0
-						rm ${STDERR_T}
+						rm ${STDERR_T} || die
 						break
 					else
 						eend 1
@@ -1153,9 +1153,9 @@
 	local tmp
 	for x in ${KPATCH_DIR}; do
 		for i in ${UNIPATCH_DOCS}; do
-			if [[ -f "${x}/${i}" ]] ; then
+			if [[ -f ${x}/${i} ]] ; then
 				tmp="${tmp} ${i}"
-				cp -f "${x}/${i}" "${T}"/
+				cp -f "${x}/${i}" "${T}"/ || die
 			fi
 		done
 	done
@@ -1353,11 +1353,11 @@
 	[[ ${ETYPE} == headers ]] && return 0
 
 	# If there isn't anything left behind, then don't complain.
-	[[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0
+	[[ -e ${EROOT}usr/src/linux-${KV_FULL} ]] || return 0
 	echo
 	ewarn "Note: Even though you have successfully unmerged "
 	ewarn "your kernel package, directories in kernel source location: "
-	ewarn "${ROOT}usr/src/linux-${KV_FULL}"
+	ewarn "${EROOT}usr/src/linux-${KV_FULL}"
 	ewarn "with modified files will remain behind. By design, package managers"
 	ewarn "will not remove these modified files and the directories they reside in."
 	echo




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support
  2016-06-13  1:12               ` Benda Xu
@ 2016-06-13  2:42                 ` Michael Orlitzky
  2016-06-13  3:32                   ` Jonathan Callen
  2016-06-13  8:25                   ` Benda Xu
  0 siblings, 2 replies; 14+ messages in thread
From: Michael Orlitzky @ 2016-06-13  2:42 UTC (permalink / raw
  To: gentoo-dev

On 06/12/2016 09:12 PM, Benda Xu wrote:
> Michael Orlitzky <mjo@gentoo.org> writes:
>>
>> Every rm, cp, mv, mkdir, dodir, cd, etc. needs "|| die".
> 
> Thanks, updated.
> 
> ...
>  
>  	# Don't forget to make directory for sysfs
> -	[[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
> +	[[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && mkdir "${EROOT}"sys
>  

One more =)




^ permalink raw reply	[flat|nested] 14+ messages in thread

* [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support
  2016-06-13  2:42                 ` Michael Orlitzky
@ 2016-06-13  3:32                   ` Jonathan Callen
  2016-06-13  8:25                   ` Benda Xu
  1 sibling, 0 replies; 14+ messages in thread
From: Jonathan Callen @ 2016-06-13  3:32 UTC (permalink / raw
  To: gentoo-dev


[-- Attachment #1.1: Type: text/plain, Size: 655 bytes --]

On 06/12/2016 10:42 PM, Michael Orlitzky wrote:
> On 06/12/2016 09:12 PM, Benda Xu wrote:
>> Michael Orlitzky <mjo@gentoo.org> writes:
>>>
>>> Every rm, cp, mv, mkdir, dodir, cd, etc. needs "|| die".
>>
>> Thanks, updated.
>>
>> ...
>>  
>>  	# Don't forget to make directory for sysfs
>> -	[[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
>> +	[[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && mkdir "${EROOT}"sys
>>  
> 
> One more =)
> 
> 
> 
> 

This one probably should also be guarded by a `if ! use prefix` or `if
[[ -z ${EPREFIX} ]]` (or whatever), as it doesn't make as much sense to
have a ${EPREFIX}/sys directory.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support
  2016-06-13  2:42                 ` Michael Orlitzky
  2016-06-13  3:32                   ` Jonathan Callen
@ 2016-06-13  8:25                   ` Benda Xu
  1 sibling, 0 replies; 14+ messages in thread
From: Benda Xu @ 2016-06-13  8:25 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 836 bytes --]

Michael Orlitzky <mjo@gentoo.org> writes:

>>  	# Don't forget to make directory for sysfs
>> -	[[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
>> +	[[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && mkdir "${EROOT}"sys
>>  
>
> One more =)

Nice catch!

Jonathan Callen <jcallen@gentoo.org> writes:

> This one probably should also be guarded by a `if ! use prefix` or `if
> [[ -z ${EPREFIX} ]]` (or whatever), as it doesn't make as much sense to
> have a ${EPREFIX}/sys directory.

It is not needed. The code is in postinst_sources(), which is called by

kernel-2_pkg_postinst() {
	[[ ${ETYPE} == sources ]] && postinst_sources
}

And linux-headers (which Prefix usually use) defines ETYPE=headers.

In rare cases, Prefix do have a chance to compile and install a kernel.
But then, EROOT/sys will also be needed.


Patch updated:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: kernel.patch --]
[-- Type: text/x-diff, Size: 5836 bytes --]

--- kernel-2.eclass	2016-02-17 22:46:25.235543840 +0900
+++ kernel-2.eclass	2016-06-13 17:17:17.594608238 +0900
@@ -105,6 +105,8 @@
 HOMEPAGE="https://www.kernel.org/ https://www.gentoo.org/ ${HOMEPAGE}"
 : ${LICENSE:="GPL-2"}
 
+has "${EAPI:-0}" 0 1 2 && ED=${D} EPREFIX= EROOT=${ROOT}
+
 # This is the latest KV_PATCH of the deblob tool available from the
 # libre-sources upstream. If you bump this, you MUST regenerate the Manifests
 # for ALL kernel-2 consumer packages where deblob is available.
@@ -345,7 +345,7 @@
 	KV_FULL=${OKV}${EXTRAVERSION}
 
 	# we will set this for backwards compatibility.
-	S=${WORKDIR}/linux-${KV_FULL}
+	S="${WORKDIR}"/linux-${KV_FULL}
 	KV=${KV_FULL}
 
 	# -rc-git pulls can be achieved by specifying CKV
@@ -667,7 +667,7 @@
 
 		# autoconf.h isnt generated unless it already exists. plus, we have
 		# no guarantee that any headers are installed on the system...
-		[[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
+		[[ -f ${EROOT}usr/include/linux/autoconf.h ]] \
 			|| touch include/linux/autoconf.h
 
 		# if K_DEFCONFIG isn't set, force to "defconfig"
@@ -688,7 +688,7 @@
 		# symlink in /usr/include/, and make defconfig will fail, so we have
 		# to force an include path with $S.
 		HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
-		ln -sf asm-${KARCH} "${S}"/include/asm
+		ln -sf asm-${KARCH} "${S}"/include/asm || die
 		cross_pre_c_headers && return 0
 
 		make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})"
@@ -705,7 +705,7 @@
 	# .config based upon any info we may have
 	case ${CTARGET} in
 	sh*)
-		sed -i '/CONFIG_CPU_SH/d' .config
+		sed -i '/CONFIG_CPU_SH/d' .config || die
 		echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config
 		return 0;;
 	esac
@@ -731,10 +731,10 @@
 	# of this crap anymore :D
 	if kernel_is ge 2 6 18 ; then
 		env_setup_xmakeopts
-		emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
+		emake headers_install INSTALL_HDR_PATH="${ED}"${ddir}/.. ${xmakeopts} || die
 
 		# let other packages install some of these headers
-		rm -rf "${D}"/${ddir}/scsi  #glibc/uclibc/etc...
+		rm -rf "${ED}"${ddir}/scsi || die #glibc/uclibc/etc...
 		return 0
 	fi
 
@@ -742,15 +742,15 @@
 	# $S values where the cmdline to cp is too long
 	pushd "${S}" >/dev/null
 	dodir ${ddir}/linux
-	cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
-	rm -rf "${D}"/${ddir}/linux/modules
+	cp -pPR "${S}"/include/linux "${ED}"${ddir}/ || die
+	rm -rf "${ED}"${ddir}/linux/modules || die
 
 	dodir ${ddir}/asm
-	cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
+	cp -pPR "${S}"/include/asm/* "${ED}"${ddir}/asm || die
 
 	if kernel_is 2 6 ; then
 		dodir ${ddir}/asm-generic
-		cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
+		cp -pPR "${S}"/include/asm-generic/* "${ED}"${ddir}/asm-generic || die
 	fi
 
 	# clean up
@@ -784,7 +784,7 @@
 			> "${S}"/patches.txt
 	fi
 
-	mv ${WORKDIR}/linux* "${D}"/usr/src
+	mv "${WORKDIR}"/linux* "${ED}"usr/src || die
 
 	if [[ -n "${UNIPATCH_DOCS}" ]] ; then
 		for i in ${UNIPATCH_DOCS}; do
@@ -797,8 +797,8 @@
 #==============================================================
 preinst_headers() {
 	local ddir=$(kernel_header_destdir)
-	[[ -L ${ddir}/linux ]] && rm ${ddir}/linux
-	[[ -L ${ddir}/asm ]] && rm ${ddir}/asm
+	[[ -L ${EPREFIX}${ddir}/linux ]] && { rm "${EPREFIX}"${ddir}/linux || die; }
+	[[ -L ${EPREFIX}${ddir}/asm ]] && { rm "${EPREFIX}"${ddir}/asm || die; }
 }
 
 # pkg_postinst functions
@@ -819,21 +819,19 @@
 
 	# if we are to forcably symlink, delete it if it already exists first.
 	if [[ ${K_SYMLINK} > 0 ]]; then
-		[[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
+		[[ -h ${EROOT}usr/src/linux ]] && { rm "${EROOT}"usr/src/linux || die; }
 		MAKELINK=1
 	fi
 
 	# if the link doesnt exist, lets create it
-	[[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
+	[[ ! -h ${EROOT}usr/src/linux ]] && MAKELINK=1
 
 	if [[ ${MAKELINK} == 1 ]]; then
-		cd "${ROOT}"usr/src
-		ln -sf linux-${KV_FULL} linux
-		cd ${OLDPWD}
+		ln -sf linux-${KV_FULL} "${EROOT}"usr/src/linux || die
 	fi
 
 	# Don't forget to make directory for sysfs
-	[[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
+	[[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && { mkdir "${EROOT}"sys || die; }
 
 	echo
 	elog "If you are upgrading from a previous kernel, you may be interested"
@@ -1095,7 +1095,7 @@
 					ebegin "Applying ${i/*\//} (-p1)"
 					if [ $(patch -p1 --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -le 2 ]; then
 						eend 0
-						rm ${STDERR_T}
+						rm ${STDERR_T} || die
 						break
 					else
 						eend 1
@@ -1119,7 +1119,7 @@
 					echo "=======================================================" >> ${STDERR_T}
 					if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
 						eend 0
-						rm ${STDERR_T}
+						rm ${STDERR_T} || die
 						break
 					else
 						eend 1
@@ -1153,9 +1153,9 @@
 	local tmp
 	for x in ${KPATCH_DIR}; do
 		for i in ${UNIPATCH_DOCS}; do
-			if [[ -f "${x}/${i}" ]] ; then
+			if [[ -f ${x}/${i} ]] ; then
 				tmp="${tmp} ${i}"
-				cp -f "${x}/${i}" "${T}"/
+				cp -f "${x}/${i}" "${T}"/ || die
 			fi
 		done
 	done
@@ -1353,11 +1353,11 @@
 	[[ ${ETYPE} == headers ]] && return 0
 
 	# If there isn't anything left behind, then don't complain.
-	[[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0
+	[[ -e ${EROOT}usr/src/linux-${KV_FULL} ]] || return 0
 	echo
 	ewarn "Note: Even though you have successfully unmerged "
 	ewarn "your kernel package, directories in kernel source location: "
-	ewarn "${ROOT}usr/src/linux-${KV_FULL}"
+	ewarn "${EROOT}usr/src/linux-${KV_FULL}"
 	ewarn "with modified files will remain behind. By design, package managers"
 	ewarn "will not remove these modified files and the directories they reside in."
 	echo

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-06-13  8:25 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-11 15:02 [gentoo-dev] RFC: kernel-2.eclass Prefix support Benda Xu
2016-06-11 15:15 ` Zac Medico
2016-06-12  2:54   ` [gentoo-dev] " Benda Xu
2016-06-12  5:01     ` Ulrich Mueller
2016-06-12  9:02       ` Benda Xu
2016-06-12  9:07         ` Zac Medico
2016-06-12  9:21           ` Benda Xu
2016-06-12 12:21             ` Michael Orlitzky
2016-06-13  1:12               ` Benda Xu
2016-06-13  2:42                 ` Michael Orlitzky
2016-06-13  3:32                   ` Jonathan Callen
2016-06-13  8:25                   ` Benda Xu
2016-06-12  9:29         ` Ulrich Mueller
2016-06-12  1:19 ` [gentoo-dev] " Göktürk Yüksek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox