rewrite verifiaction to include only sha, rewrite sources

This commit is contained in:
Ohio2 2021-10-01 22:40:05 +02:00
parent 95d746acf1
commit 46cdedc6a2
Signed by: Ohio2
GPG key ID: 2746D0A9E4F21E80

98
aps
View file

@ -44,35 +44,45 @@ function confirm(){
# wrn "This is a debug build, that may not work!"
#}
function sources(){
if [ -f sources ]; then
pkg_config_url=$(cat sources)
pkg_config_archv=$(echo ${pkg_config_url} | sed 's:.*/::')
curl -fLO ${pkg_config_url}
mkdir --parents pkgex
pkg_config_archv_ft=$(file --extension ${pkg_config_archv_ft})
case $pkg_config_archv_ft in
*.tar*) prn $(tar -xf ${pkg_config_archv} -C pkgex) ;;
*.xz) prn $(cd pkgex && xz -d ../${pkg_config_archv} && cd ..) ;;
*.bz2) prn $(cd pkgex && bzip2 -d ../${pkg_config_archv} && cd ..) ;;
*.gz) prn $(cd pkgex && gzip -d ../${pkg_config_archv} && cd ..) ;;
*.zst) prn $(cd pkgex && zstd -dc && cd ..) ;;
*) wrn "Not a tar! But it will be kept!"
esac
mkdir --parents pkgsrc
cp -r pkgex/*/* pkgsrc
#pkg_config_url=$(cat sources)
#pkg_config_archv=$(echo ${pkg_config_url} | sed 's:.*/::')
#curl -fLO ${pkg_config_url}
#mkdir --parents pkgex
#pkg_config_archv_ft=$(file --extension ${pkg_config_archv_ft})
#case $pkg_config_archv_ft in
# *.tar*) prn $(tar -xf ${pkg_config_archv} -C pkgex) ;;
# *.xz) prn $(cd pkgex && xz -d ../${pkg_config_archv} && cd ..) ;;
# *.bz2) prn $(cd pkgex && bzip2 -d ../${pkg_config_archv} && cd ..) ;;
# *.gz) prn $(cd pkgex && gzip -d ../${pkg_config_archv} && cd ..) ;;
# *.zst) prn $(cd pkgex && zstd -dc && cd ..) ;;
# *) wrn "Not a tar! But it will be kept!"
#esac
#mkdir --parents pkgsrc
#cp -r pkgex/*/* pkgsrc
pkg_config_url=$1
pkg_config_archv=$(echo ${pkg_config_url} | sed 's:.*/::'
curl -fLO ${pkg_config_url}
mkdir --parents pkgex
pkg_config_archv_ft=$(file --extension ${pkg_config_archv_ft})
case $pkg_config_archv_ft in
*.tar*) prn $(tar -xf ${pkg_config_archv} -C pkgex) ;;
*.xz) prn $(cd pkgex && xz -d ../${pkg_config_archv} && cd ..) ;;
*.bz2) prn $(cd pkgex && bzip2 -d ../${pkg_config_archv} && cd ..) ;;
*.gz) prn $(cd pkgex && gzip -d ../${pkg_config_archv} && cd ..) ;;
*.zst) prn $(cd pkgex && zstd -dc && cd ..) ;;
*) wrn "Not a tar! But it will be kept!"
esac
mkdir --parents pkgsrc
cp -r pkgex/*/* pkgsrc
else
err "Sources not found, exiting!"
fi
}
function sha256(){
sum="$(cat $1/sums | cut -d'+' -f-)"
sha256sum $sum > $1.sha256sum
shafilesum=sha256sum -cs "$1.sha256sum"
if [ shasum == shafilesum ]; then
prn "OK! sha verified."
#sha256sum $sum > $1.sha256sum
sha256sum -c "$1" 1>&2 /dev/null
if [ "$?" -ne "0" ]; then
prn "OK!"
else
err "Invalid sha"
err "Sha failed!"
fi
}
@ -80,14 +90,14 @@ function sha256(){
# sum="$(cat $@/sums)"
# md5sum "$sum"
#}
function versum(){
$sumrest=$(cat $@/sums | cut -d'+' -f-)
$sumtype=$(cat $@/sums | cut -d'+' -f2)
case $sumtype in
sha256) sha256 $1 ;;
md5) err "MD5 is not supported." ;;
esac
}
#function versum(){
# sumrest=$(cat $@/sums | cut -d'+' -f-)
# sumtype=$(cat $@/sums | cut -d'+' -f2)
# case $sumtype in
# sha256) sha256 "$1.sha256sum" ;;
# md5) err "MD5 is not supported." ;;
# esac
#}
function runbuildsh(){
if [ -x "${2}/${1}" ]; then
prn "Running $1"
@ -134,26 +144,30 @@ function pkg_local(){
mkdir -p "${pkg_path}/payload"
. "${pkg_path}/package"
cd "${pkg_path}"
sources || err "No sources found / failed getting sources"
if [ -f sums ]
versum "${1}"
if [ -f *.sources ]
sources "$(cat *.sources)"
else
wrn "No sums file found! Be careful!"
err "No sources exist!"
fi
runbuildsh "build" "${pkg_path}"
runbuildsh "predeploy" "${pkg_path}"
if [ -f *.sha256sums ]
sha256 "*.sha256sum}"
else
wrn "No sums file(s) found! Be careful!"
fi
runbuildsh "build" "${pkg_path}/pkgex"
runbuildsh "predeploy" "${pkg_path}/pkgex"
# Old APS code from before the rewrite!
# Deploy package
if [ "${pkg_config_deploy}" = true ]; then
echo ":: Deploying target ${pkg_name}..."
prn "Deploying target ${pkg_name}..."
cp -rpv "${pkg_path}/payload"/* "${install_root}" > "${temp_location}/${pkg_name}-payloaddeploylog"
sed 's/^.*-> //' "${temp_location}/${pkg_name}-payloaddeploylog" | tr -d \'\" > "${temp_location}/${pkg_name}-payloadfiles"
rm "${temp_location}/${pkg_name}-payloaddeploylog"
fi
runbuildsh "postdeploy" "${pkg_path}"
runbuildsh "postdeploy" "${pkg_path}/pkgex"
# Yet more old APS code
if [ -x "${pkg_path}/package" ]; then
echo ":: Adding target ${pkg_name} to installed package database..."
prn "Adding target ${pkg_name} to installed package database..."
[ ! -d "${installed_pkg_database}/${pkg_name}" ] && mkdir "${installed_pkg_database}/${pkg_name}"
cp -pv "${pkg_path}/package" "${installed_pkg_database}/${pkg_name}/package"
[ -e "${temp_location}/${pkg_name}-payloadfiles" ] && cp -pv "${temp_location}/${pkg_name}-payloadfiles" "${installed_pkg_database}/${pkg_name}/payloadfiles"