blob: 0797e5792673a4945bc619bbc689185d1ffb66c7 (
plain)
1 #!/usr/bin/env bash
2 #
3 # Portimg uses Crux port-like system for creating software deployment images.
4 # Copyright (C) 2016 Aaron Ball <nullspoon@oper.io>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 function archive_extract {
21 local src=${1:-}
22 local dest=${2:-}
23
24 local ext=${src##*.}
25
26 if [[ ${ext} == 'tar'
27 || ${ext} == 'gz'
28 || ${ext} == 'tgz'
29 || ${ext} == 'xz'
30 || ${ext} == 'bz2' ]]; then
31 tar -xf ${src} -C ${dest}
32 elif [[ ${ext} == 'zip' ]]; then
33 unzip ${src} -d ${dest}
34 fi
35 }
36
37
38 function download_src {
39 local uri=${1:-}
40 local destdir=${2:-}
41
42 local localname=$(basename ${uri})
43
44 curl -L -s -k -o "${destdir}/${localname}" "${uri}"
45 }
|