Gentoo Archives: gentoo-dev

From: Benda Xu <heroxbd@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support
Date: Mon, 13 Jun 2016 01:12:51
Message-Id: 8760tdhoxp.fsf@gentoo.org
In Reply to: Re: [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support by Michael Orlitzky
1 Michael Orlitzky <mjo@g.o> writes:
2
3 > On 06/12/2016 05:21 AM, Benda Xu wrote:
4 >> # let other packages install some of these headers
5 >> - rm -rf "${D}"/${ddir}/scsi #glibc/uclibc/etc...
6 >> + rm -rf "${ED}"${ddir}/scsi #glibc/uclibc/etc...
7 >
8 > Every rm, cp, mv, mkdir, dodir, cd, etc. needs "|| die".
9
10 Thanks, updated.
11
12 --- kernel-2.eclass 2016-02-17 22:46:25.235543840 +0900
13 +++ kernel-2.eclass 2016-06-13 10:04:55.966899800 +0900
14 @@ -105,6 +105,8 @@
15 HOMEPAGE="https://www.kernel.org/ https://www.gentoo.org/ ${HOMEPAGE}"
16 : ${LICENSE:="GPL-2"}
17
18 +has "${EAPI:-0}" 0 1 2 && ED=${D} EPREFIX= EROOT=${ROOT}
19 +
20 # This is the latest KV_PATCH of the deblob tool available from the
21 # libre-sources upstream. If you bump this, you MUST regenerate the Manifests
22 # for ALL kernel-2 consumer packages where deblob is available.
23 @@ -345,7 +347,7 @@
24 KV_FULL=${OKV}${EXTRAVERSION}
25
26 # we will set this for backwards compatibility.
27 - S=${WORKDIR}/linux-${KV_FULL}
28 + S="${WORKDIR}"/linux-${KV_FULL}
29 KV=${KV_FULL}
30
31 # -rc-git pulls can be achieved by specifying CKV
32 @@ -667,7 +669,7 @@
33
34 # autoconf.h isnt generated unless it already exists. plus, we have
35 # no guarantee that any headers are installed on the system...
36 - [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
37 + [[ -f ${EROOT}usr/include/linux/autoconf.h ]] \
38 || touch include/linux/autoconf.h
39
40 # if K_DEFCONFIG isn't set, force to "defconfig"
41 @@ -688,7 +690,7 @@
42 # symlink in /usr/include/, and make defconfig will fail, so we have
43 # to force an include path with $S.
44 HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
45 - ln -sf asm-${KARCH} "${S}"/include/asm
46 + ln -sf asm-${KARCH} "${S}"/include/asm || die
47 cross_pre_c_headers && return 0
48
49 make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})"
50 @@ -705,7 +707,7 @@
51 # .config based upon any info we may have
52 case ${CTARGET} in
53 sh*)
54 - sed -i '/CONFIG_CPU_SH/d' .config
55 + sed -i '/CONFIG_CPU_SH/d' .config || die
56 echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config
57 return 0;;
58 esac
59 @@ -731,10 +733,10 @@
60 # of this crap anymore :D
61 if kernel_is ge 2 6 18 ; then
62 env_setup_xmakeopts
63 - emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
64 + emake headers_install INSTALL_HDR_PATH="${ED}"${ddir}/.. ${xmakeopts} || die
65
66 # let other packages install some of these headers
67 - rm -rf "${D}"/${ddir}/scsi #glibc/uclibc/etc...
68 + rm -rf "${ED}"${ddir}/scsi || die #glibc/uclibc/etc...
69 return 0
70 fi
71
72 @@ -742,15 +744,15 @@
73 # $S values where the cmdline to cp is too long
74 pushd "${S}" >/dev/null
75 dodir ${ddir}/linux
76 - cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
77 - rm -rf "${D}"/${ddir}/linux/modules
78 + cp -pPR "${S}"/include/linux "${ED}"${ddir}/ || die
79 + rm -rf "${ED}"${ddir}/linux/modules || die
80
81 dodir ${ddir}/asm
82 - cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
83 + cp -pPR "${S}"/include/asm/* "${ED}"${ddir}/asm || die
84
85 if kernel_is 2 6 ; then
86 dodir ${ddir}/asm-generic
87 - cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
88 + cp -pPR "${S}"/include/asm-generic/* "${ED}"${ddir}/asm-generic || die
89 fi
90
91 # clean up
92 @@ -784,7 +786,7 @@
93 > "${S}"/patches.txt
94 fi
95
96 - mv ${WORKDIR}/linux* "${D}"/usr/src
97 + mv "${WORKDIR}"/linux* "${ED}"usr/src || die
98
99 if [[ -n "${UNIPATCH_DOCS}" ]] ; then
100 for i in ${UNIPATCH_DOCS}; do
101 @@ -797,8 +799,8 @@
102 #==============================================================
103 preinst_headers() {
104 local ddir=$(kernel_header_destdir)
105 - [[ -L ${ddir}/linux ]] && rm ${ddir}/linux
106 - [[ -L ${ddir}/asm ]] && rm ${ddir}/asm
107 + [[ -L ${EPREFIX}${ddir}/linux ]] && { rm "${EPREFIX}"${ddir}/linux || die; }
108 + [[ -L ${EPREFIX}${ddir}/asm ]] && { rm "${EPREFIX}"${ddir}/asm || die; }
109 }
110
111 # pkg_postinst functions
112 @@ -819,21 +821,19 @@
113
114 # if we are to forcably symlink, delete it if it already exists first.
115 if [[ ${K_SYMLINK} > 0 ]]; then
116 - [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
117 + [[ -h ${EROOT}usr/src/linux ]] && { rm "${EROOT}"usr/src/linux || die; }
118 MAKELINK=1
119 fi
120
121 # if the link doesnt exist, lets create it
122 - [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
123 + [[ ! -h ${EROOT}usr/src/linux ]] && MAKELINK=1
124
125 if [[ ${MAKELINK} == 1 ]]; then
126 - cd "${ROOT}"usr/src
127 - ln -sf linux-${KV_FULL} linux
128 - cd ${OLDPWD}
129 + ln -sf linux-${KV_FULL} "${EROOT}"usr/src/linux || die
130 fi
131
132 # Don't forget to make directory for sysfs
133 - [[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
134 + [[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && mkdir "${EROOT}"sys
135
136 echo
137 elog "If you are upgrading from a previous kernel, you may be interested"
138 @@ -1095,7 +1095,7 @@
139 ebegin "Applying ${i/*\//} (-p1)"
140 if [ $(patch -p1 --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -le 2 ]; then
141 eend 0
142 - rm ${STDERR_T}
143 + rm ${STDERR_T} || die
144 break
145 else
146 eend 1
147 @@ -1119,7 +1119,7 @@
148 echo "=======================================================" >> ${STDERR_T}
149 if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
150 eend 0
151 - rm ${STDERR_T}
152 + rm ${STDERR_T} || die
153 break
154 else
155 eend 1
156 @@ -1153,9 +1153,9 @@
157 local tmp
158 for x in ${KPATCH_DIR}; do
159 for i in ${UNIPATCH_DOCS}; do
160 - if [[ -f "${x}/${i}" ]] ; then
161 + if [[ -f ${x}/${i} ]] ; then
162 tmp="${tmp} ${i}"
163 - cp -f "${x}/${i}" "${T}"/
164 + cp -f "${x}/${i}" "${T}"/ || die
165 fi
166 done
167 done
168 @@ -1353,11 +1353,11 @@
169 [[ ${ETYPE} == headers ]] && return 0
170
171 # If there isn't anything left behind, then don't complain.
172 - [[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0
173 + [[ -e ${EROOT}usr/src/linux-${KV_FULL} ]] || return 0
174 echo
175 ewarn "Note: Even though you have successfully unmerged "
176 ewarn "your kernel package, directories in kernel source location: "
177 - ewarn "${ROOT}usr/src/linux-${KV_FULL}"
178 + ewarn "${EROOT}usr/src/linux-${KV_FULL}"
179 ewarn "with modified files will remain behind. By design, package managers"
180 ewarn "will not remove these modified files and the directories they reside in."
181 echo

Replies

Subject Author
Re: [gentoo-dev] Re: RFC: kernel-2.eclass Prefix support Michael Orlitzky <mjo@g.o>