PageRenderTime 62ms CodeModel.GetById 4ms RepoModel.GetById 0ms app.codeStats 0ms

/kerl

http://github.com/evax/kerl
Shell | 646 lines | 592 code | 29 blank | 25 comment | 59 complexity | 33f0bec8a912cfd875336fd86cf841c3 MD5 | raw file
  1. #! /bin/sh
  2. # Copyright (c) 2011 Spawngrid, Inc
  3. # Copyright (c) 2011 Evax Software <contact(at)evax(dot)org>
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. # THE SOFTWARE.
  22. ERLANG_DOWNLOAD_URL=http://www.erlang.org/download
  23. KERL_BASE_DIR="$HOME/.kerl"
  24. KERL_CONFIG="$HOME/.kerlrc"
  25. KERL_DOWNLOAD_DIR="$KERL_BASE_DIR/archives"
  26. KERL_BUILD_DIR="$KERL_BASE_DIR/builds"
  27. if [ -n "$KERL_CONFIGURE_OPTIONS" ]; then
  28. _KCO="$KERL_CONFIGURE_OPTIONS"
  29. fi
  30. if [ -n "$KERL_SASL_STARTUP" ]; then
  31. _KSS="$KERL_SASL_STARTUP"
  32. fi
  33. if [ -n "$KERL_AGNER_AUTOINSTALL" ]; then
  34. _KAA="$KERL_AGNER_AUTOINSTALL"
  35. fi
  36. KERL_CONFIGURE_OPTIONS=
  37. KERL_DISABLE_AGNER=
  38. KERL_SASL_STARTUP=
  39. # ensure the base dir exsists
  40. mkdir -p "$KERL_BASE_DIR"
  41. # source the config file if available
  42. if [ -f "$KERL_CONFIG" ]; then . "$KERL_CONFIG"; fi
  43. if [ -n "$_KCO" ]; then
  44. KERL_CONFIGURE_OPTIONS="$_KCO"
  45. fi
  46. if [ -n "$_KSS" ]; then
  47. KERL_SASL_STARTUP="$_KSS"
  48. fi
  49. if [ -n "$_KAA" ]; then
  50. KERL_AGNER_AUTOINSTALL="$_KAA"
  51. fi
  52. if [ -z "$KERL_SASL_STARTUP" ]; then
  53. INSTALL_OPT=-minimal
  54. else
  55. INSTALL_OPT=-sasl
  56. fi
  57. KERL_SYSTEM=`uname -s`
  58. case "$KERL_SYSTEM" in
  59. Darwin)
  60. MD5SUM="openssl md5"
  61. MD5SUM_FIELD=2
  62. SED_OPT=-E
  63. if [ `gcc --version | grep llvm | wc -l` = "1" ]; then
  64. if [ -x `which gcc-4.2` ]; then
  65. echo "Adjust compiler settings for OS X: using gcc-4.2"
  66. KERL_CONFIGURE_OPTIONS="CC=gcc-4.2 $KERL_CONFIGURE_OPTIONS"
  67. else
  68. echo "Adjust compiler settings for OS X: using -O0"
  69. KERL_CONFIGURE_OPTIONS="CFLAGS=-O0 $KERL_CONFIGURE_OPTIONS"
  70. fi
  71. fi
  72. ;;
  73. *)
  74. MD5SUM=md5sum
  75. MD5SUM_FIELD=1
  76. SED_OPT=-r
  77. ;;
  78. esac
  79. usage()
  80. {
  81. echo "kerl: build and install Erlang/OTP"
  82. echo "usage: $0 <command> [options ...]"
  83. echo "\n <command> Command to be executed\n"
  84. echo "Valid commands are:"
  85. echo " build Build specified release or git repository"
  86. echo " install Install the specified release at the given location"
  87. echo " update Update agner or the list of available releases from erlang.org"
  88. echo " list List releases, builds and installations"
  89. echo " delete Delete builds and installations"
  90. echo " active Print the path of the active installation"
  91. echo " status Print available builds and installations"
  92. exit 1
  93. }
  94. if [ $# -eq 0 ]; then usage; fi
  95. get_releases()
  96. {
  97. curl -s $ERLANG_DOWNLOAD_URL/ | \
  98. sed $SED_OPT -e 's/^.*>otp_src_(R1[-1234567890ABCD]+)\.tar\.gz<.*$/\1/' \
  99. -e '/^R/!d'
  100. }
  101. update_checksum_file()
  102. {
  103. echo "Getting the checksum file from erlang.org..."
  104. curl $ERLANG_DOWNLOAD_URL/MD5 > "$KERL_DOWNLOAD_DIR/MD5" || exit 1
  105. }
  106. ensure_checksum_file()
  107. {
  108. if [ ! -f "$KERL_DOWNLOAD_DIR/MD5" ]; then
  109. update_checksum_file
  110. fi
  111. }
  112. check_releases()
  113. {
  114. if [ ! -f "$KERL_BASE_DIR/otp_releases" ]; then
  115. echo "Getting the available releases from erlang.org..."
  116. get_releases > "$KERL_BASE_DIR/otp_releases"
  117. fi
  118. }
  119. # c.f. agner issue #98
  120. # https://github.com/agner/agner/issues/#issue/98
  121. KERL_NO_AGNER_SUPPORT="R10B-0 R10B-2 R10B-3 R10B-4 R10B-5 R10B-6 R10B-7
  122. R10B-8 R10B-9 R11B-0 R11B-1 R11B-2 R11B-3 R11B-4 R11B-5 R12B-0 R12B-1
  123. R12B-2 R12B-3 R12B-4 R12B-5 R13A R13B R13B01 R13B02 R13B03 R13B04"
  124. agner_support()
  125. {
  126. if [ -z "$KERL_DISABLE_AGNER" ]; then
  127. return 1;
  128. fi
  129. for v in $KERL_NO_AGNER_SUPPORT; do
  130. if [ "$v" = "$1" ]; then
  131. return 1
  132. fi
  133. done
  134. return 0
  135. }
  136. is_valid_release()
  137. {
  138. check_releases
  139. for rel in `cat $KERL_BASE_DIR/otp_releases`; do
  140. if [ "$1" = "$rel" ]; then
  141. return 0
  142. fi
  143. done
  144. return 1
  145. }
  146. assert_valid_release()
  147. {
  148. if ! is_valid_release $1; then
  149. echo "$1 is not a valid Erlang/OTP release"
  150. exit 1
  151. fi
  152. return 0
  153. }
  154. get_release_from_name()
  155. {
  156. if [ -f "$KERL_BASE_DIR/otp_builds" ]; then
  157. for l in `cat "$KERL_BASE_DIR/otp_builds"`; do
  158. rel=`echo $l | cut -d "," -f 1`
  159. name=`echo $l | cut -d "," -f 2`
  160. if [ "$name" = "$1" ]; then
  161. echo "$rel"
  162. return 0
  163. fi
  164. done
  165. fi
  166. return 1
  167. }
  168. is_valid_installation()
  169. {
  170. if [ -f "$1/activate" ]; then
  171. return 0
  172. fi
  173. return 1
  174. }
  175. do_update_agner()
  176. {
  177. rel=`get_release_from_name $1`
  178. if [ "$?" -eq 1 ]; then
  179. echo "Unknown build name $1"
  180. exit 1
  181. fi
  182. TARGET="$KERL_BUILD_DIR/$1/release_$rel"
  183. cd "$KERL_BUILD_DIR/$1/agner_$rel" && \
  184. git pull &&
  185. PATH="$KERL_BUILD_DIR/$1/otp_src_$rel/bin:$PATH" \
  186. make > /dev/null 2>&1
  187. if [ "$?" -eq 1 ]; then
  188. return 1
  189. fi
  190. return 0
  191. }
  192. assert_build_name_unused()
  193. {
  194. if [ -f "$KERL_BASE_DIR/otp_builds" ]; then
  195. for l in `cat "$KERL_BASE_DIR/otp_builds"`; do
  196. name=`echo $l | cut -d "," -f 2`
  197. if [ "$name" = "$1" ]; then
  198. echo "There's already a build named $1"
  199. exit 1
  200. fi
  201. done
  202. fi
  203. }
  204. do_git_build()
  205. {
  206. assert_build_name_unused $3
  207. mkdir -p "$KERL_BUILD_DIR/$3"
  208. cd "$KERL_BUILD_DIR/$3"
  209. echo "Checking Erlang/OTP git repository from $1..."
  210. git clone $1 otp_src_git > /dev/null 2>&1
  211. if [ "$?" -eq 1 ]; then
  212. echo "Error retriving git repository"
  213. exit 1
  214. fi
  215. if [ ! -x otp_src_git/otp_build ]; then
  216. echo "Not a valid Erlang/OTP repository"
  217. rm -Rf "$KERL_BUILD_DIR/$3"
  218. exit 1
  219. fi
  220. cd otp_src_git
  221. git branch -a | grep "$2" > /dev/null 2>&1
  222. if [ "$?" -eq 1 ]; then
  223. git checkout $2 > /dev/null 2>&1
  224. else
  225. git checkout -b $2 origin/$2 > /dev/null 2>&1
  226. fi
  227. if [ "$?" -eq 1 ]; then
  228. echo "Couldn't checkout specified version"
  229. rm -Rf "$KERL_BUILD_DIR/$3"
  230. exit 1
  231. fi
  232. LOGFILE="$KERL_BUILD_DIR/$3/opt_build.log"
  233. echo "Building Erlang/OTP $3 from git, please wait..."
  234. ./otp_build setup -a $KERL_CONFIGURE_OPTIONS > "$LOGFILE" 2>&1
  235. if [ "$?" -eq 1 ]; then
  236. echo "Build error, see $LOGFILE"
  237. exit 1
  238. fi
  239. rm -f "$LOGFILE"
  240. ./otp_build release -a "$KERL_BUILD_DIR/$3/release_git" > /dev/null 2>&1
  241. cd "$KERL_BUILD_DIR/$3/release_git"
  242. ./Install $INSTALL_OPT "$KERL_BUILD_DIR/$3/release_git" > /dev/null 2>&1
  243. echo "Erlang/OTP $3 from git has been successfully built"
  244. list_add builds "git,$3"
  245. if [ -z "$KERL_DISABLE_AGNER" ]; then
  246. echo "Fetching and building agner..."
  247. cd "$KERL_BUILD_DIR/$3" && \
  248. git clone https://github.com/agner/agner.git agner_git > /dev/null 2>&1 && \
  249. cd agner_git && \
  250. PATH="$KERL_BUILD_DIR/$3/otp_src_git/bin:$PATH" make > /dev/null 2>&1 && \
  251. if [ "$?" -eq 1 ]; then
  252. echo "Agner install failed"; exit 1
  253. fi
  254. echo "Agner has been successfully built"
  255. fi
  256. }
  257. do_build()
  258. {
  259. assert_valid_release $1
  260. assert_build_name_unused $2
  261. FILENAME=otp_src_$1.tar.gz
  262. if [ ! -f "$KERL_DOWNLOAD_DIR/$FILENAME" ]; then
  263. echo "Downloading $FILENAME to $KERL_DOWNLOAD_DIR"
  264. mkdir -p "$KERL_DOWNLOAD_DIR"
  265. curl $ERLANG_DOWNLOAD_URL/$FILENAME > "$KERL_DOWNLOAD_DIR/$FILENAME"
  266. update_checksum_file
  267. fi
  268. ensure_checksum_file
  269. echo "Verifying archive checksum..."
  270. SUM=`$MD5SUM "$KERL_DOWNLOAD_DIR/$FILENAME" | cut -d " " -f $MD5SUM_FIELD`
  271. ORIG_SUM=`grep $FILENAME "$KERL_DOWNLOAD_DIR/MD5" | cut -d " " -f 2`
  272. if [ "$SUM" != "$ORIG_SUM" ]; then
  273. echo "Checksum error, check the files in $KERL_DOWNLOAD_DIR"
  274. exit 1
  275. fi
  276. echo "Checksum verified ($SUM)"
  277. mkdir -p "$KERL_BUILD_DIR/$2"
  278. if [ ! -d "$KERL_BUILD_DIR/$2/otp_src_$1" ]; then
  279. echo "Extracting source code"
  280. cd "$KERL_BUILD_DIR/$2" && tar xfz "$KERL_DOWNLOAD_DIR/$FILENAME"
  281. fi
  282. echo "Building Erlang/OTP $1 ($2), please wait..."
  283. cd "$KERL_BUILD_DIR/$2/otp_src_$1"
  284. LOGFILE="$KERL_BUILD_DIR/$2/otp_build_$1.log"
  285. if [ -n "$KERL_USE_AUTOCONF" ]; then
  286. ./otp_build setup -a $KERL_CONFIGURE_OPTIONS > "$LOGFILE" 2>&1
  287. else
  288. ./otp_build configure $KERL_CONFIGURE_OPTIONS > "$LOGFILE" 2>&1 && \
  289. ./otp_build boot -a > "$LOGFILE" 2>&1
  290. fi
  291. if [ "$?" -eq 1 ]; then
  292. echo "Build failed, see $LOGFILE"
  293. list_remove builds "$1 $2"
  294. exit 1
  295. fi
  296. rm -f "$LOGFILE"
  297. ./otp_build release -a "$KERL_BUILD_DIR/$2/release_$1" > /dev/null 2>&1
  298. cd "$KERL_BUILD_DIR/$2/release_$1"
  299. ./Install $INSTALL_OPT "$KERL_BUILD_DIR/$2/release_$1" > /dev/null 2>&1
  300. echo "Erlang/OTP $1 ($2) has been successfully built"
  301. list_add builds "$1,$2"
  302. if agner_support $1; then
  303. echo "Fetching and building agner..."
  304. cd "$KERL_BUILD_DIR/$2" && \
  305. git clone https://github.com/agner/agner.git agner_$1 > /dev/null 2>&1 && \
  306. cd agner_$1 && \
  307. PATH="$KERL_BUILD_DIR/$2/otp_src_$1/bin:$PATH" make > /dev/null 2>&1 && \
  308. if [ "$?" -eq 1 ]; then
  309. echo "Agner install failed"; exit 1
  310. fi
  311. echo "Agner has been successfully built"
  312. fi
  313. }
  314. do_install()
  315. {
  316. rel=`get_release_from_name $1`
  317. if [ "$?" -eq 1 ]; then
  318. echo "No build named $1"
  319. exit 1
  320. fi
  321. mkdir -p "$2"
  322. if [ ! -d "$2" ]; then
  323. echo "Destination is not a directory"
  324. exit 1
  325. fi
  326. absdir=`cd "$2" && pwd`
  327. echo "Installing Erlang/OTP $rel ($1) in $absdir..."
  328. cd "$KERL_BUILD_DIR/$1/otp_src_$rel"
  329. ./otp_build release -a "$absdir" > /dev/null 2>&1 &&
  330. cd "$absdir" && ./Install $INSTALL_OPT "$absdir" > /dev/null 2>&1
  331. if [ $? -eq 1 ]; then
  332. echo "Couldn't install Erlang/OTP $rel ($1) in $absdir"
  333. exit 1
  334. fi
  335. list_add installations "$1 $absdir";
  336. cat <<ACTIVATE > "$absdir/activate"
  337. # credits to virtualenv
  338. kerl_deactivate()
  339. {
  340. if [ -n "\$_KERL_SAVED_PATH" ]; then
  341. PATH="\$_KERL_SAVED_PATH"
  342. export PATH
  343. unset _KERL_SAVED_PATH
  344. fi
  345. if [ -n "\$_KERL_SAVED_AGNER_BIN" ]; then
  346. AGNER_BIN="\$_KERL_SAVED_AGNER_BIN"
  347. export AGNER_BIN
  348. unset _KERL_SAVED_AGNER_BIN
  349. fi
  350. if [ -n "\$_KERL_SAVED_AGNER_EXACT_PREFIX" ]; then
  351. AGNER_EXACT_PREFIX="\$_KERL_SAVED_AGNER_EXACT_PREFIX"
  352. export AGNER_EXACT_PREFIX
  353. unset _KERL_SAVED_AGNER_EXACT_PREFIX
  354. fi
  355. if [ -n "\$_KERL_SAVED_REBAR_PLT_DIR" ]; then
  356. REBAR_PLT_DIR="\$_KERL_SAVED_REBAR_PLT_DIR"
  357. export REBAR_PLT_DIR
  358. unset _KERL_SAVED_REBAR_PLT_DIR
  359. fi
  360. if [ -n "\$BASH" -o -n "\$ZSH_VERSION" ]; then
  361. hash -r
  362. fi
  363. if [ ! "\$1" = "nondestructive" ]; then
  364. unset -f kerl_deactivate
  365. fi
  366. }
  367. kerl_deactivate nondestructive
  368. _KERL_SAVED_PATH="\$PATH"
  369. export _KERL_SAVED_PATH
  370. _KERL_SAVED_AGNER_BIN="\$AGNER_BIN"
  371. export _KERL_SAVED_AGNER_BIN
  372. _KERL_SAVED_AGNER_EXACT_PREFIX="\$AGNER_EXACT_PREFIX"
  373. export _KERL_SAVED_AGNER_EXACT_PREFIX
  374. _KERL_SAVED_REBAR_PLT_DIR="\$REBAR_PLT_DIR"
  375. export _KERL_SAVED_REBAR_PLT_DIR
  376. PATH="$absdir/bin:\$PATH"
  377. export PATH
  378. AGNER_BIN="$absdir/bin"
  379. export AGNER_BIN
  380. AGNER_EXACT_PREFIX="$absdir/lib"
  381. export AGNER_EXACT_PREFIX
  382. REBAR_PLT_DIR="$absdir"
  383. export REBAR_PLT_DIR
  384. if [ -n "\$BASH" -o -n "\$ZSH_VERSION" ]; then
  385. hash -r
  386. fi
  387. ACTIVATE
  388. if agner_support $1; then
  389. echo "Installing agner in $absdir..."
  390. cp "$KERL_BUILD_DIR/$1/agner_$rel/agner" "$absdir/bin/"
  391. if [ -n "$KERL_INSTALL_AGNERIZED_REBAR" ]; then
  392. echo "Installing agnerized rebar in $absdir..."
  393. cp "$KERL_BUILD_DIR/$1/agner_$rel/agner" "$absdir/bin/rebar"
  394. fi
  395. if [ -n "$KERL_AGNER_AUTOINSTALL" ]; then
  396. for i in $KERL_AGNER_AUTOINSTALL; do
  397. echo "Autoinstalling $i"
  398. agner install $i > /dev/null 2>&1
  399. done
  400. fi
  401. fi
  402. echo "You can activate this installation running the following command:"
  403. echo ". $absdir/activate"
  404. echo "Later on, you can leave the installation typing:"
  405. echo "kerl_deactivate"
  406. }
  407. list_print()
  408. {
  409. if [ -f $KERL_BASE_DIR/otp_$1 ]; then
  410. if [ "`cat "$KERL_BASE_DIR/otp_$1" | wc -l`" != "0" ]; then
  411. if [ -z "$2" ]; then
  412. cat "$KERL_BASE_DIR/otp_$1"
  413. else
  414. echo `cat "$KERL_BASE_DIR/otp_$1"`
  415. fi
  416. return 0
  417. fi
  418. fi
  419. echo "There are no $1 available"
  420. }
  421. list_add()
  422. {
  423. if [ -f "$KERL_BASE_DIR/otp_$1" ]; then
  424. for l in `cat "$KERL_BASE_DIR/otp_$1"`; do
  425. if [ "$l" = "$2" ]; then
  426. return 1
  427. fi
  428. done
  429. echo "$2" >> "$KERL_BASE_DIR/otp_$1"
  430. else
  431. echo "$2" > "$KERL_BASE_DIR/otp_$1"
  432. fi
  433. }
  434. list_remove()
  435. {
  436. if [ -f "$KERL_BASE_DIR/otp_$1" ]; then
  437. sed $SED_OPT -i -e "/^.*$2$/d" "$KERL_BASE_DIR/otp_$1"
  438. fi
  439. }
  440. list_has()
  441. {
  442. if [ -f "$KERL_BASE_DIR/otp_$1" ]; then
  443. grep $2 "$KERL_BASE_DIR/otp_$1" > /dev/null 2>&1 && return 0
  444. fi
  445. return 1
  446. }
  447. list_usage()
  448. {
  449. echo "usage: $0 list <releases|builds|installations>"
  450. }
  451. delete_usage()
  452. {
  453. echo "usage: $0 delete <build|installation> <build_name or path>"
  454. }
  455. update_usage()
  456. {
  457. echo "usage: $0 $1 <releases|agner>"
  458. }
  459. do_active()
  460. {
  461. if [ -n "$_KERL_SAVED_PATH" ]; then
  462. echo "The current active installation is:"
  463. echo `echo $PATH | cut -d ":" -f 1 | sed 's/\(.*\)..../\1/'`
  464. return 0
  465. else
  466. echo "No Erlang/OTP kerl installation is currently active"
  467. return 1
  468. fi
  469. }
  470. case "$1" in
  471. build)
  472. if [ "$2" = "git" ]; then
  473. if [ $# -ne 5 ]; then
  474. echo "usage: $0 $1 $2 <git_url> <git_version> <build_name>"
  475. exit 1
  476. fi
  477. do_git_build $3 $4 $5
  478. else
  479. if [ $# -lt 3 ]; then
  480. echo "usage: $0 $1 <release> <build_name>"
  481. exit 1
  482. fi
  483. do_build $2 $3
  484. fi
  485. ;;
  486. install)
  487. if [ $# -lt 2 ]; then
  488. echo "usage: $0 $1 <build_name> [directory]"
  489. exit 1
  490. fi
  491. if [ $# -eq 3 ]; then
  492. do_install $2 "$3"
  493. else
  494. do_install $2 .
  495. fi
  496. ;;
  497. update)
  498. if [ $# -lt 2 ]; then
  499. update_usage
  500. exit 1
  501. fi
  502. case "$2" in
  503. releases)
  504. rm -f "$KERL_BASE_DIR/otp_releases"
  505. check_releases
  506. echo "The available releases are:"
  507. list_print releases spaces
  508. ;;
  509. agner)
  510. if [ $# -ne 3 ]; then
  511. echo "usage: $0 $1 $2 <build_name>"
  512. exit 1
  513. fi
  514. if agner_support $3; then
  515. echo "Updating agner for build $3..."
  516. if do_update_agner $3; then
  517. echo "agner has been updated successfully"
  518. else
  519. echo "failed to update agner"
  520. exit 1
  521. fi
  522. fi
  523. ;;
  524. *)
  525. update_usage
  526. exit 1
  527. ;;
  528. esac
  529. ;;
  530. list)
  531. if [ $# -ne 2 ]; then
  532. list_usage
  533. exit 1
  534. fi
  535. case "$2" in
  536. releases)
  537. check_releases
  538. list_print $2 space
  539. echo "Run \"$0 update releases\" to update this list from erlang.org"
  540. ;;
  541. builds)
  542. list_print $2
  543. ;;
  544. installations)
  545. list_print $2
  546. ;;
  547. *)
  548. echo "Cannot list $2"
  549. list_usage
  550. exit 1
  551. ;;
  552. esac
  553. ;;
  554. delete)
  555. if [ $# -ne 3 ]; then
  556. delete_usage
  557. exit 1
  558. fi
  559. case "$2" in
  560. build)
  561. rel=`get_release_from_name $3`
  562. if [ -d "$KERL_BUILD_DIR/$3" ]; then
  563. rm -Rf "$KERL_BUILD_DIR/$3"
  564. list_remove $2s "$rel,$3"
  565. echo "The $3 build has been deleted"
  566. else
  567. echo "No build named $3"
  568. exit 1
  569. fi
  570. ;;
  571. installation)
  572. if is_valid_installation "$3"; then
  573. rm -Rf "$3"
  574. escaped=`echo "$3" | sed $SED_OPT -e 's#/$##' -e 's#\/#\\\/#g'`
  575. list_remove $2s "$escaped"
  576. echo "The installation in $3 has been deleted"
  577. else
  578. echo "$3 is not a kerl-managed Erlang/OTP installation"
  579. exit 1
  580. fi
  581. ;;
  582. *)
  583. echo "Cannot delete $2"
  584. delete_usage
  585. exit 1
  586. ;;
  587. esac
  588. ;;
  589. active)
  590. if ! do_active; then
  591. exit 1;
  592. fi
  593. ;;
  594. status)
  595. echo "Available builds:"
  596. list_print builds
  597. echo "----------"
  598. echo "Available installations:"
  599. list_print installations
  600. echo "----------"
  601. do_active
  602. exit 0
  603. ;;
  604. *)
  605. echo "unkwnown command: $1"; usage; exit 1
  606. ;;
  607. esac