2018-03-29 17:42:39 +02:00
|
|
|
#!/bin/bash
|
2018-03-25 20:36:38 +02:00
|
|
|
set -e # abort on first error
|
|
|
|
shopt -s nullglob
|
2021-04-07 09:59:30 +02:00
|
|
|
shopt -s extglob
|
2018-12-29 21:15:01 +01:00
|
|
|
source "$(dirname $0)/../versions.sh"
|
2018-03-25 20:36:38 +02:00
|
|
|
|
2020-12-10 23:07:29 +01:00
|
|
|
if ! [[ $DRY_RUN ]] && ! [[ $GITHUB_TOKEN ]]; then
|
2019-10-02 21:43:44 +02:00
|
|
|
echo "Don't forget to set \$GITHUB_TOKEN."
|
2023-07-07 23:49:45 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# determine GPGKEY to use and test signing
|
|
|
|
if [[ -f /etc/makepkg.conf ]]; then
|
|
|
|
source /etc/makepkg.conf
|
|
|
|
fi
|
|
|
|
if ! [[ $GPGKEY ]] && ! [[ $SKIP_SIGNING ]]; then
|
|
|
|
echo "You must set \$GPGKEY for signing or \$SKIP_SIGNING to skip signing."
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
if [[ -n $GPGKEY ]]; then
|
|
|
|
# make helpers for signing used by buildservice available to this script as well
|
|
|
|
export PATH=/var/lib/buildservice-git/bin:/var/lib/buildservice:$PATH
|
|
|
|
SIGNWITHKEY=(-u "${GPGKEY}")
|
|
|
|
echo 'test' > /tmp/signing-test
|
|
|
|
if ! gpg --detach-sign --yes --use-agent "${SIGNWITHKEY[@]}" --no-armor /tmp/signing-test ; then
|
|
|
|
echo 'Not continuing, setup for signing is broken'
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
rm /tmp/signing-test*
|
|
|
|
echo "Will sign archives with key ${GPGKEY}"
|
2019-10-02 21:43:44 +02:00
|
|
|
fi
|
|
|
|
|
2020-12-10 23:07:29 +01:00
|
|
|
if [[ $DRY_RUN ]]; then
|
|
|
|
target=${DRY_RUN_TARGET:-$PWD}
|
|
|
|
fi
|
|
|
|
|
|
|
|
projects=(${PROJECTS:-${!versions[@]}})
|
|
|
|
|
2018-03-25 20:36:38 +02:00
|
|
|
repo_dir=${PATH_REPO_OWNSTUFF}
|
|
|
|
if ! [[ $repo_dir ]]; then
|
|
|
|
echo "\$PATH_REPO_OWNSTUFF is empty."
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
repo_dir+='/x86_64'
|
|
|
|
if ! [[ -d $repo_dir ]]; then
|
|
|
|
echo "\$PATH_REPO_OWNSTUFF/x86_64 does not point to a directory."
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# upload latest static mingw-w64 package of my projects on GitHub (if not already present)
|
2020-12-10 23:07:29 +01:00
|
|
|
for project in "${projects[@]}"
|
2018-03-25 20:36:38 +02:00
|
|
|
do
|
|
|
|
version=${versions[$project]}
|
|
|
|
gh_name=${github_names[$project]:-$project}
|
|
|
|
[[ $gh_name == 'skip' ]] && continue
|
|
|
|
[[ $version == 'none' ]] && continue
|
|
|
|
echo '------------------------------------------------------------------------'
|
|
|
|
echo "NEXT: $project/v$version"
|
2020-12-10 23:07:29 +01:00
|
|
|
temp_dir=$(mktemp -d -t "$project-XXXXXXXXXX")
|
|
|
|
zip_files=()
|
|
|
|
pushd "$temp_dir"
|
|
|
|
|
|
|
|
for variant in '' 'qt6'; do
|
|
|
|
[[ $variant ]] && variant_suffix=-$variant || variant_suffix=
|
2018-03-25 20:36:38 +02:00
|
|
|
|
2019-05-04 16:29:53 +02:00
|
|
|
# determine file path of arch linux package
|
2020-12-10 23:07:29 +01:00
|
|
|
pkg_name=mingw-w64-$project$variant_suffix
|
2021-04-07 09:59:30 +02:00
|
|
|
pkg_files=("$repo_dir/$pkg_name-$version"-*-*.pkg.tar.!(*.sig))
|
2019-05-04 16:29:53 +02:00
|
|
|
if [[ ${#pkg_files[@]} == 0 ]]; then
|
2020-12-10 23:07:29 +01:00
|
|
|
echo "no mingw-w64$variant_suffix package for $project/v$version present"
|
2018-03-25 20:36:38 +02:00
|
|
|
continue
|
|
|
|
fi
|
2019-05-04 16:29:53 +02:00
|
|
|
latest_pkg_file=${pkg_files[-1]}
|
2018-03-25 20:36:38 +02:00
|
|
|
|
2019-05-04 16:29:53 +02:00
|
|
|
# extract arch linux package
|
|
|
|
pkg_file_name=${latest_pkg_file##*/}
|
2019-11-09 02:52:44 +01:00
|
|
|
bsdtar xJf "$latest_pkg_file"
|
|
|
|
|
|
|
|
# locate the license file
|
|
|
|
license_file=usr/share/licenses/$pkg_name/LICENSES-windows-distribution.md
|
|
|
|
if [[ ! -f $license_file ]]; then
|
|
|
|
echo "the package $latest_pkg_file does not include the expected license file $license_file"
|
|
|
|
continue
|
|
|
|
fi
|
2019-05-04 16:29:53 +02:00
|
|
|
|
|
|
|
# make a zip file for each statically linked binary
|
|
|
|
for arch in i686-w64-mingw32 x86_64-w64-mingw32; do
|
|
|
|
binaries=(usr/$arch/bin/*-static.exe)
|
|
|
|
for binary in ${binaries[@]}; do
|
2023-04-29 21:24:35 +02:00
|
|
|
binary_cli=${binary%-static.exe}-static-cli.exe
|
2019-11-09 02:52:44 +01:00
|
|
|
base_name=${binary##*/}
|
|
|
|
base_name=${base_name%-static.exe}
|
|
|
|
symlink_name=$base_name-$arch.exe
|
2023-04-29 21:24:35 +02:00
|
|
|
symlink_name_cli=$base_name-$arch-cli.exe
|
2022-05-10 23:01:53 +02:00
|
|
|
# consider Qt 6 the suffixless default and use suffix for Qt 5 version instead
|
|
|
|
if [[ $base_name =~ .*-qt6 ]]; then
|
|
|
|
base_name=${base_name%-qt6}
|
|
|
|
else
|
|
|
|
base_name=${base_name}-qt5
|
|
|
|
fi
|
2019-11-09 02:52:44 +01:00
|
|
|
binary_name=$base_name-$version-$arch.exe
|
2023-04-29 21:24:35 +02:00
|
|
|
binary_name_cli=$base_name-$version-$arch-cli.exe
|
2019-08-25 13:32:16 +02:00
|
|
|
|
|
|
|
# check whether upload already exists
|
|
|
|
zip_file="$binary_name.zip"
|
2020-12-10 23:07:29 +01:00
|
|
|
if ! [[ $DRY_RUN ]] && github-release info --user martchus --repo "$gh_name" --tag "v$version" | grep "artifact: $zip_file"; then
|
2019-08-25 13:32:16 +02:00
|
|
|
echo "auto-skipping $project/v$version; $zip_file already present"
|
|
|
|
continue
|
2020-12-10 23:07:29 +01:00
|
|
|
elif [[ $DRY_RUN ]] && [[ -e $zip_file ]]; then
|
|
|
|
echo "auto-skipping $project/v$version; $zip_file already present (dry-run)"
|
|
|
|
continue
|
2019-08-25 13:32:16 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# create zip file
|
|
|
|
echo "zipping $binary to $zip_file"
|
2019-11-09 02:52:44 +01:00
|
|
|
mv "$binary" "$binary_name"
|
|
|
|
ln -s "$binary_name" "$symlink_name"
|
2023-06-06 21:55:06 +02:00
|
|
|
additional_files=()
|
2023-04-29 21:24:35 +02:00
|
|
|
if [[ -f $binary_cli ]]; then
|
|
|
|
mv "$binary_cli" "$binary_name_cli"
|
|
|
|
ln -s "$binary_name_cli" "$symlink_name_cli"
|
2023-06-06 21:55:06 +02:00
|
|
|
additional_files+=("$binary_name_cli")
|
2023-04-29 21:24:35 +02:00
|
|
|
fi
|
2019-11-09 02:52:44 +01:00
|
|
|
license_file_2=$project-$version-$arch-LICENSES.md
|
|
|
|
cp "$license_file" "$license_file_2"
|
2023-06-06 21:55:06 +02:00
|
|
|
bsdtar acf "$zip_file" "$binary_name" "$license_file_2" "${additional_files[@]}"
|
2019-08-25 13:32:16 +02:00
|
|
|
zip_files+=("$zip_file")
|
2019-05-04 16:29:53 +02:00
|
|
|
done
|
|
|
|
done
|
2020-12-10 23:07:29 +01:00
|
|
|
done
|
2022-05-02 21:53:41 +02:00
|
|
|
pkg_name=static-compat-$project
|
|
|
|
pkg_files=("$repo_dir/$pkg_name-$version"-*-*.pkg.tar.!(*.sig))
|
|
|
|
if [[ ${#pkg_files[@]} == 0 ]]; then
|
|
|
|
echo "no static-compat package for $project/v$version present"
|
|
|
|
else
|
|
|
|
latest_pkg_file=${pkg_files[-1]}
|
|
|
|
|
|
|
|
# extract arch linux package
|
|
|
|
pkg_file_name=${latest_pkg_file##*/}
|
|
|
|
bsdtar xJf "$latest_pkg_file"
|
|
|
|
|
|
|
|
# locate the license file
|
|
|
|
license_file=usr/share/licenses/$pkg_name/LICENSES-linux-distribution.md
|
|
|
|
if [[ ! -f $license_file ]]; then
|
|
|
|
echo "the package $latest_pkg_file does not include the expected license file $license_file"
|
|
|
|
fi
|
|
|
|
|
|
|
|
binaries=(usr/static-compat/bin/*)
|
|
|
|
arch=x86_64-pc-linux-gnu
|
|
|
|
for binary in ${binaries[@]}; do
|
|
|
|
base_name=${binary##*/}
|
|
|
|
symlink_name=$base_name-$arch
|
|
|
|
binary_name=$base_name-$version-$arch
|
|
|
|
|
|
|
|
# check whether upload already exists
|
|
|
|
zip_file="$binary_name.tar.xz"
|
|
|
|
if ! [[ $DRY_RUN ]] && github-release info --user martchus --repo "$gh_name" --tag "v$version" | grep "artifact: $zip_file"; then
|
|
|
|
echo "auto-skipping $project/v$version; $zip_file already present"
|
|
|
|
continue
|
|
|
|
elif [[ $DRY_RUN ]] && [[ -e $zip_file ]]; then
|
|
|
|
echo "auto-skipping $project/v$version; $zip_file already present (dry-run)"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# create zip file
|
|
|
|
echo "zipping $binary to $zip_file"
|
|
|
|
mv "$binary" "$binary_name"
|
|
|
|
ln -s "$binary_name" "$symlink_name"
|
|
|
|
#license_file_2=$project-$version-$arch-LICENSES.md
|
|
|
|
#cp "$license_file" "$license_file_2"
|
|
|
|
bsdtar acf "$zip_file" "$binary_name" "$symlink_name"
|
|
|
|
zip_files+=("$zip_file")
|
|
|
|
done
|
|
|
|
fi
|
2019-05-04 16:29:53 +02:00
|
|
|
|
2023-07-07 23:49:45 +02:00
|
|
|
# try next project and print warning if no files could be created
|
2019-05-04 16:29:53 +02:00
|
|
|
if [[ ${#zip_files[@]} == 0 ]]; then
|
2019-08-25 13:32:16 +02:00
|
|
|
echo "no zip files for $project/v$version could be created (either all skipped or no executables found)"
|
2018-03-25 20:36:38 +02:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2023-07-07 23:49:45 +02:00
|
|
|
# sign files
|
|
|
|
to_upload=()
|
2019-08-25 13:32:16 +02:00
|
|
|
for zip_file in ${zip_files[@]}; do
|
2023-07-07 23:49:45 +02:00
|
|
|
to_upload+=("$zip_file")
|
|
|
|
if ! [[ $GPGKEY ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo "signing $project/v$version -> $zip_file"
|
|
|
|
gpg --detach-sign --yes --use-agent "${SIGNWITHKEY[@]}" --no-armor "$zip_file"
|
|
|
|
to_upload+=("$zip_file.sig")
|
|
|
|
done
|
|
|
|
|
|
|
|
# upload files
|
|
|
|
for zip_file in ${to_upload[@]}; do
|
2019-05-04 16:29:53 +02:00
|
|
|
echo "uploading $project/v$version -> $zip_file"
|
2020-12-10 23:07:29 +01:00
|
|
|
if [[ $DRY_RUN ]]; then
|
2023-07-07 23:49:45 +02:00
|
|
|
mv --target-directory="$target" "$zip_file"
|
2020-12-10 23:07:29 +01:00
|
|
|
continue
|
|
|
|
fi
|
2019-05-04 16:29:53 +02:00
|
|
|
if github-release upload --user martchus --repo "$gh_name" --tag "v$version" --file "$zip_file" --name "$zip_file"; then
|
|
|
|
echo "SUCCESS: uploaded $project/v$version -> $zip_file"
|
|
|
|
else
|
|
|
|
echo "FAILURE: unable to upload $project/v$version -> $zip_file"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
popd
|
|
|
|
rm -r "$temp_dir"
|
2018-03-25 20:36:38 +02:00
|
|
|
done
|