Accepting request 964029 from home:cunix:server_dns

switched to vendored_licenses_packager as build dependency

OBS-URL: https://build.opensuse.org/request/show/964029
OBS-URL: https://build.opensuse.org/package/show/server:dns/dnscrypt-proxy?expand=0&rev=39
This commit is contained in:
c unix 2022-03-26 17:08:58 +00:00 committed by Git OBS Bridge
parent 324e13472d
commit 5140cc702e
4 changed files with 14 additions and 152 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed Mar 22 12:00:00 UTC 2022 - cunix@mail.de
- switched to vendored_licenses_packager as build dependency
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Oct 1 12:00:00 UTC 2021 - cunix@mail.de - 2.1.1 Fri Oct 1 12:00:00 UTC 2021 - cunix@mail.de - 2.1.1

View File

@ -22,7 +22,6 @@
%define home_dir %{_localstatedir}/lib/%{name} %define home_dir %{_localstatedir}/lib/%{name}
%define log_dir %{_localstatedir}/log/%{name} %define log_dir %{_localstatedir}/log/%{name}
%define services %{name}.socket %{name}.service %{name}-resolvconf.service %define services %{name}.socket %{name}.service %{name}-resolvconf.service
%define vlic_dir vendored
Name: dnscrypt-proxy Name: dnscrypt-proxy
Version: 2.1.1 Version: 2.1.1
@ -37,20 +36,17 @@ Source2: %{name}.socket
Source3: %{name}-resolvconf.service Source3: %{name}-resolvconf.service
# File to use with sed to modify default configuration. # File to use with sed to modify default configuration.
Source4: example-dnscrypt-proxy.toml.sed Source4: example-dnscrypt-proxy.toml.sed
# Find licenses of vendored packages.
Source5: find_licenses.sh
# Install licenses of vendored packages.
Source6: install_licenses.sh
# Some words # Some words
Source7: README.openSUSE Source5: README.openSUSE
# Example how to override socket unit # Example how to override socket unit
Source8: %{name}.socket.conf Source6: %{name}.socket.conf
BuildRequires: golang-packaging BuildRequires: golang-packaging
BuildRequires: pkgconfig BuildRequires: pkgconfig
BuildRequires: shadow BuildRequires: shadow
BuildRequires: systemd-rpm-macros BuildRequires: systemd-rpm-macros
BuildRequires: golang(API) >= 1.16 BuildRequires: golang(API) >= 1.16
BuildRequires: pkgconfig(libsystemd) BuildRequires: pkgconfig(libsystemd)
BuildRequires: vendored_licenses_packager
# For systemd pidfile solution. # For systemd pidfile solution.
Requires: bash Requires: bash
# for daemon group/user # for daemon group/user
@ -71,9 +67,6 @@ and ODoH (Oblivious DoH).
%prep %prep
%setup -q -n %{name}-%{version} %setup -q -n %{name}-%{version}
# Find licenses of vendored packages and prepare for installation
bash %{SOURCE5} %{vlic_dir}
# duplicate original config file # duplicate original config file
cp ./%{name}/example-%{name}.toml ./%{name}.toml.default cp ./%{name}/example-%{name}.toml ./%{name}.toml.default
@ -89,6 +82,8 @@ sed -i "s/## This is an example configuration file./## This is a configuration f
# python path instead of env # python path instead of env
sed -i "1s/#! \/usr\/bin\/env python3/#! \/usr\/bin\/python3/" utils/generate-domains-blocklist/generate-domains-blocklist.py sed -i "1s/#! \/usr\/bin\/env python3/#! \/usr\/bin\/python3/" utils/generate-domains-blocklist/generate-domains-blocklist.py
%vendored_licenses_packager_prep
%build %build
cd %{name} cd %{name}
go build -mod=vendor -buildmode=pie go build -mod=vendor -buildmode=pie
@ -128,15 +123,13 @@ install -D -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}-resolvconf.service
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name} ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-resolvconf ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-resolvconf
# Vendor Licenses %vendored_licenses_packager_install
install -d -m 0755 %{buildroot}%{_licensedir}/%{name}/%{vlic_dir}
bash %{SOURCE6} %{vlic_dir} %{buildroot}/%{_licensedir}/%{name}/%{vlic_dir}
# Some hints. Improvements and feedback welcome! # Some hints. Improvements and feedback welcome!
cp %{SOURCE7} README.openSUSE cp %{SOURCE5} README.openSUSE
# Example drop-in. # Example drop-in.
cp %{SOURCE8} %{name}.socket.conf cp %{SOURCE6} %{name}.socket.conf
%pre %pre
# group and user # group and user
@ -178,6 +171,6 @@ getent passwd %{user_group} >/dev/null || %{_sbindir}/useradd -r -g %{user_group
%dir %attr(0750,%{user_group},%{user_group}) %{home_dir} %dir %attr(0750,%{user_group},%{user_group}) %{home_dir}
%dir %attr(0750,%{user_group},%{user_group}) %{log_dir} %dir %attr(0750,%{user_group},%{user_group}) %{log_dir}
%license LICENSE %license LICENSE
%{_licensedir}/%{name}/%{vlic_dir}/ %vendored_licenses_packager_files
%changelog %changelog

View File

@ -1,102 +0,0 @@
#!/bin/bash
# written by cunix in 2019
# corrected by Bernhard Wiedemann in 2020 (pipe through sort)
# updated by cunix in 2021
#
# Tries to find and prepare licenses from vendored packages for
# installation as file or link to existing file.
#
# $1 should be a destination directory for vendored licenses
vendor_licenses_dir=$1
username=$(whoami)
workingdir=$(pwd)
licenses_file=$(mktemp /tmp/license_files_XXXXXXXXXX.txt)
goahead=0
hash_list=()
filename_list=()
legal_file_names="copying copyright legal licence license notice patents unlicense"
if [[ -z "$vendor_licenses_dir" ]]
then
echo missing directory as parameter
exit 1
else
if [[ "$vendor_licenses_dir" = "/" ]] || [[ "$vendor_licenses_dir" = "/home" ]] \
|| [[ "$vendor_licenses_dir" = "/home/" ]] || [[ "$vendor_licenses_dir" = "/home/$username" ]] \
|| [[ "$vendor_licenses_dir" = "/home/$username/" ]] || [[ "$vendor_licenses_dir" = "$HOME" ]]
then
echo Do not use "$vendor_licenses_dir" as destination directory.
echo It will delete all your files.
exit 1
else
mkdir -pv $vendor_licenses_dir
if [[ -d "$vendor_licenses_dir" ]]
then
echo Searching for licenses ...
rm $licenses_file
for item in $legal_file_names
do
echo searching for file names starting with $item
find ./*/ -iname "$item*" | sort >> $licenses_file
done
goahead=1
else
echo "$vendor_licenses_dir" is not a directory.
exit 1
fi
fi
fi
if [[ -f "$licenses_file" ]]
then
if [[ $goahead -eq 1 ]]
then
echo Removing $vendor_licenses_dir
rm -r "$vendor_licenses_dir"
mkdir -pv $vendor_licenses_dir
echo Processing licenses . . .
while read line
do
filenamepre=${line////__}
filename=${filenamepre//.__/}
hash_output=$(sha256sum $line)
hash=${hash_output:0:66}
hash_list_len=${#hash_list[@]}
if [[ $hash_list_len -eq 0 ]]
then
cat $line > $vendor_licenses_dir/$filename
hash_list[0]=$hash
filename_list[0]=$filename
else
counter=0
match=0
for item in ${hash_list[@]}
do
if test $item = $hash
then
match=1
break
fi
counter=$(($counter+1))
done
if [[ $match -eq 0 ]]
then
hash_list[$counter]=$hash
filename_list[$counter]=$filename
cat $line > $vendor_licenses_dir/$filename
else
cd $vendor_licenses_dir
ln -s ${filename_list[$counter]} $filename
cd $workingdir
fi
fi
done < $licenses_file
else
echo Does not package licenses.
exit 1
fi
else
echo No licenses found to package.
fi

View File

@ -1,34 +0,0 @@
#!/bin/bash
# written by cunix in 2019
# updated in 2021
#
# Installs or links previously found licenses.
#
# $1 should be the soure directory, prepared with script "find_licenses.sh"
# $2 should be the (already created) destination directory
vendor_licenses_dir=$1
install_licenses_dir=$2
licenses_files=$(mktemp /tmp/real_license_files_XXXXXXXXXX.txt)
licenses_links=$(mktemp /tmp/link_license_files_XXXXXXXXXX.txt)
rm $licenses_files
rm $licenses_links
find -P $vendor_licenses_dir -type f -fprintf $licenses_files "%f\n"
find -P $vendor_licenses_dir -type l -fprintf $licenses_links "%f %l\n"
while read line
do
install -D -m 0644 $vendor_licenses_dir/$line $install_licenses_dir/$line
echo installed: $line
done < $licenses_files
cd $install_licenses_dir
while read line
do
combo=($line)
ln -s ${combo[1]} ${combo[0]}
echo linked: $line
done < $licenses_links