mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-13 22:51:08 -05:00
Revert undesired changes to shell scripts
This commit is contained in:
parent
0aacaea918
commit
3f49b32086
3 changed files with 52 additions and 77 deletions
10
.gitattributes
vendored
10
.gitattributes
vendored
|
@ -1,7 +1,7 @@
|
||||||
*.bash text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=2
|
*.bash text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=4
|
||||||
*.sh text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=2
|
*.sh text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=4
|
||||||
|
|
||||||
# files for systemd
|
# files for systemd
|
||||||
*.path text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=2
|
*.path text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=4
|
||||||
*.service text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=2
|
*.service text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=4
|
||||||
*.timer text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=2
|
*.timer text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=4
|
||||||
|
|
|
@ -19,7 +19,7 @@ ldflags=()
|
||||||
|
|
||||||
# Timestamp of build
|
# Timestamp of build
|
||||||
name="${pkg}.buildDate"
|
name="${pkg}.buildDate"
|
||||||
value=$(date --utc +"%F %H:%M:%SZ")
|
value=$(date -u +"%a %b %d %H:%M:%S %Z %Y")
|
||||||
ldflags+=("-X" "\"${name}=${value}\"")
|
ldflags+=("-X" "\"${name}=${value}\"")
|
||||||
|
|
||||||
# Current tag, if HEAD is on a tag
|
# Current tag, if HEAD is on a tag
|
||||||
|
@ -46,10 +46,7 @@ ldflags+=("-X" "\"${name}=${value}\"")
|
||||||
|
|
||||||
# List of modified files
|
# List of modified files
|
||||||
name="${pkg}.gitFilesModified"
|
name="${pkg}.gitFilesModified"
|
||||||
value="$(git diff-index --name-only HEAD | tr "\n" "," | sed -e 's:,$::')"
|
value="$(git diff-index --name-only HEAD)"
|
||||||
ldflags+=("-X" "\"${name}=${value}\"")
|
ldflags+=("-X" "\"${name}=${value}\"")
|
||||||
|
|
||||||
set -x
|
go build -ldflags "${ldflags[*]}" -o "${output_filename}"
|
||||||
go build \
|
|
||||||
-ldflags "${ldflags[*]}" \
|
|
||||||
-o "${output_filename}"
|
|
||||||
|
|
114
dist/automate.sh
vendored
114
dist/automate.sh
vendored
|
@ -1,78 +1,56 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
set -o pipefail
|
||||||
|
shopt -s nullglob # if no files match glob, assume empty list instead of string literal
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
# if no files match glob, assume empty list instead of string literal
|
|
||||||
shopt -s nullglob
|
|
||||||
|
|
||||||
: ${build_package:="github.com/mholt/caddy"}
|
## PACKAGE TO BUILD
|
||||||
|
Package=github.com/mholt/caddy
|
||||||
|
|
||||||
: ${dist_dir:="${GOPATH}/src/${build_package}/dist"}
|
|
||||||
: ${build_dir:="${dist_dir}/builds"}
|
|
||||||
: ${target_dir:="${dist_dir}/release"}
|
|
||||||
|
|
||||||
# Bundles a single binary, given as first parameter, into an archive.
|
## PATHS TO USE
|
||||||
package() {
|
DistDir=$GOPATH/src/$Package/dist
|
||||||
# Binary inside the zip file is simply the project name
|
BuildDir=$DistDir/builds
|
||||||
binbase="$(basename "${build_package}")"
|
ReleaseDir=$DistDir/release
|
||||||
if [[ "${1}" == *.exe ]]; then
|
|
||||||
binbase+=".exe"
|
|
||||||
fi
|
|
||||||
bin="${build_dir}/${binbase}"
|
|
||||||
|
|
||||||
|
|
||||||
|
## BEGIN
|
||||||
|
|
||||||
|
# Compile binaries
|
||||||
|
mkdir -p $BuildDir
|
||||||
|
cd $BuildDir
|
||||||
|
rm -f caddy*
|
||||||
|
gox $Package
|
||||||
|
|
||||||
|
# Zip them up with release notes and stuff
|
||||||
|
mkdir -p $ReleaseDir
|
||||||
|
cd $ReleaseDir
|
||||||
|
rm -f caddy*
|
||||||
|
for f in $BuildDir/*
|
||||||
|
do
|
||||||
# Name .zip file same as binary, but strip .exe from end
|
# Name .zip file same as binary, but strip .exe from end
|
||||||
zipname="$(basename "${1%.exe}")"
|
zipname=$(basename ${f%".exe"})
|
||||||
case "$(printf "${zipname}" | cut -d '_' -f 2 | sed -e 's:[a-z]*bsd:bsd:')" in
|
if [[ $f == *"linux"* ]] || [[ $f == *"bsd"* ]]; then
|
||||||
linux|bsd) zipname+=".tar.gz" ;;
|
zipname=${zipname}.tar.gz
|
||||||
*) zipname+=".zip" ;;
|
else
|
||||||
esac
|
zipname=${zipname}.zip
|
||||||
|
fi
|
||||||
|
|
||||||
# Compress distributable depending on extension
|
# Binary inside the zip file is simply the project name
|
||||||
case "${zipname##*.}" in
|
binbase=$(basename $Package)
|
||||||
zip)
|
if [[ $f == *.exe ]]; then
|
||||||
zip -j "${target_dir}/${zipname}" \
|
binbase=$binbase.exe
|
||||||
"${1}" \
|
fi
|
||||||
"${dist_dir}"/{CHANGES.txt,LICENSES.txt,README.txt}
|
bin=$BuildDir/$binbase
|
||||||
printf "@ $(basename "${1}")\n@=${binbase}\n" \
|
mv $f $bin
|
||||||
| zipnote -w "${target_dir}/${zipname}"
|
|
||||||
;;
|
|
||||||
gz)
|
|
||||||
tar -caf "${target_dir}/${zipname}" \
|
|
||||||
--owner=0 --group=0 \
|
|
||||||
--transform="s#$(basename "${1}")#${binbase}#" \
|
|
||||||
-C "$(dirname "${1}")" "$(basename "${1}")" \
|
|
||||||
-C "${dist_dir}" CHANGES.txt LICENSES.txt README.txt
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare_directories() {
|
# Compress distributable
|
||||||
mkdir -p "${build_dir}"
|
if [[ $zipname == *.zip ]]; then
|
||||||
rm -f "${build_dir}"/caddy*
|
zip -j $zipname $bin $DistDir/CHANGES.txt $DistDir/LICENSES.txt $DistDir/README.txt
|
||||||
|
else
|
||||||
|
tar -cvzf $zipname -C $BuildDir $binbase -C $DistDir CHANGES.txt LICENSES.txt README.txt
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "${target_dir}"
|
# Put binary filename back to original
|
||||||
rm -f "${target_dir}"/caddy*
|
mv $bin $f
|
||||||
}
|
done
|
||||||
|
|
||||||
compile_binaries() {
|
|
||||||
(cd "${build_dir}"; gox "${build_package}")
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ "${1:-}" == "" ]]; then
|
|
||||||
prepare_directories
|
|
||||||
compile_binaries
|
|
||||||
|
|
||||||
case "${OSTYPE}" in
|
|
||||||
linux*)
|
|
||||||
find "${build_dir}" -type f -executable -print0 \
|
|
||||||
| xargs --null --max-args=1 --max-procs=$(nproc --ignore=1) -I '{}' \
|
|
||||||
"${0}" package '{}'
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
while read f; do
|
|
||||||
package "${f}"
|
|
||||||
done < <(ls -1 "${build_dir}"/caddy*)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
${1} "${2}"
|
|
||||||
fi
|
|
||||||
|
|
Loading…
Reference in a new issue