summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bashrc50
1 files changed, 26 insertions, 24 deletions
diff --git a/bashrc b/bashrc
index e5e9956..e3ef84b 100644
--- a/bashrc
+++ b/bashrc
@@ -1,59 +1,61 @@
#!/bin/bash
-. /etc/init.d/functions.sh
+if ! type einfo >/dev/null 2>&1 ; then
+ . /etc/init.d/functions.sh
+fi
autopatch() {
- local diff level p patches patched
+ local diff level p patches patchdir
- [[ ! -d "$PATCH_OVERLAY" ]] && return 0
+ [[ ! -d "$PATCH_OVERLAY" ]] && return
- patches=$(ls -1 ${PATCH_OVERLAY}/${CATEGORY}/${PN}/{${PN},${P},${PF}}-[^0-9]*.{patch,diff} 2>/dev/null)
- [[ $patches == "" ]] && return 0
+ patchdir="${PATCH_OVERLAY}/${CATEGORY}/${PN}"
+ patches=$(ls -1 ${patchdir}/{${PN},${P},${PF}}-[^0-9]*.{patch,diff} 2>/dev/null)
+ [[ $patches == "" ]] && return
- if ! cd ${S}; then
+ if ! pushd ${S} &>/dev/null; then
eerror "FAILED TO cd $S"
- return 1
+ return
fi
for p in ${patches}; do
p=$(basename $p)
- diff=${PATCH_OVERLAY}/${CATEGORY}/${PN}/${p}
+ diff=${patchdir}/${p}
if [[ -e $diff ]] && [ ! -e ${S}/.${p} ]; then
- patched=0
for level in 0 1 2 3 4; do
- if [[ $patched == 0 ]]; then
- patch -g0 --dry -p${level} >/dev/null < $diff
- if [ $? = 0 ]; then
- ebegin "auto patching (-p${level}) ${p}"
- patch -g0 -p${level} < $diff > /dev/null && patched=1
- eend $?
- touch ${S}/.${p}
- fi
+ patch -g0 --dry -p${level} >/dev/null < $diff
+
+ if [ $? = 0 ]; then
+ ebegin "auto patching (-p${level}) ${p}"
+ patch -g0 -p${level} < $diff > /dev/null
+ eend $?
+ touch ${S}/.${p}
+
+ continue 2
fi
done
- [[ $patched != 1 ]] && eerror "FAILED auto patching $p"
+
+ eerror "FAILED auto patching $p"
else
[[ ! -e $diff ]] && eerror "$diff does not exist, unable to auto patch"
fi
done
- cd $OLDPWD
+
+ popd &>/dev/null
}
#ewarn "at $EBUILD_PHASE"
case $EBUILD_PHASE in
compile)
- ebegin "Checking for auto patches in ${PATCH_OVERLAY}/${CATEGORY}/${PN}"
-
+ einfo "Checking for auto patches in ${PATCH_OVERLAY}/${CATEGORY}/${PN}"
+
if [[ ! -d "$PATCH_OVERLAY" ]]; then
- eend 1
eerror "PATCH_OVERLAY=$PATCH_OVERLAY is not a dir"
else
PATH=$PATH:/usr/sbin:/usr/bin:/bin:/sbin
autopatch
- eend 0
fi
;;
esac
-