python312Packages.types-aiobotocore-*: adjust update script

- to honor nixfmt
- prepare to generate entries for new packages
This commit is contained in:
Fabian Affolter 2024-05-24 21:09:49 +02:00
parent 8d5ad9166b
commit 96d8191bb1

View File

@ -1,15 +1,17 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix-update nixpkgs-fmt
#!nix-shell -i bash -p nix-update nixfmt curl jq
set -eu -o pipefail
source_file=pkgs/development/python-modules/types-aiobotocore-packages/default.nix
version="2.12.3"
#nix-update python312Packages.types-aiobotocore --commit --build
packages=(
types-aiobotocore-accessanalyzer
types-aiobotocore-account
types-aiobotocore-acm
types-aiobotocore-acm-pca
types-aiobotocore-alexaforbusiness
types-aiobotocore-amp
types-aiobotocore-amplify
@ -138,6 +140,7 @@ packages=(
types-aiobotocore-frauddetector
types-aiobotocore-fsx
types-aiobotocore-gamelift
# types-aiobotocore-gamesparks Obsolete, will be removed soon
types-aiobotocore-glacier
types-aiobotocore-globalaccelerator
types-aiobotocore-glue
@ -159,7 +162,7 @@ packages=(
types-aiobotocore-iot
types-aiobotocore-iot-data
types-aiobotocore-iot-jobs-data
types-aiobotocore-iot-roborunner
# types-aiobotocore-iot-roborunner Obsolete, will be removed soon
types-aiobotocore-iot1click-devices
types-aiobotocore-iot1click-projects
types-aiobotocore-iotanalytics
@ -207,6 +210,7 @@ packages=(
types-aiobotocore-lookoutvision
types-aiobotocore-m2
types-aiobotocore-machinelearning
# types-aiobotocore-macie Obsolete, will be removed soon
types-aiobotocore-macie2
types-aiobotocore-managedblockchain
types-aiobotocore-managedblockchain-query
@ -359,21 +363,34 @@ packages=(
types-aiobotocore-xray
)
for package in "${packages[@]}"; do
echo "Updating ${package}"
version=$(curl -s https://pypi.org/pypi/types-aiobotocore/json | jq -r '.info.version')
echo "All types-aiobotocore-* packages will be updated to ${version}"
url="https://pypi.io/packages/source/t/${package}/${package}-${version}.tar.gz"
for package in "${packages[@]}"; do
echo "Updating ${package} ..."
url="https://pypi.io/packages/source/t/${package}/${package//-/_}-${version}.tar.gz"
hash=$(nix-prefetch-url --type sha256 $url)
sri_hash="$(nix hash to-sri --type sha256 $hash)"
package_short="${package#types-aiobotocore-}"
awk -i inplace -v package="$package" -v new_version="$version" -v new_sha256="$sri_hash" '
$1 == package {
$5 = "\"" new_version "\"";
$6 = "\"" new_sha256 "\";";
}
{print}
' $source_file
awk -i inplace -v pkg="$package" -v pkg_short="$package_short" -v ver="$version" -v hash="$sri_hash" '
{
# If the line contains the package name
if ($0 ~ "^\\s*" pkg "\\s*=") {
print $0
inside_block = 1
} else if (inside_block && $0 ~ "buildTypesAiobotocorePackage") {
print " buildTypesAiobotocorePackage \"" "" pkg_short "\" \"" ver "\""
} else if (inside_block && $0 ~ "sha256-") {
print " \"" hash "\";"
inside_block = 0
} else {
# Preserve blank lines to honor nixfmt
print $0
}
}' ${source_file}
done
nixpkgs-fmt ${source_file}
nixfmt ${source_file}