wok view get-bitcoin/stuff/get-bitcoin @ rev 22824

graveman: change icon for 'about'
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Feb 06 17:19:39 2020 +0100 (2020-02-06)
parents c07aaa614a02
children 49bbb4b9da3c
line source
1 #!/bin/sh
2 #
3 # get-bitcoin - create and install SliTaz package bitcoin
4 #
5 # (C) 2020 SliTaz - GNU General Public License v3.
6 # Author : unknown
7 # modified by HGT on 2020-01-29
8 #
10 # === Initialisations ===
12 PKGS_DB="/var/lib/tazpkg" # packages database directory
13 PACKAGE="bitcoin"
14 CATEGORY="misc"
15 SHORT_DESC="New digital currency for instant payments to anyone, anywhere."
16 MAINTAINER="somebody@$PACKAGE.org"
17 WEB_SITE="https://bitcoin.org/"
18 DEPENDS="libQtGui bzlib"
20 # Declare functions check_root, status, ...
21 . /lib/libtaz.sh
22 # and make commandline options (if any) available as variables
24 is_installed()
25 {
26 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
27 then #package is deemed to be installed
28 return 0
29 else
30 return 1
31 fi
32 }
34 # Show commandline options, if requested by --help
35 if [ "$help" == "yes" ]
36 then
37 echo "Commandline options:
38 $0
39 --version=<version>
40 --root=<path-to-root>
41 --install=yes|no
42 --keep=no|yes
43 --tmpdir=<directory-to-build-package>"
44 exit
45 fi
47 # Check for system administrator privileges
48 check_root
50 title "Package $PACKAGE will be build as SliTaz package and installed"
52 # Fetch latest version, unless version is set by option --version
53 [ -z "$version" ] && version="latest"
55 # Install SliTaz package, unless inhibited by option --install=no
56 [ -z "$install" ] && install="yes"
58 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
59 # unless option --keep=yes is given
60 [ -z "$keep" ] && keep="no"
62 # Directory for temporary files
63 [ -z "$tempdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
65 # Logging file (unused by now)
66 LOG=$TMP_DIR/get-$PACKAGE.log
68 cat <<EOT
69 Options in use:
70 root : $root/
71 version : $version
72 install package: $install
73 keep tazpkg : $keep
74 build directory: $TMP_DIR
76 EOT
78 separator; newline
80 # === Remove package, if installed ===
81 if [ is_installed ]
82 then
83 action "Removing installed version..."
84 tazpkg remove $PACKAGE --root="$root/"
85 [ ! is_installed ] &&
86 die "Can't remove installed version. Exiting."
87 fi
89 # === Fetch archive file, if not existing ===
90 if [ "$version" == "latest" ]
91 then
92 WGET_URL=$(wget -q --no-check-certificate -O - ${WEB_SITE}en/download | \
93 sed '/linux-gnu.tar/!d; /i686/!d; s/.*href="\([^"]*\).*/\1/; s|/download$||')
94 WGET_URL=${WEB_SITE}$WGET_URL
95 FILE="$(basename $WGET_URL)"
96 VERSION="$(echo $FILE | sed 's|.*coin-\(.*\)-i686.*|\1|')"
97 else
98 FILE="bitcoin-$version-i686-pc-linux-gnu.tar.gz"
99 WGET_URL="https://bitcoincore.org/bin/bitcoin-core-$version/$FILE"
100 VERSION=$version
101 fi
103 CUR_DIR=$(pwd)
104 mkdir -p $TMP_DIR
105 cd $TMP_DIR
106 if [ -f $FILE ]
107 then
108 echo "Using existing archive file $FILE"
109 else
110 action "Fetching the archive"
111 newline
112 wget --no-check-certificate $WGET_URL
113 if [ ! -f $FILE ]
114 then
115 cd $CUR_DIR
116 rm -rf $TMP_DIR
117 echo "Could not transfer $FILE from $WGET_URL. Exiting."
118 exit 1
119 fi
120 fi
122 # === Extract files from archive ===
123 action "Extracting the archive"
124 newline
125 busybox tar x -f $FILE
127 mkdir -p $PACKAGE-$VERSION/fs/usr/bin
128 mv $PACKAGE-$VERSION/bin/* $PACKAGE-$VERSION/fs/usr/bin
130 # Remove archive file
131 rm -f $FILE
133 # === Create SliTaz package ===
135 cd $PACKAGE-$VERSION/fs
137 # Create menu
138 mkdir -p usr/share/applications
139 cat > usr/share/applications/$PACKAGE.desktop <<EOT
140 [Desktop Entry]
141 Version=1.0
142 Encoding=UTF-8
143 Name=$PACKAGE
144 Exec=/usr/bin/$PACKAGE-qt
145 Icon=stock_certificate.png
146 Terminal=false
147 Categories=Application
148 Comment=$SHORT_DESC
149 Type=Application
150 Categories=Office;
151 EOT
153 cd ..
155 # Create recipe for SliTaz package
156 cat > receipt <<EOT
157 PACKAGE="$PACKAGE"
158 VERSION="$VERSION"
159 CATEGORY="$CATEGORY"
160 SHORT_DESC="$SHORT_DESC"
161 MAINTAINER="$MAINTAINER"
162 DEPENDS="$DEPENDS"
163 WEB_SITE="$WEB_SITE"
164 EOT
166 cd $TMP_DIR
168 action "Creating the package $PACKAGE..."
169 # Pack
170 tazpkg pack $PACKAGE-$VERSION
172 # Remove package tree
173 rm -rf $PACKAGE-$VERSION
175 # === Install the SliTaz package ===
176 [ "$install" == "yes" ] &&
177 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
179 # === Cleanup ===
180 # Preserve package file, if requested
181 [ "$keep" == "yes" ] &&
182 mv $PACKAGE-$VERSION.tazpkg $CUR_DIR
184 # Remove temporary build directory
185 cd $CUR_DIR
186 rm -rf $TMP_DIR