2017-08-23 23:05:40 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
selected=
|
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
$0 -- Test packages in crosstool-NG
|
|
|
|
|
|
|
|
Verifies that the release tarballs can be downloaded for the packages
|
2023-01-30 22:15:19 +00:00
|
|
|
available in crosstool-NG and check that the patches apply cleanly.
|
2017-08-23 23:05:40 +00:00
|
|
|
Requires crosstool-NG to be configured and built prior to running.
|
|
|
|
|
|
|
|
Options:
|
|
|
|
--help, -?
|
|
|
|
Display this help message.
|
|
|
|
|
|
|
|
--download, -d
|
|
|
|
Download all packages to the default directory (\$HOME/src).
|
|
|
|
|
2017-09-28 05:29:35 +00:00
|
|
|
--digest, -D
|
|
|
|
Create digests (MD5/SHA-1/...) for all package archives.
|
|
|
|
|
2017-08-23 23:05:40 +00:00
|
|
|
--apply-patches, -a
|
|
|
|
Implies -d. Unpack and apply the bundled patches.
|
|
|
|
|
2017-12-02 20:21:27 +00:00
|
|
|
--update-patches, -P
|
|
|
|
Implies -d. Renumber the patches and update the offsets
|
|
|
|
in them. Requires quilt to be installed.
|
|
|
|
|
2017-08-23 23:05:40 +00:00
|
|
|
--verify-urls, -u
|
|
|
|
Check *all* the download URLs for accessibility, without
|
|
|
|
actually downloading anything.
|
|
|
|
|
|
|
|
--select MASK, -s MASK
|
|
|
|
Specify the package to operate upon. MASK can be either package
|
|
|
|
name ("-s foo"), or package name + version ("-s foo-1.1").
|
|
|
|
|
2017-09-28 06:10:46 +00:00
|
|
|
--signature, -S
|
|
|
|
When downloading archives (because of any of -D/-d/-u options),
|
|
|
|
also download/verify signatures.
|
|
|
|
|
2017-08-23 23:05:40 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
while [ -n "${1}" ]; do
|
|
|
|
case "${1}" in
|
|
|
|
--download|-d)
|
|
|
|
download_pkgs=y
|
|
|
|
;;
|
2017-09-28 05:29:35 +00:00
|
|
|
--digest|-D)
|
|
|
|
create_digests=y
|
|
|
|
;;
|
2017-08-23 23:05:40 +00:00
|
|
|
--verify-urls|-u)
|
|
|
|
verify_urls=y
|
|
|
|
;;
|
|
|
|
--apply-patches|-a)
|
|
|
|
apply_patches=y
|
|
|
|
download_pkgs=y
|
|
|
|
;;
|
2017-12-02 20:21:27 +00:00
|
|
|
--update-patches|-P)
|
|
|
|
update_patches=y
|
|
|
|
download_pkgs=y
|
|
|
|
;;
|
2017-08-23 23:05:40 +00:00
|
|
|
--select|-s)
|
|
|
|
shift
|
|
|
|
[ -n "${1}" ] || { echo "argument required for --select" >&2; exit 1; }
|
|
|
|
selected="${1}"
|
|
|
|
;;
|
2017-09-28 06:10:46 +00:00
|
|
|
--signature|-S)
|
|
|
|
signature=y
|
|
|
|
;;
|
2017-08-23 23:05:40 +00:00
|
|
|
--help|-?)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown option ${1}" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2017-09-28 05:29:35 +00:00
|
|
|
if [ -z "${download_pkgs}${create_digests}${verify_urls}" ]; then
|
2017-09-16 20:05:34 +00:00
|
|
|
echo "No action selected" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-08-23 23:05:40 +00:00
|
|
|
CT_LIB_DIR=`pwd`
|
|
|
|
CT_TOP_DIR=`pwd`
|
|
|
|
CT_TARBALLS_DIR=`pwd`/temp.tarballs
|
|
|
|
CT_COMMON_SRC_DIR=`pwd`/temp.src
|
2020-02-17 21:00:49 +00:00
|
|
|
CT_WORK_DIR=`pwd`/temp.work
|
2017-08-23 23:05:40 +00:00
|
|
|
CT_SRC_DIR=`pwd`/temp.src
|
|
|
|
CT_LOG_LEVEL_MAX=EXTRA
|
2017-12-02 20:21:27 +00:00
|
|
|
CT_TEMP_PATCH_DIR=`pwd`/temp.patches
|
2020-02-17 21:00:49 +00:00
|
|
|
mkdir -p "${CT_TARBALLS_DIR}" "${CT_WORK_DIR}"
|
2017-08-23 23:05:40 +00:00
|
|
|
|
|
|
|
# Does not matter, just to make the scripts load
|
|
|
|
CT_ARCH=arm
|
|
|
|
CT_KERNEL=bare-metal
|
|
|
|
CT_BINUTILS=binutils
|
|
|
|
CT_LIBC=none
|
|
|
|
CT_CC=gcc
|
|
|
|
|
|
|
|
. paths.sh
|
|
|
|
. scripts/functions
|
|
|
|
|
|
|
|
rm -f build.log
|
|
|
|
CT_LogEnable
|
|
|
|
|
|
|
|
check_pkg_urls()
|
|
|
|
{
|
|
|
|
local e m mh url
|
|
|
|
|
|
|
|
for e in ${archive_formats}; do
|
|
|
|
local -A mirror_status=( )
|
|
|
|
|
|
|
|
CT_DoStep EXTRA "Looking for ${archive_filename}${e}"
|
|
|
|
for m in ${mirrors}; do
|
|
|
|
url="${m}/${archive_filename}${e}"
|
2018-04-12 15:17:05 +00:00
|
|
|
mh="${url#*://}"
|
|
|
|
mh="${mh%%[:/]*}"
|
2017-08-24 06:56:40 +00:00
|
|
|
case "${url}" in
|
|
|
|
# WGET always returns success for FTP URLs in spider mode :(
|
2018-04-12 15:17:05 +00:00
|
|
|
ftp://*) CT_DoLog EXTRA "SKIP ${mh} [FTP not supported]"; continue;;
|
2017-08-24 06:56:40 +00:00
|
|
|
esac
|
2017-08-23 23:05:40 +00:00
|
|
|
if [ -n "${mirror_status[${mh}]}" ]; then
|
|
|
|
CT_DoLog DEBUG "Skipping '${url}': already found on this host at '${mirror_status[${mh}]}'"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if CT_DoExecLog ALL wget --spider "${url}"; then
|
|
|
|
mirror_status[${mh}]="${url}"
|
|
|
|
else
|
|
|
|
mirror_status[${mh}]=
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
for mh in "${!mirror_status[@]}"; do
|
|
|
|
if [ -n "${mirror_status[${mh}]}" ]; then
|
|
|
|
CT_DoLog EXTRA "OK ${mh} [${archive_filename}${e}]"
|
|
|
|
else
|
|
|
|
CT_DoLog ERROR "FAIL ${mh} [${archive_filename}${e}]"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
CT_EndStep
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2017-09-28 05:29:35 +00:00
|
|
|
create_digests()
|
|
|
|
{
|
2017-09-30 00:05:22 +00:00
|
|
|
local e m url alg chksum
|
2017-09-28 05:29:35 +00:00
|
|
|
local save_archive_formats="${archive_formats}"
|
|
|
|
|
2017-09-30 00:05:22 +00:00
|
|
|
# Remove stale digests - we'll create them anew below
|
|
|
|
CT_DoExecLog ALL rm -f "${CT_LIB_DIR}/packages/${pkg_name}/${version}/chksum"
|
2017-09-28 05:29:35 +00:00
|
|
|
for e in ${save_archive_formats}; do
|
|
|
|
CT_DoStep EXTRA "Downloading ${archive_filename}${e}"
|
|
|
|
archive_formats="${e}"
|
|
|
|
CT_DoFetch
|
|
|
|
CT_Pushd "${CT_LOCAL_TARBALLS_DIR}"
|
|
|
|
for alg in md5 sha1 sha256 sha512; do
|
|
|
|
CT_DoLog EXTRA "Creating ${alg^^} digest for ${archive_filename}${e}"
|
2017-09-30 00:05:22 +00:00
|
|
|
chksum=`${alg}sum "${archive_filename}${e}"`
|
|
|
|
if [ "$?" != 0 ]; then
|
|
|
|
CT_DoExecLog ALL rm -f "${CT_LIB_DIR}/packages/${pkg_name}/${version}/chksum"
|
2017-09-28 05:29:35 +00:00
|
|
|
CT_Abort "${alg}sum failed"
|
|
|
|
fi
|
2017-09-30 00:05:22 +00:00
|
|
|
echo "${alg} ${archive_filename}${e} ${chksum%%[[:space:]]*}" >> \
|
|
|
|
"${CT_LIB_DIR}/packages/${pkg_name}/${version}/chksum"
|
2017-09-28 05:29:35 +00:00
|
|
|
done
|
|
|
|
CT_Popd
|
|
|
|
CT_EndStep
|
|
|
|
done
|
|
|
|
archive_formats="${save_archive_formats}"
|
|
|
|
}
|
|
|
|
|
2017-12-02 20:21:27 +00:00
|
|
|
update_patches()
|
|
|
|
{
|
|
|
|
local masterpfx="${1}"
|
|
|
|
local pkgdir="${CT_LIB_DIR}/packages/${pkg_name}/${version}"
|
|
|
|
local p i base newname
|
|
|
|
|
|
|
|
CT_DoExecLog ALL rm -rf "${CT_TEMP_PATCH_DIR}"
|
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_TEMP_PATCH_DIR}"
|
|
|
|
|
|
|
|
# Move old patches so that CT_DoExtractPatch produces a clean directory
|
|
|
|
for p in "${pkgdir}"/*.patch; do
|
|
|
|
if [ "${p}" = "${pkgdir}/*.patch" ]; then
|
|
|
|
return # No patches
|
|
|
|
fi
|
|
|
|
CT_DoExecLog ALL mv "${p}" "${CT_TEMP_PATCH_DIR}"
|
|
|
|
done
|
|
|
|
# NOTE: we're already inside CT_PackageRun, so use CT_DoExtractPatch rather
|
|
|
|
# than CT_ExtractPatch, so that we keep the variable modified by it.
|
|
|
|
CT_DoExtractPatch
|
|
|
|
CT_DoLog EXTRA "Pushing patches into quilt"
|
|
|
|
CT_Pushd "${src_dir}/${dir_name}"
|
|
|
|
export QUILT_PATCHES=ct-ng.patches
|
|
|
|
CT_DoExecLog ALL mkdir -p ${QUILT_PATCHES}
|
|
|
|
CT_DoExecLog ALL touch ${QUILT_PATCHES}/series
|
|
|
|
CT_DoExecLog ALL quilt --quiltrc - setup ct-ng.patches/series
|
|
|
|
for p in "${CT_TEMP_PATCH_DIR}"/*.patch; do
|
|
|
|
# By now we know we have a non-empty set of patches
|
|
|
|
CT_DoExecLog ALL quilt --quiltrc - import "${p}"
|
|
|
|
CT_DoExecLog ALL quilt --quiltrc - push
|
2022-05-12 09:00:25 +00:00
|
|
|
CT_DoExecLog ALL quilt --quiltrc - refresh -p ab -u --no-timestamps --no-index --diffstat
|
2017-12-02 20:21:27 +00:00
|
|
|
done
|
|
|
|
# Now publish the patches back into the package's directory, renumbering them
|
|
|
|
# in the process.
|
|
|
|
CT_DoLog EXTRA "Saving updated patches"
|
|
|
|
i=0
|
|
|
|
for p in `quilt --quiltrc - applied`; do
|
|
|
|
# Strip index separated by dash or underscore
|
|
|
|
base=`echo "${p}" | sed 's#^[0-9]\{2,4\}[-_]##'`
|
|
|
|
newname=`printf "%04u-%s" "${i}" "${base}"`
|
|
|
|
i=$[i+1]
|
|
|
|
CT_DoExecLog ALL mv "${QUILT_PATCHES}/${p}" "${pkgdir}/${newname}"
|
|
|
|
done
|
|
|
|
CT_Popd
|
|
|
|
}
|
|
|
|
|
2017-12-05 09:09:56 +00:00
|
|
|
matched=0
|
|
|
|
|
2017-08-23 23:05:40 +00:00
|
|
|
run_pkgversion()
|
|
|
|
{
|
2020-02-17 21:00:49 +00:00
|
|
|
local descr
|
|
|
|
|
2017-08-23 23:05:40 +00:00
|
|
|
while [ -n "${1}" ]; do
|
|
|
|
eval "local ${1}"
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -n "${selected}" ]; then
|
|
|
|
case "${selected}" in
|
|
|
|
${pkg_name}|${pkg_name}-${ver})
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2020-02-17 21:00:49 +00:00
|
|
|
if [ -n "${ver}" ]; then
|
|
|
|
descr="${pkg_name}-${ver}"
|
|
|
|
else
|
|
|
|
descr="${pkg_name} revision ${repository_cset}"
|
|
|
|
fi
|
2017-08-23 23:05:40 +00:00
|
|
|
|
2020-02-17 21:00:49 +00:00
|
|
|
CT_DoStep INFO "Handling ${descr}"
|
2017-12-05 09:09:56 +00:00
|
|
|
matched=$[matched+1]
|
2017-08-23 23:05:40 +00:00
|
|
|
|
|
|
|
# Create a temporary configuration head file
|
|
|
|
cat >temp.in <<EOF
|
|
|
|
config OBSOLETE
|
|
|
|
def_bool y
|
|
|
|
|
|
|
|
config EXPERIMENTAL
|
|
|
|
def_bool y
|
|
|
|
|
2019-09-26 05:53:39 +00:00
|
|
|
config CONFIGURE_has_lzip
|
|
|
|
def_bool y
|
|
|
|
|
2017-08-23 23:05:40 +00:00
|
|
|
config CONFIGURE_has_wget
|
|
|
|
def_bool y
|
|
|
|
|
|
|
|
config CONFIGURE_has_curl
|
|
|
|
def_bool y
|
|
|
|
|
|
|
|
config ${versionlocked}_V_${kcfg}
|
|
|
|
def_bool y
|
|
|
|
|
|
|
|
source "config/global/paths.in"
|
|
|
|
source "config/global/download.in"
|
|
|
|
source "config/global/extract.in"
|
2018-04-12 15:17:05 +00:00
|
|
|
source "config/global/build-behave.in"
|
2017-08-23 23:05:40 +00:00
|
|
|
source "config/versions/${master}.in"
|
|
|
|
EOF
|
|
|
|
|
2020-02-17 21:00:49 +00:00
|
|
|
# Common part of the config file
|
2017-08-23 23:05:40 +00:00
|
|
|
cat >temp.defconfig <<EOF
|
|
|
|
CT_${masterpfx}_USE_${originpfx}=y
|
|
|
|
CT_SAVE_TARBALLS=y
|
2020-02-17 21:00:49 +00:00
|
|
|
CT_WORK_DIR="${CT_WORK_DIR}"
|
|
|
|
# CT_OVERRIDE_CONFIG_GUESS_SUB is not set
|
2017-09-28 05:29:35 +00:00
|
|
|
# CT_VERIFY_DOWNLOAD_DIGEST is not set
|
2017-09-28 06:10:46 +00:00
|
|
|
${signature+CT_VERIFY_DOWNLOAD_SIGNATURE=y}
|
2017-08-23 23:05:40 +00:00
|
|
|
EOF
|
|
|
|
|
2020-02-17 21:00:49 +00:00
|
|
|
if [ -n "${kcfg}" ]; then
|
|
|
|
# Regular tarball
|
|
|
|
cat >>temp.defconfig <<EOF
|
|
|
|
CT_${pfx}_SRC_RELEASE=y
|
|
|
|
CT_${pfx}_V_${kcfg}=y
|
|
|
|
EOF
|
|
|
|
else
|
|
|
|
# VCS-based release
|
|
|
|
cat >>temp.defconfig <<EOF
|
|
|
|
CT_${pfx}_SRC_DEVEL=y
|
|
|
|
CT_${pfx}_DEVEL_VCS="${vcs}"
|
|
|
|
CT_${pfx}_DEVEL_URL="${repository_url}"
|
|
|
|
CT_${pfx}_DEVEL_BRANCH="${repository_branch}"
|
|
|
|
CT_${pfx}_DEVEL_REVISION="${repository_cset}"
|
|
|
|
CT_${pfx}_DEVEL_SUBDIR="${repository_subdir}"
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
2017-08-23 23:05:40 +00:00
|
|
|
./kconfig/conf --defconfig=temp.defconfig temp.in >/dev/null
|
|
|
|
|
|
|
|
CT_LoadConfig
|
2020-02-17 21:00:49 +00:00
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}"
|
2017-08-23 23:05:40 +00:00
|
|
|
rm -f .config .config.old temp.defconfig temp.in
|
2020-02-17 21:00:49 +00:00
|
|
|
if [ -n "${ver}" ]; then
|
|
|
|
if [ -n "${verify_urls}" ]; then
|
|
|
|
CT_DoLog EXTRA "Verifying URLs for ${descr}"
|
|
|
|
CT_PackageRun "${masterpfx}" check_pkg_urls
|
|
|
|
fi
|
|
|
|
if [ -n "${create_digests}" ]; then
|
|
|
|
CT_DoLog EXTRA "Creating digests for ${descr}"
|
|
|
|
CT_PackageRun "${masterpfx}" create_digests
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
CT_DoLog EXTRA "Not verifying URLs or creating digests for ${descr} (devel release)"
|
2017-09-28 05:29:35 +00:00
|
|
|
fi
|
2017-08-23 23:05:40 +00:00
|
|
|
if [ -n "${download_pkgs}" ]; then
|
2020-02-17 21:00:49 +00:00
|
|
|
CT_DoLog EXTRA "Downloading ${descr}"
|
2017-08-23 23:05:40 +00:00
|
|
|
CT_Fetch "${masterpfx}"
|
|
|
|
fi
|
|
|
|
if [ -n "${apply_patches}" ]; then
|
2017-12-02 20:21:27 +00:00
|
|
|
CT_DoExecLog ALL rm -rf ${CT_COMMON_SRC_DIR}
|
|
|
|
CT_DoExecLog ALL mkdir -p ${CT_COMMON_SRC_DIR}
|
2017-08-23 23:05:40 +00:00
|
|
|
CT_ExtractPatch "${masterpfx}"
|
|
|
|
fi
|
2017-12-02 20:21:27 +00:00
|
|
|
if [ -n "${update_patches}" ]; then
|
|
|
|
CT_DoExecLog ALL rm -rf ${CT_COMMON_SRC_DIR}
|
|
|
|
CT_DoExecLog ALL mkdir -p ${CT_COMMON_SRC_DIR}
|
|
|
|
CT_PackageRun "${masterpfx}" update_patches
|
|
|
|
fi
|
2017-08-23 23:05:40 +00:00
|
|
|
|
|
|
|
CT_EndStep
|
|
|
|
}
|
|
|
|
|
2017-09-04 23:22:52 +00:00
|
|
|
[ -r .config ] && mv .config .config-saved
|
2017-12-05 09:09:56 +00:00
|
|
|
CT_DoStep INFO "Iterating over ${selected:-all} packages"
|
2017-08-23 23:05:40 +00:00
|
|
|
. maintainer/package-versions
|
2017-12-05 09:09:56 +00:00
|
|
|
CT_EndStep
|
|
|
|
CT_DoLog INFO "Handled ${matched} packages/versions"
|
2017-09-04 23:22:52 +00:00
|
|
|
[ -r .config-saved ] && mv .config-saved .config
|
2017-08-23 23:05:40 +00:00
|
|
|
|
2020-02-17 21:00:49 +00:00
|
|
|
CT_DoExecLog ALL rm -rf "${CT_TARBALLS_DIR}" "${CT_COMMON_SRC_DIR}" "${CT_TEMP_PATCH_DIR}" "${CT_WORK_DIR}"
|