diff options
Diffstat (limited to 'build.sh')
-rw-r--r-- | build.sh | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/build.sh b/build.sh new file mode 100644 index 000000000..a39582798 --- /dev/null +++ b/build.sh @@ -0,0 +1,104 @@ +#!/bin/bash + +# ============================================================================== +# FUNCTIONS - START +# ============================================================================== +VERSION='1.1.11' +BASEDIR="${2-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}" + +run_rebrand() +{ + printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Rebrand...' '\e[m' + + mv -T youtube_dl hypervideo_dl + mv bin/youtube-dl bin/hypervideo + mv youtube-dl.plugin.zsh hypervideo.plugin.zsh + + find . -type f \( \ + -iname "*" \ + ! -iname "build.sh" \ + ! -iname ".travis.yml" \ + ! -iname ".gitlab-ci.yml" \ + ! -path "./.git*" \) \ + -exec grep -rIl 'youtube_dl' {} + -exec sed -i 's|youtube_dl|hypervideo_dl|g' {} \; + + find . -name "tox.ini" -type f -exec sed -i 's|youtube-dl|hypervideo|g' {} \; + find . -name "setup.cfg" -type f -exec sed -i 's|youtube-dl|hypervideo|g' {} \; + find . -name "Makefile" -type f -exec sed -i 's|youtube-dl|hypervideo|g' {} \; + find . -name "*.py" -type f -exec sed -i 's|youtube-dl|hypervideo|g' {} \; + find . -name "*.in" -type f -exec sed -i 's|youtube-dl|hypervideo|g' {} \; + find . -name "*.zsh" -type f -exec sed -i 's|youtube-dl|hypervideo|g' {} \; + find docs -type f -exec sed -i 's|youtube-dl|hypervideo|g' {} \; + + # fixes URLs + find . -name "*.py" -type f -exec sed -i 's|hypervideo+test+video|youtube-dl+test+video|g' {} \; + find . -name "*.py" -type f -exec sed -i 's|https://github.com/ytdl-org/hypervideo/|https://github.com/ytdl-org/youtube-dl/|g' {} \; + find . -name "*.py" -type f -exec sed -i 's|https://github.com/rg3/hypervideo/issues/|https://github.com/rg3/youtube-dl/issues/|g' {} \; + find . -name "*.py" -type f -exec sed -i 's|http://hypervideo.bandcamp.com/|http://youtube-dl.bandcamp.com/|g' {} \; + find . -name "*.py" -type f -exec sed -i 's|http://youtube-dl.bandcamp.com/track/hypervideo-test-song|http://youtube-dl.bandcamp.com/track/youtube-dl-test-song|g' {} \; + find . -name "*.py" -type f -exec sed -i 's|https://www.dropbox.com/s/nelirfsxnmcfbfh/hypervideo|https://www.dropbox.com/s/nelirfsxnmcfbfh/youtube-dl|g' {} \; + find . -name "*.py" -type f -exec sed -i 's|http://8tracks.com/ytdl/hypervideo-test-tracks-a|http://8tracks.com/ytdl/youtube-dl-test-tracks-a|g' {} \; + find . -name "*.py" -type f -exec sed -i 's|http://phihag.de/2014/hypervideo/|http://phihag.de/2014/youtube-dl/|g' {} \; + find . -name "*.py" -type f -exec sed -i 's|https://hypervideo-demo.neocities.org/|https://youtube-dl-demo.neocities.org/|g' {} \; + find . -name "*.py" -type f -exec sed -i 's|https://travis-ci.org/ytdl-org/hypervideo/|https://travis-ci.org/ytdl-org/youtube-dl/|g' {} \; + find . -name "*.py" -type f -exec sed -i 's|https://soundcloud.com/jaimemf/hypervideo-test|https://soundcloud.com/jaimemf/youtube-dl-test|g' {} \; + find . -name "*.py" -type f -exec sed -i 's|http://streamcloud.eu/skp9j99s4bpz/hypervideo_test_video|http://streamcloud.eu/skp9j99s4bpz/youtube_dl_test_video|g' {} \; + + find . -type f \( \ + -iname "*" \ + ! -iname "build.sh" \ + ! -iname ".travis.yml" \ + ! -iname ".gitlab-ci.yml" \ + ! -path "./.git*" \) \ + -exec grep -rIl 'YOUTUBE-DL' {} + -exec sed -i 's|YOUTUBE-DL|HYPERVIDEO|g' {} \; + + # Set current version + sed -i "s|__version.*|__version__ = '${VERSION}'|" hypervideo_dl/version.py +} + +run_clean() +{ + printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Clean tempfiles...' '\e[m' + rm -rf -- hypervideo.1.temp.md hypervideo.1 hypervideo.bash-completion README.txt MANIFEST build/ dist/ .coverage cover/ hypervideo.tar.gz hypervideo.zsh hypervideo.fish hypervideo_dl/extractor/lazy_extractors.py *.dump *.part* *.ytdl *.info.json *.mp4 *.m4a *.flv *.mp3 *.avi *.mkv *.webm *.3gp *.wav *.ape *.swf *.jpg *.png CONTRIBUTING.md.tmp hypervideo hypervideo.exe + find . -name "*.pyc" -delete + find . -name "*.class" -delete +} + +run_make() +{ + printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Making hypervideo...' '\e[m' + make hypervideo.tar.gz +} + +run_copy() +{ + printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Genering build...' '\e[m' + install -d -m755 build + mv hypervideo.tar.gz "./build/hypervideo.tar.gz" + cd build && tar xzf hypervideo.tar.gz && + mv hypervideo "hypervideo-${VERSION}" && + tar -czvf "hypervideo-${VERSION}.tar.gz" "hypervideo-${VERSION}" && + rm -rf "hypervideo-${VERSION}" hypervideo.tar.gz + cd "$BASEDIR" || return + printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Tarball in build/ directory' '\e[m' +} + +# Restore directory, compatibility reasons +run_reset() +{ + printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Restore compatibility...' '\e[m' + mv -T hypervideo_dl youtube_dl + mv bin/hypervideo bin/youtube-dl + mv hypervideo.plugin.zsh youtube-dl.plugin.zsh + rm -v hypervideo hypervideo.1 hypervideo.bash-completion hypervideo.fish hypervideo.zsh + printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Please execute: "git checkout ." for complete restore' '\e[m' +} + +# ============================================================================== +# EXECUTION - START +# ============================================================================== +run_rebrand "$@" && run_clean "$@" + +run_make "$@" + +run_copy "$@" && run_reset "$@" |