Merge pull request #3353 from Grimler91/fast-build

build-package.sh: handle Release.gpg and get deb path from Package
This commit is contained in:
Henrik Grimler 2019-02-16 22:49:47 +01:00 committed by GitHub
commit c178433867
2 changed files with 33 additions and 21 deletions

View File

@ -454,12 +454,12 @@ termux_download_deb() {
local version=$3 local version=$3
local deb_file=${package}_${version}_${package_arch}.deb local deb_file=${package}_${version}_${package_arch}.deb
for idx in $(seq ${#TERMUX_REPO_URL[@]}); do for idx in $(seq ${#TERMUX_REPO_URL[@]}); do
local TERMUX_REPO_NAME=$(echo ${TERMUX_REPO_URL[$idx-1]} | sed -e 's%https://%%g' -e 's%http://%%g' -e 's%/dists%%g' -e 's%/%-%g') local TERMUX_REPO_NAME=$(echo ${TERMUX_REPO_URL[$idx-1]} | sed -e 's%https://%%g' -e 's%http://%%g' -e 's%/%-%g')
local PACKAGE_FILE_PATH="${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-${TERMUX_REPO_COMPONENT[$idx-1]}-Packages" local PACKAGE_FILE_PATH="${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-${TERMUX_REPO_COMPONENT[$idx-1]}-Packages"
PKG_HASH=$(./scripts/get_hash_from_file.py "${TERMUX_COMMON_CACHEDIR}-$arch/$PACKAGE_FILE_PATH" $package $version) read -d "\n" PKG_PATH PKG_HASH <<<$(./scripts/get_hash_from_file.py "${TERMUX_COMMON_CACHEDIR}-$arch/$PACKAGE_FILE_PATH" $package $version)
if ! [ "$PKG_HASH" = "" ]; then if ! [ "$PKG_HASH" = "" ]; then
if [ ! "$TERMUX_QUIET_BUILD" = true ]; then if [ ! "$TERMUX_QUIET_BUILD" = true ]; then
echo "Found $package in ${TERMUX_REPO_URL[$idx-1]}" echo "Found $package in ${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}"
fi fi
break break
fi fi
@ -467,7 +467,7 @@ termux_download_deb() {
if [ "$PKG_HASH" = "" ]; then if [ "$PKG_HASH" = "" ]; then
return 1 return 1
else else
termux_download ${TERMUX_REPO_URL[$idx-1]}/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/${TERMUX_REPO_COMPONENT[$idx-1]}/binary-${package_arch}/${deb_file} \ termux_download ${TERMUX_REPO_URL[$idx-1]}/${PKG_PATH} \
$TERMUX_COMMON_CACHEDIR-$package_arch/${deb_file} \ $TERMUX_COMMON_CACHEDIR-$package_arch/${deb_file} \
$PKG_HASH $PKG_HASH
return 0 return 0
@ -518,21 +518,30 @@ termux_step_get_repo_files() {
gpg --import ${TERMUX_REPO_SIGNING_KEYS} gpg --import ${TERMUX_REPO_SIGNING_KEYS}
for idx in $(seq ${#TERMUX_REPO_URL[@]}); do for idx in $(seq ${#TERMUX_REPO_URL[@]}); do
local TERMUX_REPO_NAME=$(echo ${TERMUX_REPO_URL[$idx-1]} | sed -e 's%https://%%g' -e 's%http://%%g' -e 's%/dists%%g' -e 's%/%-%g') local TERMUX_REPO_NAME=$(echo ${TERMUX_REPO_URL[$idx-1]} | sed -e 's%https://%%g' -e 's%http://%%g' -e 's%/%-%g')
curl --fail -L "${TERMUX_REPO_URL[$idx-1]}/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/InRelease" \ curl --fail -L "${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/InRelease" \
-o ${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-InRelease \ -o ${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-InRelease \
|| termux_error_exit "Download of ${TERMUX_REPO_URL[$idx-1]}/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/InRelease failed" || curl --fail -L "${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/Release.gpg" \
-o ${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-Release.gpg \
&& curl --fail -L "${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/Release" \
-o ${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-Release \
|| termux_error_exit "Download of InRelease and Release.gpg from ${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]} failed"
if [ -f ${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-InRelease ]; then
local RELEASE_FILE=${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-InRelease
gpg --verify $RELEASE_FILE
else
local RELEASE_FILE=${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-Release
gpg --verify ${RELEASE_FILE}.gpg $RELEASE_FILE
fi
gpg --verify ${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-InRelease
for arch in all $TERMUX_ARCH; do for arch in all $TERMUX_ARCH; do
local packages_hash=$(./scripts/get_hash_from_file.py ${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-InRelease \ local packages_hash=$(./scripts/get_hash_from_file.py ${RELEASE_FILE} $arch ${TERMUX_REPO_COMPONENT[$idx-1]})
$arch ${TERMUX_REPO_COMPONENT[$idx-1]})
# If packages_hash = "" then the repo probably doesn't contain debs for $arch # If packages_hash = "" then the repo probably doesn't contain debs for $arch
if ! [ "$packages_hash" = "" ]; then if ! [ "$packages_hash" = "" ]; then
termux_download "${TERMUX_REPO_URL[$idx-1]}/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/${TERMUX_REPO_COMPONENT[$idx-1]}/binary-$arch/Packages.xz" \ termux_download "${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/${TERMUX_REPO_COMPONENT[$idx-1]}/binary-$arch/Packages" \
"${TERMUX_COMMON_CACHEDIR}-$arch/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-${TERMUX_REPO_COMPONENT[$idx-1]}-Packages.xz" \ "${TERMUX_COMMON_CACHEDIR}-$arch/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-${TERMUX_REPO_COMPONENT[$idx-1]}-Packages" \
$packages_hash $packages_hash
xz --keep -df "${TERMUX_COMMON_CACHEDIR}-$arch/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-${TERMUX_REPO_COMPONENT[$idx-1]}-Packages.xz"
fi fi
done done
done done

View File

@ -8,7 +8,10 @@ def get_pkg_hash_from_Packages(Packages_file, package, version, hash="SHA256"):
for pkg in package_list: for pkg in package_list:
if pkg.split('\n')[0] == "Package: "+package: if pkg.split('\n')[0] == "Package: "+package:
for line in pkg.split('\n'): for line in pkg.split('\n'):
if line.startswith('Version:'): # Assuming Filename: comes before Version:
if line.startswith('Filename:'):
print(line.split(" ")[1] + " ")
elif line.startswith('Version:'):
if line != 'Version: '+version: if line != 'Version: '+version:
# Seems the repo contains the wrong version, or several versions # Seems the repo contains the wrong version, or several versions
# We can't use this one so continue looking # We can't use this one so continue looking
@ -17,10 +20,10 @@ def get_pkg_hash_from_Packages(Packages_file, package, version, hash="SHA256"):
print(line.split(" ")[1]) print(line.split(" ")[1])
break break
def get_Packages_hash_from_InRelease(InRelease_file, arch, component, hash="SHA256"): def get_Packages_hash_from_Release(Release_file, arch, component, hash="SHA256"):
string_to_find = component+'/binary-'+arch+'/Packages.xz' string_to_find = component+'/binary-'+arch+'/Packages'
with open(InRelease_file, 'r') as InRelease: with open(Release_file, 'r') as Release:
hash_list = InRelease.readlines() hash_list = Release.readlines()
for i in range(len(hash_list)): for i in range(len(hash_list)):
if hash_list[i].startswith(hash+':'): if hash_list[i].startswith(hash+':'):
break break
@ -35,7 +38,7 @@ if __name__ == '__main__':
if sys.argv[1].endswith('Packages'): if sys.argv[1].endswith('Packages'):
get_pkg_hash_from_Packages(sys.argv[1], sys.argv[2], sys.argv[3]) get_pkg_hash_from_Packages(sys.argv[1], sys.argv[2], sys.argv[3])
elif sys.argv[1].endswith('InRelease'): elif sys.argv[1].endswith(('InRelease', 'Release')):
get_Packages_hash_from_InRelease(sys.argv[1], sys.argv[2], sys.argv[3]) get_Packages_hash_from_Release(sys.argv[1], sys.argv[2], sys.argv[3])
else: else:
sys.exit(sys.argv[1]+' does not seem to be a path to a Packages or InRelease file') sys.exit(sys.argv[1]+' does not seem to be a path to a Packages or InRelease/Release file')