mirror of
https://gitdl.cn/https://github.com/chakralinux/core.git
synced 2025-01-24 02:22:15 +08:00
62 lines
1.1 KiB
Bash
Executable File
62 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
cat_patch() {
|
|
file=${startdir}/src/$(basename ${1})
|
|
ftype=$(file -bizL "${file}")
|
|
case "$ftype" in
|
|
*application/x-gzip*)
|
|
zcat ${file} ;;
|
|
*application/x-bzip*)
|
|
bzcat ${file} ;;
|
|
*)
|
|
cat ${file} ;;
|
|
esac
|
|
}
|
|
|
|
get_file() {
|
|
file=$(basename ${1})
|
|
OPWD=${PWD}
|
|
if [ "${file}" != "${1}" ]; then
|
|
cd ${SRCDEST}
|
|
[ ! -f ${file} ] && wget -c ${1}
|
|
cd ${startdir}/src
|
|
ln -s ../../_sources/${file} .
|
|
else
|
|
cd ${startdir}/src
|
|
ln -s ../patches/${file} .
|
|
fi
|
|
cd ${OPWD}
|
|
}
|
|
|
|
source PATCHCFG
|
|
|
|
export SRCNAME
|
|
|
|
export startdir=${PWD}
|
|
mkdir ${startdir}/src
|
|
cd ${startdir}/src
|
|
|
|
get_file ${SRC}
|
|
bsdtar -xf $(basename ${SRC})
|
|
cp -a ${SRCORIG} ${SRCNAME}
|
|
cd ${SRCNAME}
|
|
|
|
pre_apply
|
|
|
|
for p in ${PATCHES[@]}; do
|
|
patchname=$(echo ${p} | cut -d% -f1)
|
|
patchstrip=$(echo ${p} | cut -d% -f2)
|
|
get_file ${patchname}
|
|
cat_patch ${patchname} | patch -Np${patchstrip} || exit 1
|
|
done
|
|
|
|
post_apply
|
|
|
|
rm -v $(find . -type f -name '*.orig')
|
|
|
|
cd ${startdir}/src
|
|
diff -Nur ${SRCORIG} ${SRCNAME} > $startdir/${PATCHNAME}
|
|
bzip2 --best $startdir/${PATCHNAME}
|
|
md5sum $startdir/${PATCHNAME}.bz2
|
|
|