Compare commits
2 commits
7f8c1f9dd0
...
bc86960680
Author | SHA1 | Date | |
---|---|---|---|
Alex Janka | bc86960680 | ||
Alex Janka | 6d537d299a |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
debs/
|
||||
build/
|
||||
apikeys.sh
|
||||
|
|
2
Makefile
2
Makefile
|
@ -7,7 +7,7 @@ default: all
|
|||
|
||||
.PHONY: all
|
||||
all:
|
||||
for target in $(TARGETS); do ./build.sh $$target $(ARCHITECTURES); done
|
||||
for target in $(TARGETS); do for architecture in $(ARCHITECTURES); do ./build.sh $$target $$architecture; done; done
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
|
|
166
build.sh
166
build.sh
|
@ -3,29 +3,68 @@
|
|||
SCRIPT_PATH="${0:A:h}"
|
||||
source $SCRIPT_PATH/apikeys.sh
|
||||
|
||||
if (( $+commands[gsed] )); then
|
||||
alias sed=gsed
|
||||
fi
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "please give me target and architecture(s) plss..."
|
||||
exit
|
||||
fi
|
||||
|
||||
target=${1:l}
|
||||
shift
|
||||
NAME_CAPS=${(C)target}
|
||||
config_path=$SCRIPT_PATH/config/$target.config.sh
|
||||
if [ ! -f $config_path ]; then
|
||||
echo "Config for $NAME_CAPS not found:"
|
||||
echo "Expected config at $config_path"
|
||||
exit 1
|
||||
if (( $+commands[gsed] )); then
|
||||
alias sed=gsed
|
||||
fi
|
||||
if (( $+commands[gdate] )); then
|
||||
alias date=gdate
|
||||
fi
|
||||
source $config_path
|
||||
export VERSION=$(jq -r '.name' <<<$JSON)
|
||||
echo "Building $NAME_CAPS v$VERSION for architectures: $@"
|
||||
|
||||
control_file="Source: $target
|
||||
target=${1:l}
|
||||
architecture=${2:l}
|
||||
NAME_CAPS=${(C)target}
|
||||
|
||||
echo "Building $NAME_CAPS..."
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
BUILD_DIR=$TEMP_DIR/build
|
||||
mkdir -p $BUILD_DIR
|
||||
|
||||
DEBIAN_DIR=$BUILD_DIR/debian
|
||||
mkdir -p $DEBIAN_DIR
|
||||
|
||||
|
||||
curl -Ls https://api.github.com/repos/$NAME_CAPS/$NAME_CAPS/releases --header "Authorization: Bearer $GITHUB_API_KEY" --header "X-GitHub-Api-Version: 2022-11-28" | jq -c '.[]' | while read -r release; do
|
||||
version=$(jq -r '.name' <<<$release)
|
||||
echo "$target ($version) testing; urgency=medium"
|
||||
echo ""
|
||||
jq -r '.body' <<<$release | sed -e '/^\*/!d' -e '/\*$/d' | sed -E 's/\*\*/-/g' | while read -r line; do
|
||||
echo " $line"
|
||||
done
|
||||
author=$(jq -r '.author.login' <<<$release)
|
||||
date=$(jq -r '.published_at' <<<$release)
|
||||
date=$(date --date="$date" -R)
|
||||
echo ""
|
||||
echo " $author $date"
|
||||
echo ""
|
||||
done > $DEBIAN_DIR/changelog
|
||||
|
||||
source $SCRIPT_PATH/config/$target.config.sh
|
||||
|
||||
VERSION=$(jq -r '.name' <<<$JSON)
|
||||
|
||||
echo "\tVersion: $VERSION"
|
||||
|
||||
echo 12 > $DEBIAN_DIR/compat
|
||||
echo "#!/usr/bin/make -f
|
||||
|
||||
clean:
|
||||
|
||||
build:
|
||||
|
||||
binary:
|
||||
dh_installsysusers
|
||||
dh_installsystemd
|
||||
dh_installtmpfiles
|
||||
dh_gencontrol
|
||||
dh_builddeb" > $DEBIAN_DIR/rules
|
||||
echo "Source: $target
|
||||
Section: $SECTION
|
||||
Priority: optional
|
||||
Maintainer: alex
|
||||
|
@ -33,20 +72,22 @@ Maintainer: alex
|
|||
Package: $target
|
||||
Depends: $DEPENDS
|
||||
Version: $VERSION
|
||||
Architecture: REPLACE_ARCHITECTURE
|
||||
Description: $target"
|
||||
Architecture: $architecture
|
||||
Description: $target" > $DEBIAN_DIR/control
|
||||
|
||||
package_control_file="Package: $target
|
||||
Maintainer: alex
|
||||
Depends: $DEPENDS
|
||||
Version: $VERSION
|
||||
Architecture: REPLACE_ARCHITECTURE
|
||||
Description: $target"
|
||||
PKG_DIR=$DEBIAN_DIR/$target
|
||||
mkdir -p $PKG_DIR
|
||||
|
||||
package_info="PackageAuthor=alex
|
||||
UpdateMethod=External
|
||||
UpdateMethodMessage=rebuild apt packages
|
||||
Branch=$BRANCH"
|
||||
tmpfiles_file="# Override this file with a modified version in /etc/tmpfiles.d/
|
||||
d /var/lib/$target 0755 $target $target
|
||||
Z /var/lib/$target - $target $target
|
||||
Z /usr/lib/$target - $target $target
|
||||
L /var/log/$target - - - - /var/lib/$target/logs/"
|
||||
echo $tmpfiles_file > $DEBIAN_DIR/$target.tmpfiles
|
||||
|
||||
sysusers_file="u $target - - /var/lib/$target
|
||||
g $target -"
|
||||
echo $sysusers_file > $DEBIAN_DIR/$target.sysusers
|
||||
|
||||
service_file="# Be sure to use \`systemctl edit $target\` to modify this service with an override.conf because
|
||||
# direct changes will be overwritten by package updates.
|
||||
|
@ -66,29 +107,8 @@ Type=simple
|
|||
[Install]
|
||||
WantedBy=multi-user.target"
|
||||
|
||||
sysusers_file="$target home=/var/lib/$target"
|
||||
echo $service_file > $DEBIAN_DIR/$target.service
|
||||
|
||||
tmpfiles_file="# Override this file with a modified version in /etc/tmpfiles.d/
|
||||
d /var/lib/$target 0755 $target $target
|
||||
Z /var/lib/$target - $target $target
|
||||
Z /usr/lib/$target - $target $target
|
||||
L /var/log/$target - - - - /var/lib/$target/logs/"
|
||||
|
||||
postinst_file="#!/bin/sh
|
||||
|
||||
SERVER_GROUP=$target
|
||||
|
||||
if ! getent group | grep -q \"^$target:\" ; then
|
||||
echo -n \"Adding group $target..\"
|
||||
addgroup --quiet --system $target 2>/dev/null ||true
|
||||
echo \"..done\"
|
||||
fi
|
||||
|
||||
adduser $target \
|
||||
--system \
|
||||
--home /var/lib/$target \
|
||||
--ingroup $target \
|
||||
--disabled-password"
|
||||
|
||||
rel_info=$(jq '.assets[] | select(.name | contains("linux")) | select(.name | contains("musl") | not)' <<<$JSON)
|
||||
declare -a tarballs=($(jq '"\(.browser_download_url) /\(.name)"' <<<$rel_info | tr -d '"' | tr "\n" " "))
|
||||
|
@ -109,39 +129,19 @@ for ((i = 1; i < ${#tarballs[@]}; i += 2)); do
|
|||
if [[ "$arch" == "core-arm64" ]]; then
|
||||
arch="arm64"
|
||||
fi
|
||||
if (( $@[(Ie)$arch])); then
|
||||
echo "Building for $arch..."
|
||||
dir=$(mktemp -d)
|
||||
deb_dir=$dir/debian
|
||||
mkdir -p $deb_dir
|
||||
echo $control_file | sed -E "s/REPLACE_ARCHITECTURE/$arch/g" > $deb_dir/control
|
||||
echo $sysusers_file > $deb_dir/$target.sysuser
|
||||
pkgdir=$deb_dir/$target
|
||||
|
||||
mkdir -p $pkgdir/usr/lib/systemd/system
|
||||
echo $service_file > $pkgdir/usr/lib/systemd/system/$target.service
|
||||
|
||||
mkdir -p $pkgdir/usr/lib/tmpfiles.d
|
||||
echo $tmpfiles_file > $pkgdir/usr/lib/tmpfiles.d/$target.conf
|
||||
|
||||
mkdir -p $pkgdir/usr/lib/$target
|
||||
echo "$package_info\nPackageVersion=$VERSION" >$pkgdir/usr/lib/$target/package_info
|
||||
|
||||
curl -Ls $url | tar xz -C $pkgdir/
|
||||
rm -rf $pkgdir/$NAME_CAPS/$NAME_CAPS.Update
|
||||
mv $pkgdir/$NAME_CAPS $pkgdir/usr/lib/$target/bin
|
||||
chmod -R a=,a+rX,u+w $pkgdir/usr/lib/$target/bin
|
||||
chmod +x $pkgdir/usr/lib/$target/bin/$NAME_CAPS
|
||||
|
||||
deb_pkg_dir=$pkgdir/DEBIAN
|
||||
mkdir -p $deb_pkg_dir
|
||||
echo $package_control_file | sed -E "s/REPLACE_ARCHITECTURE/$arch/g" > $deb_pkg_dir/control
|
||||
|
||||
mkdir -p $SCRIPT_PATH/debs
|
||||
cd $dir
|
||||
dh_builddeb --destdir $SCRIPT_PATH/debs
|
||||
rm -rf $dir
|
||||
else
|
||||
echo "Skipping arch $arch"
|
||||
if [[ "$arch" == "$architecture" ]]; then
|
||||
curl -Ls $url | tar xz -C $BUILD_DIR/
|
||||
rm -rf $BUILD_DIR/$NAME_CAPS/$NAME_CAPS.Update
|
||||
install -d -m 755 "$PKG_DIR/usr/lib/$target/bin"
|
||||
cp -dpr --no-preserve=ownership "$BUILD_DIR/$NAME_CAPS"* "$PKG_DIR/usr/lib/$target/bin"
|
||||
fi
|
||||
done
|
||||
|
||||
cd $BUILD_DIR
|
||||
dpkg-buildpackage -b
|
||||
cd $TEMP_DIR
|
||||
rm -rf $BUILD_DIR
|
||||
OUT_DIR=$SCRIPT_PATH/debs
|
||||
mkdir -p $OUT_DIR
|
||||
cp $TEMP_DIR/* $OUT_DIR
|
|
@ -1,7 +1,5 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
source ./apikeys.sh
|
||||
|
||||
export SECTION=sound
|
||||
export JSON=$(curl -Ls https://api.github.com/repos/Lidarr/Lidarr/releases/latest --header "Authorization: Bearer $GITHUB_API_KEY" --header "X-GitHub-Api-Version: 2022-11-28")
|
||||
export BRANCH=master
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
source ./apikeys.sh
|
||||
|
||||
export SECTION=web
|
||||
export JSON=$(curl -Ls https://api.github.com/repos/Prowlarr/Prowlarr/releases/latest --header "Authorization: Bearer $GITHUB_API_KEY" --header "X-GitHub-Api-Version: 2022-11-28")
|
||||
export BRANCH=master
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
source ./apikeys.sh
|
||||
|
||||
export SECTION=video
|
||||
export JSON=$(curl -Ls https://api.github.com/repos/Radarr/Radarr/releases/latest --header "Authorization: Bearer $GITHUB_API_KEY" --header "X-GitHub-Api-Version: 2022-11-28")
|
||||
export BRANCH=master
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
source ./apikeys.sh
|
||||
|
||||
export SECTION=misc
|
||||
export JSON=$(curl -Ls https://api.github.com/repos/Readarr/Readarr/releases --header "Authorization: Bearer $GITHUB_API_KEY" --header "X-GitHub-Api-Version: 2022-11-28" | jq 'map(select(.prerelease)) | first')
|
||||
export BRANCH=develop
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
source ./apikeys.sh
|
||||
|
||||
export SECTION=video
|
||||
export JSON=$(curl -Ls https://api.github.com/repos/Sonarr/Sonarr/releases/latest --header "Authorization: Bearer $GITHUB_API_KEY" --header "X-GitHub-Api-Version: 2022-11-28")
|
||||
export BRANCH=master
|
||||
|
|
Loading…
Reference in a new issue