2020-04-08 10:59:16 +00:00
#!/bin/bash
2024-01-02 13:32:11 +00:00
# Copyright (c) 2024 Proton AG
2020-05-28 12:25:00 +00:00
#
2022-04-05 13:50:21 +00:00
# This file is part of Proton Mail Bridge.
2020-05-28 12:25:00 +00:00
#
2022-04-05 13:50:21 +00:00
# Proton Mail Bridge is free software: you can redistribute it and/or modify
2020-05-28 12:25:00 +00:00
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
2022-04-05 13:50:21 +00:00
# Proton Mail Bridge is distributed in the hope that it will be useful,
2020-05-28 12:25:00 +00:00
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
2022-04-05 13:50:21 +00:00
# along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
2020-05-28 12:25:00 +00:00
2020-04-08 10:59:16 +00:00
## Generate credits from go.mod
2020-05-14 13:22:29 +00:00
PACKAGE = $1
2020-04-08 10:59:16 +00:00
# Vendor packages
LOCKFILE = ../go.mod
2020-08-17 08:28:10 +00:00
TEMPFILE1 = $( mktemp)
TEMPFILE2 = $( mktemp)
egrep $'^\t[^=>]*$' $LOCKFILE | sed -r 's/\t([^ ]*) v.*/\1/g' > $TEMPFILE1
egrep $'^\t.*=>.*v.*$' $LOCKFILE | sed -r 's/^.*=> ([^ ]*)( v.*)?/\1/g' >> $TEMPFILE1
cat $TEMPFILE1 | egrep -v 'therecipe/qt/internal|therecipe/env_.*_512|protontech' | sort | uniq > $TEMPFILE2
2020-04-08 10:59:16 +00:00
# Add non vendor credits
2023-08-07 07:12:37 +00:00
echo -e "\nQt 6.4.3 by Qt group\n" >> $TEMPFILE2
2020-04-08 10:59:16 +00:00
# join lines
2020-08-17 08:28:10 +00:00
sed -i -e ':a' -e 'N' -e '$!ba' -e 's|\n|;|g' $TEMPFILE2
2020-04-08 10:59:16 +00:00
2020-05-14 13:22:29 +00:00
cat ../utils/license_header.txt > ../internal/$PACKAGE /credits.go
2020-08-17 08:28:10 +00:00
echo -e '// Code generated by ' ` echo $0 ` ' at ' ` date` '. DO NOT EDIT.\n\npackage ' $PACKAGE '\n\nconst Credits = "' $( cat $TEMPFILE2 ) '"' >> ../internal/$PACKAGE /credits.go
rm $TEMPFILE1 $TEMPFILE2