system/tzupdate: Added (timezone util).

Signed-off-by: Andrew Clemons <andrew.clemons@gmail.com>

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
Lockywolf 2023-12-03 20:59:29 +09:00 committed by Willy Sudiarto Raharjo
parent 0d39e40951
commit e5cf141fcd
No known key found for this signature in database
GPG Key ID: 3F617144D7238786
4 changed files with 326 additions and 0 deletions

14
system/tzupdate/README Normal file
View File

@ -0,0 +1,14 @@
tzupdate
tzupdate is a fully automated utility to set the system time using
geolocation.
Internally, this geolocates you, gets the timezone for that geolocation,
and then updates the system's local time zone.
You can see what tzupdate would do without actually doing it by passing
-p, and specify an alternative IP address by using -i. This is not an
exhaustive list of options, see tzupdate --help for that.
NOTE: Do not trust its results blindly. It does what it can, but
determining a time zone based on an IP is inherently unreliable.

View File

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
tzupdate: tzupdate ( utility to set the system time using geolocation)
tzupdate:
tzupdate: Small, easy to understand codebase. Queries multiple geolocation
tzupdate: services in parallel and returns the first with a successful result.
tzupdate: Protects against directory traversal and invalid results when
tzupdate: linking /etc/localtime
tzupdate:
tzupdate:
tzupdate:
tzupdate:
tzupdate:

View File

