Browse Source

Merge pull request #3353 from Grimler91/fast-build

build-package.sh: handle Release.gpg and get deb path from Package
android-5
Henrik Grimler 6 years ago
committed by GitHub
parent
commit
5bce9345c4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 35
      build-package.sh
  2. 19
      scripts/get_hash_from_file.py

35
build-package.sh

@ -454,12 +454,12 @@ termux_download_deb() {
local version=$3
local deb_file=${package}_${version}_${package_arch}.deb
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"
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 [ ! "$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
break
fi
@ -467,7 +467,7 @@ termux_download_deb() {
if [ "$PKG_HASH" = "" ]; then
return 1
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} \
$PKG_HASH
return 0
@ -518,21 +518,30 @@ termux_step_get_repo_files() {
gpg --import ${TERMUX_REPO_SIGNING_KEYS}
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')
curl --fail -L "${TERMUX_REPO_URL[$idx-1]}/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/InRelease" \
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]}/dists/${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
local packages_hash=$(./scripts/get_hash_from_file.py ${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-InRelease \
$arch ${TERMUX_REPO_COMPONENT[$idx-1]})
local packages_hash=$(./scripts/get_hash_from_file.py ${RELEASE_FILE} $arch ${TERMUX_REPO_COMPONENT[$idx-1]})
# If packages_hash = "" then the repo probably doesn't contain debs for $arch
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_COMMON_CACHEDIR}-$arch/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-${TERMUX_REPO_COMPONENT[$idx-1]}-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" \
$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
done
done

19
scripts/get_hash_from_file.py

@ -8,7 +8,10 @@ def get_pkg_hash_from_Packages(Packages_file, package, version, hash="SHA256"):
for pkg in package_list:
if pkg.split('\n')[0] == "Package: "+package:
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:
# Seems the repo contains the wrong version, or several versions
# 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])
break
def get_Packages_hash_from_InRelease(InRelease_file, arch, component, hash="SHA256"):
string_to_find = component+'/binary-'+arch+'/Packages.xz'
with open(InRelease_file, 'r') as InRelease:
hash_list = InRelease.readlines()
def get_Packages_hash_from_Release(Release_file, arch, component, hash="SHA256"):
string_to_find = component+'/binary-'+arch+'/Packages'
with open(Release_file, 'r') as Release:
hash_list = Release.readlines()
for i in range(len(hash_list)):
if hash_list[i].startswith(hash+':'):
break
@ -35,7 +38,7 @@ if __name__ == '__main__':
if sys.argv[1].endswith('Packages'):
get_pkg_hash_from_Packages(sys.argv[1], sys.argv[2], sys.argv[3])
elif sys.argv[1].endswith('InRelease'):
get_Packages_hash_from_InRelease(sys.argv[1], sys.argv[2], sys.argv[3])
elif sys.argv[1].endswith(('InRelease', 'Release')):
get_Packages_hash_from_Release(sys.argv[1], sys.argv[2], sys.argv[3])
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')

Loading…
Cancel
Save