new: allow file in sources
This commit is contained in:
@@ -63,8 +63,8 @@
|
|||||||
- pkgdesc 字符串, 软件描述
|
- pkgdesc 字符串, 软件描述
|
||||||
- pkgurl 字符串, 软件主页/上游地址
|
- pkgurl 字符串, 软件主页/上游地址
|
||||||
- license 数组, 软件许可证
|
- license 数组, 软件许可证
|
||||||
- sources 数组, 构建过程使用到的所有源码包和补丁
|
- sources 数组, 构建过程使用到的所有源码包和补丁,可以是 `https://...` 也可以是文件相对路径
|
||||||
- urls 数组, `sources` 各项对应的地址, 当前仅限使用 `wget` 获取
|
- urls 数组, `sources` 各项对应的地址, 当前仅限使用 `wget` 获取或复制文件
|
||||||
- md5sums 数组, `sources` 各项对应的 md5 checksum
|
- md5sums 数组, `sources` 各项对应的 md5 checksum
|
||||||
- options 数组, 构建选项, 详见第4小节
|
- options 数组, 构建选项, 详见第4小节
|
||||||
- srcdir 字符串, 构建路径(在leaf主程序中定义)
|
- srcdir 字符串, 构建路径(在leaf主程序中定义)
|
||||||
|
|||||||
@@ -379,34 +379,54 @@ leaf_update_environment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
leaf_prepare_package() {
|
leaf_prepare_package() {
|
||||||
local url sourcefile index _md5sum
|
local url sourcefile index _md5sum local_src pkg_src_root
|
||||||
|
|
||||||
distdir="${DIST_DIR}"
|
distdir="${DIST_DIR}"
|
||||||
mkdir -pv "${distdir}"
|
mkdir -pv -- "${distdir}"
|
||||||
pushd "${distdir}"
|
|
||||||
|
pkg_src_root="${PKGBUILD_DIR}/${PKG_PREFIX}/${PKG_NAME}"
|
||||||
|
|
||||||
|
pushd "${distdir}" >/dev/null || leaf_error "cannot enter distdir: ${distdir}"
|
||||||
|
|
||||||
for index in "${!sources[@]}"; do
|
for index in "${!sources[@]}"; do
|
||||||
sourcefile="${sources[$index]}"
|
sourcefile="${sources[$index]}"
|
||||||
url="${urls[$index]}"
|
url="${urls[$index]}"
|
||||||
|
|
||||||
|
if [ -z "${url}" ]; then
|
||||||
|
url="${sourcefile}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f "${sourcefile}" ]; then
|
if [ -f "${sourcefile}" ]; then
|
||||||
echo "${sourcefile} exits, checking..."
|
echo "${sourcefile} exists, checking..."
|
||||||
_md5sum=$(md5sum ${sourcefile} | awk '{print $1}')
|
_md5sum="$(md5sum -- "${sourcefile}" | awk '{print $1}')"
|
||||||
if [ "${_md5sum}" == "${md5sums[$index]}" ]; then
|
if [ "${_md5sum}" = "${md5sums[$index]}" ]; then
|
||||||
echo "md5sum match, skip ${sourcefile}."
|
echo "md5sum match, skip ${sourcefile}."
|
||||||
else
|
continue
|
||||||
echo "md5sum does not match, redownloading..."
|
|
||||||
rm -rf "${sourcefile}"
|
|
||||||
wget -O "${sourcefile}" "${url}"
|
|
||||||
fi
|
fi
|
||||||
else
|
echo "md5sum does not match, refetching..."
|
||||||
echo "Downloading ${sourcefile}..."
|
rm -f -- "${sourcefile}"
|
||||||
wget -O "${sourcefile}" "${url}"
|
|
||||||
fi
|
fi
|
||||||
_md5sum=$(md5sum "${sourcefile}" | awk '{print $1}')
|
|
||||||
|
case "${url}" in
|
||||||
|
http://*|https://*|ftp://*)
|
||||||
|
echo "Downloading ${sourcefile} from ${url}..."
|
||||||
|
wget -O "${sourcefile}" -- "${url}" || leaf_error "wget failed: ${url}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
local_src="${pkg_src_root}/${url}"
|
||||||
|
echo "Copying ${sourcefile} from local file ${local_src}..."
|
||||||
|
[ -f "${local_src}" ] || leaf_error "local source not found: ${local_src}"
|
||||||
|
cp -f -- "${local_src}" "${sourcefile}" || leaf_error "cp failed: ${local_src}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
_md5sum="$(md5sum -- "${sourcefile}" | awk '{print $1}')"
|
||||||
if [ "${_md5sum}" != "${md5sums[$index]}" ]; then
|
if [ "${_md5sum}" != "${md5sums[$index]}" ]; then
|
||||||
leaf_error "md5sums of ${sourcefile}(${_md5sum}) does not match with ${md5sums[$index]}!"
|
leaf_error "md5sums of ${sourcefile}(${_md5sum}) does not match with ${md5sums[$index]}!"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
popd
|
|
||||||
|
popd >/dev/null || true
|
||||||
echo "Sources ready."
|
echo "Sources ready."
|
||||||
src_prepare
|
src_prepare
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user