From 5140cc702e064164022f87890f9410916865586c1960c050d05ee926cc43e9c5 Mon Sep 17 00:00:00 2001 From: c unix Date: Sat, 26 Mar 2022 17:08:58 +0000 Subject: [PATCH] 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 --- dnscrypt-proxy.changes | 5 ++ dnscrypt-proxy.spec | 25 ++++------ find_licenses.sh | 102 ----------------------------------------- install_licenses.sh | 34 -------------- 4 files changed, 14 insertions(+), 152 deletions(-) delete mode 100644 find_licenses.sh delete mode 100644 install_licenses.sh diff --git a/dnscrypt-proxy.changes b/dnscrypt-proxy.changes index 66af765..164055f 100644 --- a/dnscrypt-proxy.changes +++ b/dnscrypt-proxy.changes @@ -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 diff --git a/dnscrypt-proxy.spec b/dnscrypt-proxy.spec index eda4a1b..3a87b34 100644 --- a/dnscrypt-proxy.spec +++ b/dnscrypt-proxy.spec @@ -22,7 +22,6 @@ %define home_dir %{_localstatedir}/lib/%{name} %define log_dir %{_localstatedir}/log/%{name} %define services %{name}.socket %{name}.service %{name}-resolvconf.service -%define vlic_dir vendored Name: dnscrypt-proxy Version: 2.1.1 @@ -37,20 +36,17 @@ Source2: %{name}.socket Source3: %{name}-resolvconf.service # File to use with sed to modify default configuration. 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 -Source7: README.openSUSE +Source5: README.openSUSE # Example how to override socket unit -Source8: %{name}.socket.conf +Source6: %{name}.socket.conf BuildRequires: golang-packaging BuildRequires: pkgconfig BuildRequires: shadow BuildRequires: systemd-rpm-macros BuildRequires: golang(API) >= 1.16 BuildRequires: pkgconfig(libsystemd) +BuildRequires: vendored_licenses_packager # For systemd pidfile solution. Requires: bash # for daemon group/user @@ -71,9 +67,6 @@ and ODoH (Oblivious DoH). %prep %setup -q -n %{name}-%{version} -# Find licenses of vendored packages and prepare for installation -bash %{SOURCE5} %{vlic_dir} - # duplicate original config file 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 sed -i "1s/#! \/usr\/bin\/env python3/#! \/usr\/bin\/python3/" utils/generate-domains-blocklist/generate-domains-blocklist.py +%vendored_licenses_packager_prep + %build cd %{name} 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}-resolvconf -# Vendor Licenses -install -d -m 0755 %{buildroot}%{_licensedir}/%{name}/%{vlic_dir} -bash %{SOURCE6} %{vlic_dir} %{buildroot}/%{_licensedir}/%{name}/%{vlic_dir} +%vendored_licenses_packager_install # Some hints. Improvements and feedback welcome! -cp %{SOURCE7} README.openSUSE +cp %{SOURCE5} README.openSUSE # Example drop-in. -cp %{SOURCE8} %{name}.socket.conf +cp %{SOURCE6} %{name}.socket.conf %pre # 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}) %{log_dir} %license LICENSE -%{_licensedir}/%{name}/%{vlic_dir}/ +%vendored_licenses_packager_files %changelog diff --git a/find_licenses.sh b/find_licenses.sh deleted file mode 100644 index cf3a6d1..0000000 --- a/find_licenses.sh +++ /dev/null @@ -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 diff --git a/install_licenses.sh b/install_licenses.sh deleted file mode 100644 index 97626bf..0000000 --- a/install_licenses.sh +++ /dev/null @@ -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