@ -0,0 +1,165 @@
#!/bin/bash
# Slackware build script for tzupdate
# Copyright 2023, Lockywolf
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=tzupdate
VERSION=${VERSION:-3.1.0_e6815b}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
COMMIT="e6815b34d3bb37661ba8b677f30db408de651c7f"
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i586 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
# the name of the created package would be, and then exit. This information
# could be useful to other scripts.
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
exit 0
fi
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
elif [ "$ARCH" = "aarch64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$COMMIT
tar xvf $CWD/$PRGNAM-$COMMIT.tar.gz
cd $PRGNAM-$COMMIT
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
rm -rf $TMP/$TARNAM-$VERSION/.cargo
mkdir .cargo
cat << EOF >> .cargo/config
[source.crates-io]
registry = 'https://github.com/rust-lang/crates.io-index'
replace-with = 'vendored-sources'
[source.vendored-sources]
directory = '$(pwd)/vendor'
EOF
# deps and versions come from Cargo.lock
mkdir vendor
(
cd vendor
grep -h -A 3 "\[\[package\]\]" $(find ../ -maxdepth 1 -mindepth 1 -name Cargo.lock | tr '\n' ' ') | \
sed 's/[[:space:]]*=[[:space:]]*/=/g;s/^--//;s/^\[\[/--\n[[/' | \
awk 'BEGIN { RS = "--\n" ; FS="\n" } { print $2, $3, $4 }' | sed 's/"//g;s/name=//;s/ version=/=/' | \
grep crates\.io-index | sed 's/ source=.*$//' | sort -u | while read -r dep ; do
ver="$(printf "%s\n" "$dep" | cut -d= -f2)"
dep="$(printf "%s\n" "$dep" | cut -d= -f1)"
tar xvf $CWD/$dep-$ver.crate
touch $dep-$ver/.cargo-ok
# generate checksum
{
printf "{\n"
printf ' "files": {\n'
(
cd $dep-$ver
find . -type f -print0 | xargs -0 sha256sum | sed -n '/\.cargo-checksum\.json/!p' | sed 's/\.\///;s/^\([^ ]*\)[[:space:]][[:space:]]*\(.*\)$/"\2":"\1",/'
) | sed '$ s/,$//'
printf " },\n"
printf ' "package": "'
sha256sum "$CWD/$dep-$ver.crate" | cut -f1 -d' ' | sed 's/$/"/'
printf "}\n"
} > $dep-$ver/.cargo-checksum.json
done
)
export PATH="/opt/rust16/bin:$PATH"
if [ -z "$LD_LIBRARY_PATH" ]; then
export LD_LIBRARY_PATH="/opt/rust16/lib$LIBDIRSUFFIX"
else
export LD_LIBRARY_PATH="/opt/rust16/lib$LIBDIRSUFFIX:$LD_LIBRARY_PATH"
fi
CARGO_HOME=.cargo \
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
cargo build --release --locked
CARGO_HOME=.cargo \
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
cargo install --no-track --locked --root "$PKG/usr" --path .
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a \
README.md LICENSE \
$PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE

View File

@ -0,0 +1,128 @@
PRGNAM="tzupdate"
VERSION="3.1.0_e6815b"
HOMEPAGE="https://github.com/cdown/tzupdate"
DOWNLOAD="https://github.com/cdown/tzupdate/archive/e6815b34d3bb37661ba8b677f30db408de651c7f/tzupdate-e6815b34d3bb37661ba8b677f30db408de651c7f.tar.gz \
https://static.crates.io/crates/anstyle/anstyle-1.0.4.crate \
https://static.crates.io/crates/anyhow/anyhow-1.0.75.crate \
https://static.crates.io/crates/base64/base64-0.21.5.crate \
https://static.crates.io/crates/bitflags/bitflags-1.3.2.crate \
https://static.crates.io/crates/bitflags/bitflags-2.4.1.crate \
https://static.crates.io/crates/cc/cc-1.0.83.crate \
https://static.crates.io/crates/cfg-if/cfg-if-1.0.0.crate \
https://static.crates.io/crates/clap/clap-4.4.10.crate \
https://static.crates.io/crates/clap_builder/clap_builder-4.4.9.crate \
https://static.crates.io/crates/clap_derive/clap_derive-4.4.7.crate \
https://static.crates.io/crates/clap_lex/clap_lex-0.6.0.crate \
https://static.crates.io/crates/env_logger/env_logger-0.10.1.crate \
https://static.crates.io/crates/errno/errno-0.3.7.crate \
https://static.crates.io/crates/fastrand/fastrand-2.0.1.crate \
https://static.crates.io/crates/form_urlencoded/form_urlencoded-1.2.1.crate \
https://static.crates.io/crates/getrandom/getrandom-0.2.11.crate \
https://static.crates.io/crates/heck/heck-0.4.1.crate \
https://static.crates.io/crates/humantime/humantime-2.1.0.crate \
https://static.crates.io/crates/idna/idna-0.5.0.crate \
https://static.crates.io/crates/itoa/itoa-1.0.9.crate \
https://static.crates.io/crates/libc/libc-0.2.150.crate \
https://static.crates.io/crates/linux-raw-sys/linux-raw-sys-0.4.11.crate \
https://static.crates.io/crates/log/log-0.4.20.crate \
https://static.crates.io/crates/once_cell/once_cell-1.18.0.crate \
https://static.crates.io/crates/percent-encoding/percent-encoding-2.3.1.crate \
https://static.crates.io/crates/proc-macro2/proc-macro2-1.0.70.crate \
https://static.crates.io/crates/quote/quote-1.0.33.crate \
https://static.crates.io/crates/redox_syscall/redox_syscall-0.4.1.crate \
https://static.crates.io/crates/ring/ring-0.17.5.crate \
https://static.crates.io/crates/rustix/rustix-0.38.25.crate \
https://static.crates.io/crates/rustls-webpki/rustls-webpki-0.101.7.crate \
https://static.crates.io/crates/rustls/rustls-0.21.9.crate \
https://static.crates.io/crates/ryu/ryu-1.0.15.crate \
https://static.crates.io/crates/sct/sct-0.7.1.crate \
https://static.crates.io/crates/serde/serde-1.0.193.crate \
https://static.crates.io/crates/serde_derive/serde_derive-1.0.193.crate \
https://static.crates.io/crates/serde_json/serde_json-1.0.108.crate \
https://static.crates.io/crates/spin/spin-0.9.8.crate \
https://static.crates.io/crates/syn/syn-2.0.39.crate \
https://static.crates.io/crates/tempfile/tempfile-3.8.1.crate \
https://static.crates.io/crates/tinyvec/tinyvec-1.6.0.crate \
https://static.crates.io/crates/tinyvec_macros/tinyvec_macros-0.1.1.crate \
https://static.crates.io/crates/unicode-bidi/unicode-bidi-0.3.13.crate \
https://static.crates.io/crates/unicode-ident/unicode-ident-1.0.12.crate \
https://static.crates.io/crates/unicode-normalization/unicode-normalization-0.1.22.crate \
https://static.crates.io/crates/untrusted/untrusted-0.9.0.crate \
https://static.crates.io/crates/ureq/ureq-2.9.1.crate \
https://static.crates.io/crates/url/url-2.5.0.crate \
https://static.crates.io/crates/wasi/wasi-0.11.0+wasi-snapshot-preview1.crate \
https://static.crates.io/crates/webpki-roots/webpki-roots-0.25.3.crate \
https://static.crates.io/crates/windows-sys/windows-sys-0.48.0.crate \
https://static.crates.io/crates/windows-targets/windows-targets-0.48.5.crate \
https://static.crates.io/crates/windows_aarch64_gnullvm/windows_aarch64_gnullvm-0.48.5.crate \
https://static.crates.io/crates/windows_aarch64_msvc/windows_aarch64_msvc-0.48.5.crate \
https://static.crates.io/crates/windows_i686_gnu/windows_i686_gnu-0.48.5.crate \
https://static.crates.io/crates/windows_i686_msvc/windows_i686_msvc-0.48.5.crate \
https://static.crates.io/crates/windows_x86_64_gnu/windows_x86_64_gnu-0.48.5.crate \
https://static.crates.io/crates/windows_x86_64_gnullvm/windows_x86_64_gnullvm-0.48.5.crate \
https://static.crates.io/crates/windows_x86_64_msvc/windows_x86_64_msvc-0.48.5.crate"
MD5SUM="b056f345d320331a40a16104133129c1 \
b4f71ffecd3694a82ffb62c357d997a8 \
39a78bec5a0ae75f210c1f67250152b0 \
577bba6ae4d7493e169ca895141dd106 \
a295edb6953237ebbdfa8e731229f9a3 \
ebcf604c44976809506192718f439dc1 \
9241fa90ea8b17c00010be46c9aa1ac5 \
74634128440dbc3766bda76fdf0aaa05 \
b9fb1a6efa893a291dc40b8f67894047 \
7a5fbad4068946fdd6cf5020683d847c \
08b9a34eadbb01ac16e36694e53eb254 \
8f177f61a37d63f805acb925b30a0e58 \
80a78a0fcf1ea91382db857c8e10c8fe \
24f6202003a936e73e51f47584ea8bea \
80e1c1b89d858c93fc5946b4a8266504 \
c3e51926c9853b714191ef1bec90e2ce \
3b00daaa372df161c5c8eeaf16a741d1 \
b92fa50f56a1e06a7f1bf665442d4a73 \
c01022fe0357c10ca1d48b16187f81bd \
b5305bde14813da51d536a9df564db69 \
c6e20d23948f86627f5d4668e7ca43e3 \
5a8dc4bf5c57a6487a7247a635347cc9 \
c0be6754bd3aef87de8cbc405f9f1673 \
8ee79b4fe4c43d9ab09f16344612a656 \
2dc8aacabbc090f8025a4789d4d6d8f0 \
0ba30a94d7b8865c23e86d4d64e5b91e \
3f210fd91912a2d7d2f0af5038704d17 \
0ddb8bccd3198892d0dd0ec7151f7cd3 \
ff1d093069cfc9eb161907e17a51208b \
118b8b86f9aa5ae7adc04d0e0dc01642 \
9bdda698a3c8ba141f4daba1a7630143 \
9a668fb72cd7aeefb4e48fc37bdc0a4e \
f615260189f3714be67797e8ad42a666 \
254042a2a29ae1d79b96a283c8cc251f \
c5a05bb3260e6a4b5d61cf78618f6021 \
d6c1f2447aa984e398cdfdeb4cd75d44 \
d43f1621c76532ffdc7990d23593c61b \
3ed0ebc631b1840f3be21e1ba07fa4ed \
ae0a9c293bf6cb72cd62d6b9486356c0 \
16236f1edd28a8895ad8c3de8de226d8 \
f80faded72df19d43134e2b44137376a \
5f0470696baaa4e5953bddbf196998f9 \
c678a7da0ee4b850ebde0474144a0415 \
04c5de5f2fcb441ced909a45cff020bd \
ca65153603a1a7240bbd9d2ce19f2d67 \
c12d182417999fc365f952e701f6071f \
674e5a6b49cf5e0ebb1d6cc85f6ec786 \
23b29676b5f70e5155a2502f20f8d21e \
e547b0e754cd61f24f9ef8c9e26fcd95 \
e972ea58ec203bfa6c79c1207852298b \
501eb875ed9de4f2e1422f5579833a78 \
f2797ade0e36f1e5d6be9d11b5076582 \
24c64817e85ef77765ed0f26c31c9b4c \
dae6d89034a6988042fd8be4cf5e037d \
de2839e16d9d7a9fd1c397da62f62b4a \
e0c35ffb8cfdb74a39bf799811f79304 \
d990172b607020701f9e84ca8e1c043c \
0a68848588e847ceccf504891584d00b \
45b469ad607b912256b7c80141fa2d17 \
7799baff9a5664205d9110a2624e8989"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES="rust16"
MAINTAINER="Lockywolf"
EMAIL="for_sbo.tzupdate_2023-12-03@lockywolf.net"