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

72
aps
View file

@ -44,9 +44,23 @@ function confirm(){
# wrn "This is a debug build, that may not work!" # wrn "This is a debug build, that may not work!"
#} #}
function sources(){ function sources(){
if [ -f sources ]; then #pkg_config_url=$(cat sources)
pkg_config_url=$(cat sources) #pkg_config_archv=$(echo ${pkg_config_url} | sed 's:.*/::')
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} curl -fLO ${pkg_config_url}
mkdir --parents pkgex mkdir --parents pkgex
pkg_config_archv_ft=$(file --extension ${pkg_config_archv_ft}) pkg_config_archv_ft=$(file --extension ${pkg_config_archv_ft})
@ -61,18 +75,14 @@ function sources(){
mkdir --parents pkgsrc mkdir --parents pkgsrc
cp -r pkgex/*/* pkgsrc cp -r pkgex/*/* pkgsrc
else
err "Sources not found, exiting!"
fi
} }
function sha256(){ function sha256(){
sum="$(cat $1/sums | cut -d'+' -f-)" #sha256sum $sum > $1.sha256sum
sha256sum $sum > $1.sha256sum sha256sum -c "$1" 1>&2 /dev/null
shafilesum=sha256sum -cs "$1.sha256sum" if [ "$?" -ne "0" ]; then
if [ shasum == shafilesum ]; then prn "OK!"
prn "OK! sha verified."
else else
err "Invalid sha" err "Sha failed!"
fi fi
} }
@ -80,14 +90,14 @@ function sha256(){
# sum="$(cat $@/sums)" # sum="$(cat $@/sums)"
# md5sum "$sum" # md5sum "$sum"
#} #}
function versum(){ #function versum(){
$sumrest=$(cat $@/sums | cut -d'+' -f-) # sumrest=$(cat $@/sums | cut -d'+' -f-)
$sumtype=$(cat $@/sums | cut -d'+' -f2) # sumtype=$(cat $@/sums | cut -d'+' -f2)
case $sumtype in # case $sumtype in
sha256) sha256 $1 ;; # sha256) sha256 "$1.sha256sum" ;;
md5) err "MD5 is not supported." ;; # md5) err "MD5 is not supported." ;;
esac # esac
} #}
function runbuildsh(){ function runbuildsh(){
if [ -x "${2}/${1}" ]; then if [ -x "${2}/${1}" ]; then
prn "Running $1" prn "Running $1"
@ -134,26 +144,30 @@ function pkg_local(){
mkdir -p "${pkg_path}/payload" mkdir -p "${pkg_path}/payload"
. "${pkg_path}/package" . "${pkg_path}/package"
cd "${pkg_path}" cd "${pkg_path}"
sources || err "No sources found / failed getting sources" if [ -f *.sources ]
if [ -f sums ] sources "$(cat *.sources)"
versum "${1}"
else else
wrn "No sums file found! Be careful!" err "No sources exist!"
fi fi
runbuildsh "build" "${pkg_path}" if [ -f *.sha256sums ]
runbuildsh "predeploy" "${pkg_path}" 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! # Old APS code from before the rewrite!
# Deploy package # Deploy package
if [ "${pkg_config_deploy}" = true ]; then 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" 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" sed 's/^.*-> //' "${temp_location}/${pkg_name}-payloaddeploylog" | tr -d \'\" > "${temp_location}/${pkg_name}-payloadfiles"
rm "${temp_location}/${pkg_name}-payloaddeploylog" rm "${temp_location}/${pkg_name}-payloaddeploylog"
fi fi
runbuildsh "postdeploy" "${pkg_path}" runbuildsh "postdeploy" "${pkg_path}/pkgex"
# Yet more old APS code # Yet more old APS code
if [ -x "${pkg_path}/package" ]; then 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}" [ ! -d "${installed_pkg_database}/${pkg_name}" ] && mkdir "${installed_pkg_database}/${pkg_name}"
cp -pv "${pkg_path}/package" "${installed_pkg_database}/${pkg_name}/package" 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" [ -e "${temp_location}/${pkg_name}-payloadfiles" ] && cp -pv "${temp_location}/${pkg_name}-payloadfiles" "${installed_pkg_database}/${pkg_name}/payloadfiles"