44set -x
55
66if [[ " $( uname) " == ' Linux' ]]; then
7- INSTALL_DIR=usr
8- FPM_FLAGS=
7+ INSTALL_DIR=usr
8+ FPM_FLAGS=
99else
10- INSTALL_DIR=usr/local
11- FPM_FLAGS=' --osxpkg-identifier-prefix com.iterative'
12- FPM_FLAGS+=' --after-install scripts/fpm/after-install.sh'
13- FPM_FLAGS+=' --after-remove scripts/fpm/after-remove.sh'
10+ INSTALL_DIR=usr/local
11+ FPM_FLAGS=' --osxpkg-identifier-prefix com.iterative'
12+ FPM_FLAGS+=' --after-install scripts/fpm/after-install.sh'
13+ FPM_FLAGS+=' --after-remove scripts/fpm/after-remove.sh'
1414fi
1515
1616BUILD_DIR=build
@@ -21,129 +21,121 @@ LIB_DIR=$BUILD_DIR/$INSTALL_DIR/lib
2121FPM_PACKAGE_DIRS=" usr"
2222ZSH_CMPLT_DIR=usr/share/zsh/site-functions/_dvc
2323if [[ " $( uname) " == ' Linux' ]]; then
24- BASH_CMPLT_DIR=etc/bash_completion.d
25- FPM_PACKAGE_DIRS=" $FPM_PACKAGE_DIRS etc"
24+ BASH_CMPLT_DIR=etc/bash_completion.d
25+ FPM_PACKAGE_DIRS=" $FPM_PACKAGE_DIRS etc"
2626else
27- BASH_CMPLT_DIR=usr/local/etc/bash_completion.d
27+ BASH_CMPLT_DIR=usr/local/etc/bash_completion.d
2828fi
2929
30- print_error ()
31- {
32- echo -e " \e[31m$1 \e[0m" >&2
30+ print_error () {
31+ echo -e " \e[31m$1 \e[0m" >&2
3332}
3433
3534if [ ! -d " dvc" ]; then
36- print_error " Please run this script from repository root"
37- exit 1
35+ print_error " Please run this script from repository root"
36+ exit 1
3837fi
3938
4039trap ' print_error "FAIL"; exit 1' ERR
4140
42- print_info ()
43- {
44- echo -e " \e[32m$1 \e[0m"
41+ print_info () {
42+ echo -e " \e[32m$1 \e[0m"
4543}
4644
47- command_exists ()
48- {
49- command -v $1 > /dev/null 2>&1
45+ command_exists () {
46+ command -v $1 > /dev/null 2>&1
5047}
5148
52- fpm_build ()
53- {
54- print_info " Building $1 ..."
55- VERSION=$( python -c " import dvc; from dvc import __version__; print(str(__version__))" )
56- fpm -s dir \
57- -f \
58- -t $1 \
59- --description " $DESC " \
60- $FPM_FLAGS \
61- -n dvc \
62- -v $VERSION \
63- -C $BUILD_DIR \
64- $FPM_PACKAGE_DIRS
49+ fpm_build () {
50+ print_info " Building $1 ..."
51+ VERSION=$( python -c " import dvc; from dvc import __version__; print(str(__version__))" )
52+ fpm -s dir \
53+ -f \
54+ -t $1 \
55+ --description " $DESC " \
56+ $FPM_FLAGS \
57+ -n dvc \
58+ -v $VERSION \
59+ -C $BUILD_DIR \
60+ $FPM_PACKAGE_DIRS
6561}
6662
67- cleanup ()
68- {
69- print_info " Cleaning up..."
70- rm -rf build
63+ cleanup () {
64+ print_info " Cleaning up..."
65+ rm -rf build
7166}
7267
73- install_dependencies ()
74- {
75- print_info " Installing fpm..."
76- if command_exists dnf; then
77- sudo dnf install ruby-devel gcc make rpm-build
78- elif command_exists yum; then
79- sudo yum install ruby-devel gcc make rpm-build
80- elif command_exists apt-get; then
81- sudo apt-get update -y
82- sudo apt-get install ruby-dev build-essential rpm python-pip python-dev
83- elif command_exists brew; then
84- brew install ruby
85- else
86- echo " Unable to install fpm dependencies" && exit 1
87- fi
88-
89- gem install --no-document fpm
90-
91- # https://github.com/iterative/dvc/issues/2970
92- gem uninstall -i /Users/travis/.rvm/gems/ruby-2.4.3@global rubygems-bundler
93-
94- print_info " Installing requirements..."
95- pip install .[all]
96- pip install -r scripts/build-requirements.txt
68+ install_dependencies () {
69+ print_info " Installing fpm..."
70+ if command_exists dnf; then
71+ sudo dnf install ruby-devel gcc make rpm-build
72+ elif command_exists yum; then
73+ sudo yum install ruby-devel gcc make rpm-build
74+ elif command_exists apt-get; then
75+ sudo apt-get update -y
76+ sudo apt-get install ruby-dev build-essential rpm python-pip python-dev
77+ elif command_exists brew; then
78+ brew install ruby
79+ else
80+ echo " Unable to install fpm dependencies" && exit 1
81+ fi
82+
83+ gem install --no-document fpm
84+
85+ # https://github.com/iterative/dvc/issues/2970
86+ gem uninstall -i /Users/travis/.rvm/gems/ruby-2.4.3@global rubygems-bundler
87+
88+ print_info " Installing requirements..."
89+ pip install .[all]
90+ pip install -r scripts/build-requirements.txt
9791}
9892
99- build_dvc ()
100- {
101- print_info " Building dvc binary..."
102- pyinstaller \
103- --additional-hooks-dir $( pwd) /scripts/hooks dvc/__main__.py \
104- --name dvc \
105- --distpath $LIB_DIR \
106- --specpath $BUILD_DIR
107-
108- $LIB_DIR /dvc/dvc --help
109-
110- # NOTE: in osxpkg fpm replaces symlinks with actual file that it
111- # points to, so we need to use after-install hook. See FPM_FLAGS
112- # above.
113- if [[ " $( uname) " == ' Linux' ]]; then
114- mkdir -p $BIN_DIR
115- pushd $BIN_DIR
116- ln -s ../lib/dvc/dvc dvc
117- popd
118- $BIN_DIR /dvc --help
119- fi
120-
121- # NOTE: temporarily not adding scripts to mac package. See [1]
122- # [1] https://github.com/iterative/dvc/issues/2585
123- if [[ " $( uname) " == ' Linux' ]]; then
124- mkdir -p $BUILD_DIR /$BASH_CMPLT_DIR
125- cp scripts/completion/dvc.bash $BUILD_DIR /$BASH_CMPLT_DIR /dvc
126-
127- mkdir -p $BUILD_DIR /$ZSH_CMPLT_DIR
128- cp scripts/completion/dvc.zsh $BUILD_DIR /$ZSH_CMPLT_DIR
129- fi
93+ build_dvc () {
94+ print_info " Building dvc binary..."
95+ pyinstaller \
96+ --additional-hooks-dir $( pwd) /scripts/hooks dvc/__main__.py \
97+ --name dvc \
98+ --distpath $LIB_DIR \
99+ --specpath $BUILD_DIR
100+
101+ $LIB_DIR /dvc/dvc --help
102+
103+ # NOTE: in osxpkg fpm replaces symlinks with actual file that it
104+ # points to, so we need to use after-install hook. See FPM_FLAGS
105+ # above.
106+ if [[ " $( uname) " == ' Linux' ]]; then
107+ mkdir -p $BIN_DIR
108+ pushd $BIN_DIR
109+ ln -s ../lib/dvc/dvc dvc
110+ popd
111+ $BIN_DIR /dvc --help
112+ fi
113+
114+ # NOTE: temporarily not adding scripts to mac package. See [1]
115+ # [1] https://github.com/iterative/dvc/issues/2585
116+ if [[ " $( uname) " == ' Linux' ]]; then
117+ mkdir -p $BUILD_DIR /$BASH_CMPLT_DIR
118+ cp scripts/completion/dvc.bash $BUILD_DIR /$BASH_CMPLT_DIR /dvc
119+
120+ mkdir -p $BUILD_DIR /$ZSH_CMPLT_DIR
121+ cp scripts/completion/dvc.zsh $BUILD_DIR /$ZSH_CMPLT_DIR
122+ fi
130123}
131124
132- build ()
133- {
134- cleanup
135- echo " PKG = \" $1 \" " > dvc/utils/build.py
136- build_dvc
137- fpm_build $1
125+ build () {
126+ cleanup
127+ echo " PKG = \" $1 \" " > dvc/utils/build.py
128+ build_dvc
129+ fpm_build $1
138130}
139131
140132install_dependencies
141133
142134if [[ " $( uname) " == ' Linux' ]]; then
143- build rpm
144- build deb
135+ build rpm
136+ build deb
145137else
146- build osxpkg
138+ build osxpkg
147139fi
148140
149141cleanup
0 commit comments