all: sync with master; upd chlog
This commit is contained in:
77
scripts/snap/build.sh
Normal file
77
scripts/snap/build.sh
Normal file
@@ -0,0 +1,77 @@
|
||||
#!/bin/sh
|
||||
|
||||
verbose="${VERBOSE:-0}"
|
||||
|
||||
if [ "$verbose" -gt '0' ]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
set -e -f -u
|
||||
|
||||
# Function log is an echo wrapper that writes to stderr if the caller requested
|
||||
# verbosity level greater than 0. Otherwise, it does nothing.
|
||||
#
|
||||
# TODO(a.garipov): Add to helpers.sh and use more actively in scripts.
|
||||
log() {
|
||||
if [ "$verbose" -gt '0' ]
|
||||
then
|
||||
# Don't use quotes to get word splitting.
|
||||
echo "$1" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
version="$( ./AdGuardHome_amd64 --version | cut -d ' ' -f 4 )"
|
||||
if [ "$version" = '' ]
|
||||
then
|
||||
log 'empty version from ./AdGuardHome_amd64'
|
||||
exit 1
|
||||
fi
|
||||
readonly version
|
||||
|
||||
log "version '$version'"
|
||||
|
||||
for arch in\
|
||||
'i386'\
|
||||
'amd64'\
|
||||
'armhf'\
|
||||
'arm64'
|
||||
do
|
||||
build_output="./AdGuardHome_${arch}"
|
||||
snap_output="./AdGuardHome_${arch}.snap"
|
||||
snap_dir="${snap_output}.dir"
|
||||
|
||||
# Create the meta subdirectory and copy files there.
|
||||
mkdir -p "${snap_dir}/meta"
|
||||
cp "$build_output" "${snap_dir}/AdGuardHome"
|
||||
cp './snap/local/adguard-home-web.sh' "$snap_dir"
|
||||
cp -r './snap/gui' "${snap_dir}/meta/"
|
||||
|
||||
# Create a snap.yaml file, setting the values.
|
||||
sed\
|
||||
-e 's/%VERSION%/'"$version"'/'\
|
||||
-e 's/%ARCH%/'"$arch"'/'\
|
||||
./snap/snap.tmpl.yaml\
|
||||
> "${snap_dir}/meta/snap.yaml"
|
||||
|
||||
# TODO(a.garipov): The snapcraft tool will *always* write everything,
|
||||
# including errors, to stdout. And there doesn't seem to be a way to change
|
||||
# that. So, save the combined output, but only show it when snapcraft
|
||||
# actually fails.
|
||||
set +e
|
||||
snapcraft_output="$(
|
||||
snapcraft pack "$snap_dir" --output "$snap_output" 2>&1
|
||||
)"
|
||||
snapcraft_exit_code="$?"
|
||||
set -e
|
||||
|
||||
if [ "$snapcraft_exit_code" -ne '0' ]
|
||||
then
|
||||
log "$snapcraft_output"
|
||||
exit "$snapcraft_exit_code"
|
||||
fi
|
||||
|
||||
log "$snap_output"
|
||||
|
||||
rm -f -r "$snap_dir"
|
||||
done
|
||||
29
scripts/snap/download.sh
Normal file
29
scripts/snap/download.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
verbose="${VERBOSE:-0}"
|
||||
|
||||
if [ "$verbose" -gt '0' ]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
set -e -f -u
|
||||
|
||||
channel="${CHANNEL:?please set CHANNEL}"
|
||||
readonly channel
|
||||
|
||||
printf '%s %s\n'\
|
||||
'386' 'i386'\
|
||||
'amd64' 'amd64'\
|
||||
'armv7' 'armhf'\
|
||||
'arm64' 'arm64' \
|
||||
| while read -r arch snap_arch
|
||||
do
|
||||
release_url="https://static.adtidy.org/adguardhome/${channel}/AdGuardHome_linux_${arch}.tar.gz"
|
||||
output="./AdGuardHome_linux_${arch}.tar.gz"
|
||||
|
||||
curl -o "$output" -v "$release_url"
|
||||
tar -f "$output" -v -x -z
|
||||
cp ./AdGuardHome/AdGuardHome "./AdGuardHome_${snap_arch}"
|
||||
rm -f -r "$output" ./AdGuardHome
|
||||
done
|
||||
@@ -1,8 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Encoding=UTF-8
|
||||
Name=AdGuard Home
|
||||
Comment=Network-wide ads & trackers blocking DNS server
|
||||
Exec=adguard-home.adguard-home-web
|
||||
Icon=${SNAP}/meta/gui/adguard-home-web.png
|
||||
Terminal=false
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Get the admin interface port from the configuration.
|
||||
bind_port="$( grep -e 'bind_port' "${SNAP_DATA}/AdGuardHome.yaml" | awk -F ' ' '{print $2}' )"
|
||||
readonly bind_port
|
||||
|
||||
if [ "$bind_port" = '' ]
|
||||
then
|
||||
xdg-open 'http://localhost:3000'
|
||||
else
|
||||
xdg-open "http://localhost:${bind_port}"
|
||||
fi
|
||||
@@ -1,42 +0,0 @@
|
||||
# The %VARIABLES% are be replaced by actual values by the build script.
|
||||
|
||||
'name': 'adguard-home'
|
||||
'base': 'core22'
|
||||
'version': '%VERSION%'
|
||||
'summary': Network-wide ads & trackers blocking DNS server
|
||||
'description': |
|
||||
AdGuard Home is a network-wide software for blocking ads & tracking. After
|
||||
you set it up, it'll cover ALL your home devices, and you don't need any
|
||||
client-side software for that.
|
||||
|
||||
It operates as a DNS server that re-routes tracking domains to a "black hole,"
|
||||
thus preventing your devices from connecting to those servers. It's based
|
||||
on software we use for our public AdGuard DNS servers -- both share a lot
|
||||
of common code.
|
||||
'grade': 'stable'
|
||||
'confinement': 'strict'
|
||||
|
||||
'architectures':
|
||||
- '%ARCH%'
|
||||
|
||||
'apps':
|
||||
'adguard-home':
|
||||
'command': 'AdGuardHome --no-check-update -w $SNAP_DATA'
|
||||
'plugs':
|
||||
# Add the "network-bind" plug to bind to interfaces.
|
||||
- 'network-bind'
|
||||
# Add the "network-observe" plug to be able to bind to ports below 1024
|
||||
# (cap_net_bind_service) and also to bind to a particular interface using
|
||||
# SO_BINDTODEVICE (cap_net_raw).
|
||||
- 'network-observe'
|
||||
# Add the "network-control" plug to be able to use raw sockets in the DHCP
|
||||
# server.
|
||||
#
|
||||
# TODO(a.garipov): If this works, request auto-connect of this plug.
|
||||
- 'network-control'
|
||||
'daemon': 'simple'
|
||||
'restart-condition': 'always'
|
||||
'adguard-home-web':
|
||||
'command': 'adguard-home-web.sh'
|
||||
'plugs':
|
||||
- 'desktop'
|
||||
93
scripts/snap/upload.sh
Normal file
93
scripts/snap/upload.sh
Normal file
@@ -0,0 +1,93 @@
|
||||
#!/bin/sh
|
||||
|
||||
verbose="${VERBOSE:-0}"
|
||||
|
||||
if [ "$verbose" -gt '0' ]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
set -e -f -u
|
||||
|
||||
# Function log is an echo wrapper that writes to stderr if the caller requested
|
||||
# verbosity level greater than 0. Otherwise, it does nothing.
|
||||
log() {
|
||||
if [ "$verbose" -gt '0' ]
|
||||
then
|
||||
# Don't use quotes to get word splitting.
|
||||
echo "$1" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
# Do not set a new lowercase variable, because the snapcraft tool expects the
|
||||
# uppercase form.
|
||||
if [ "${SNAPCRAFT_STORE_CREDENTIALS:-}" = '' ]
|
||||
then
|
||||
log 'please set SNAPCRAFT_STORE_CREDENTIALS'
|
||||
|
||||
exit 1
|
||||
fi
|
||||
export SNAPCRAFT_STORE_CREDENTIALS
|
||||
|
||||
snapcraft_channel="${SNAPCRAFT_CHANNEL:?please set SNAPCRAFT_CHANNEL}"
|
||||
readonly snapcraft_channel
|
||||
|
||||
# Allow developers to overwrite the command, e.g. for testing.
|
||||
snapcraft_cmd="${SNAPCRAFT_CMD:-snapcraft}"
|
||||
readonly snapcraft_cmd
|
||||
|
||||
default_timeout='90s'
|
||||
kill_timeout='120s'
|
||||
readonly default_timeout kill_timeout
|
||||
|
||||
for arch in\
|
||||
'i386'\
|
||||
'amd64'\
|
||||
'armhf'\
|
||||
'arm64'
|
||||
do
|
||||
snap_file="./AdGuardHome_${arch}.snap"
|
||||
|
||||
# Catch the exit code and the combined output to later inspect it.
|
||||
set +e
|
||||
snapcraft_output="$(
|
||||
# Use timeout(1) to force snapcraft to quit after a certain time. There
|
||||
# seems to be no environment variable or flag to force this behavior.
|
||||
timeout\
|
||||
--preserve-status\
|
||||
-k "$kill_timeout"\
|
||||
-v "$default_timeout"\
|
||||
"$snapcraft_cmd" upload\
|
||||
--release="${snapcraft_channel}"\
|
||||
--quiet\
|
||||
"${snap_file}"\
|
||||
2>&1
|
||||
)"
|
||||
snapcraft_exit_code="$?"
|
||||
set -e
|
||||
|
||||
if [ "$snapcraft_exit_code" -eq '0' ]
|
||||
then
|
||||
log "successful upload: ${snapcraft_output}"
|
||||
|
||||
continue
|
||||
fi
|
||||
|
||||
# Skip the ones that were failed by a duplicate upload error.
|
||||
case "$snapcraft_output"
|
||||
in
|
||||
(*'A file with this exact same content has already been uploaded'|\
|
||||
'Error checking upload uniqueness'*)
|
||||
|
||||
log "warning: duplicate upload, skipping"
|
||||
log "snapcraft upload error: ${snapcraft_output}"
|
||||
|
||||
continue
|
||||
;;
|
||||
(*)
|
||||
echo "unexpected snapcraft upload error: ${snapcraft_output}"
|
||||
|
||||
return "$snapcraft_exit_code"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
Reference in New Issue
Block a user