main/swclock-offset: move to its own repository (MR 3642)

To make "swclock-offset" available to other projects as well, it was
moved to its own repository.
This commit is contained in:
Jakob Hauser 2022-11-13 22:47:32 +01:00 committed by Newbyte
parent fa69d91465
commit 67b5dd49dd
No known key found for this signature in database
GPG key ID: 990600ED1DB95E02
6 changed files with 7 additions and 128 deletions

View file

@ -24,8 +24,6 @@ sh_files="
./main/postmarketos-mkinitfs-hook-debug-shell/20-debug-shell.sh
./main/postmarketos-mkinitfs-hook-netboot/netboot.sh
./main/postmarketos-update-kernel/update-kernel.sh
./main/swclock-offset/swclock-offset-boot.sh
./main/swclock-offset/swclock-offset-shutdown.sh
./main/ttyescape/*.post-install
./main/unl0kr/unlock.sh
./main/msm-firmware-loader/*.post-install

View file

@ -1,21 +1,19 @@
# Maintainer: Jakko <jahau@rocketmail.com>
pkgname=swclock-offset
pkgver=0.2
pkgrel=2
pkgver=0.2.1
pkgrel=0
pkgdesc="Keep system time at an offset to a non-writable RTC"
url="https://gitlab.com/postmarketOS/pmaports"
url="https://gitlab.com/postmarketOS/swclock-offset"
arch="noarch"
license="GPL-3.0-or-later"
install="$pkgname.post-deinstall"
subpackages="$pkgname-openrc"
source="$pkgname-boot.initd $pkgname-shutdown.initd $pkgname-boot.sh $pkgname-shutdown.sh"
source="https://gitlab.com/postmarketOS/swclock-offset/-/archive/$pkgver/swclock-offset-$pkgver.tar.gz"
options="!check" # No tests
package() {
install -Dm755 "$srcdir/$pkgname-boot.initd" "$pkgdir/etc/init.d/$pkgname-boot"
install -Dm755 "$srcdir/$pkgname-shutdown.initd" "$pkgdir/etc/init.d/$pkgname-shutdown"
install -Dm755 "$srcdir/$pkgname-boot.sh" "$pkgdir/sbin/$pkgname-boot"
install -Dm755 "$srcdir/$pkgname-shutdown.sh" "$pkgdir/sbin/$pkgname-shutdown"
make DESTDIR="$pkgdir" install
make DESTDIR="$pkgdir" install_openrc
}
openrc() {
@ -24,8 +22,5 @@ openrc() {
}
sha512sums="
777dff161dcae742d1bfb7acbf413a319c9e623292a315ccd8cf5f3f0df9258d54d3e9891bdff741a6146ab285bc5a27c7921bc93902b4a2006104666a835ecd swclock-offset-boot.initd
a834fe9f721a4797f5675361fe07b500f93a2082753ed0a0fd583ccfd49738acfe04fb526e2936f3ce270053d151c7080a6a5356246fb816638e72992c6f77db swclock-offset-shutdown.initd
a3b7ea5963da066ddfec64dac56b4c15306de6e5dc0028a6d88e4fceef8b5229e0847c91fea556488476e281424883df7738a305ad9efb1a1531ec8eba493848 swclock-offset-boot.sh
36a6a1d8b9907e3b8e2342cb20b29fecd5904d4fb01c81e67e528242cb8b5f8e7745ecee69a1be797ee5ffae2156419e21e68118393394ccb1c808a5268490a3 swclock-offset-shutdown.sh
ce33a47adf5c72ae3b668a0e072157e45c6b8677b54891de1e8f9979ff9ed4b8bd178c2e7f78e574647ce462681e9ddc2cbd078ff1943cd3dcf58bf1c1468afb swclock-offset-0.2.1.tar.gz
"

View file

@ -1,23 +0,0 @@
#!/sbin/openrc-run
# To avoid time inconsistency at filesystems check, the system time
# shall be set before "fsck".
description="Setting the system time according to an offset file."
depend()
{
before fsck
}
start()
{
ebegin "Setting system time"
/sbin/swclock-offset-boot
eend $?
}
stop()
{
return 0
}

View file

@ -1,32 +0,0 @@
#!/bin/sh
# This shell scripts reads the offset from the file and sets the 'swclock'.
#
# To keep the offset calculation simple, the epoch timestamp is used.
#
# The RTC is read from the sysfs node.
#
# To set the system time, command "date" is used. The "@" sign marks an
# epoch time format. As the "date" command offers no quiet option, the
# output is written to the null device.
rtc_sys_node="/sys/class/rtc/rtc0/since_epoch"
offset_file="/var/cache/swclock-offset/offset-storage"
# check presence of rtc sys node
if [ ! -f $rtc_sys_node ]; then
exit 1
fi
# check presence of offset file
if [ ! -f $offset_file ]; then
exit 2
fi
# calculate system time
hwclock_epoch=$(cat $rtc_sys_node)
offset_epoch=$(cat $offset_file)
swclock_epoch=$((hwclock_epoch + offset_epoch))
# set system time, dump output
date --utc --set=@$swclock_epoch > /dev/null

View file

@ -1,29 +0,0 @@
#!/sbin/openrc-run
# A dedicated shutdown service is used to write the offset file instead
# of using the stop function of the swclock-offset service at boot. This
# approach is more fail-safe on different installation/deinstallation
# situations.
#
# Because the shutdown services are performed late within the shutdown
# runlevel, dependencies are needed to execute the script before
# processes are killed and filesystems are remounted read-only.
description="Writing the offset between system time and RTC to a file."
depend()
{
before killprocs mount-ro
}
start()
{
ebegin "Saving swclock-offset"
/sbin/swclock-offset-shutdown
eend $?
}
stop()
{
return 0
}

View file

@ -1,30 +0,0 @@
#!/bin/sh
# This shell scripts writes the offset between 'hwclock' and 'swclock'
# to a file.
#
# To keep the offset calculation simple, the epoch timestamp is used.
#
# The system time is read by command "date". The RTC is read from the
# sysfs node.
rtc_sys_node="/sys/class/rtc/rtc0/since_epoch"
offset_directory="/var/cache/swclock-offset"
# check presence of rtc sys node
if [ ! -f $rtc_sys_node ]; then
exit 1
fi
# check presence of offset directory
if [ ! -d $offset_directory ]; then
mkdir -p $offset_directory
fi
# calculate offset
swclock_epoch=$(date --utc +%s)
hwclock_epoch=$(cat $rtc_sys_node)
offset_epoch=$((swclock_epoch - hwclock_epoch))
# write offset file
echo $offset_epoch > $offset_directory/offset-storage