Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
chromebrew
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
chromebrew
Commits
e77b6798
Commit
e77b6798
authored
Aug 15, 2013
by
Michał Siwek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement downloading and searching with sha1sum verification
parent
ad4b94b4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
14 deletions
+45
-14
cbrew.coffee
cbrew.coffee
+40
-10
formulas/binutils.coffee
formulas/binutils.coffee
+1
-1
formulas/mpfr.coffee
formulas/mpfr.coffee
+2
-2
network.coffee
network.coffee
+2
-1
No files found.
cbrew.coffee
View file @
e77b6798
#!/usr/local/bin/coffee
program
=
require
'commander'
fs
=
require
'fs'
events
=
require
'events'
global
.
eventDispatch
=
new
events
.
EventEmitter
crypto
=
require
'crypto'
program
.
version
'0.0.1'
program
.
parse
process
.
argv
...
...
@@ -9,20 +12,47 @@ program.parse process.argv
action
=
process
.
argv
[
2
]
pkgName
=
process
.
argv
[
3
]
search
=
(
pkgName
,
callback
)
->
fs
.
readdir
'.'
,
(
err
,
files
)
=>
callback
file
for
file
in
files
when
file
.
indexOf
(
pkgName
)
isnt
-
1
@
pkg
=
(
pkgName
)
->
eventDispatch
.
on
'packageFound'
,
->
@
pkg
=
require
'./formulas/'
+
pkgName
+
'.coffee'
eventDispatch
.
on
'packageNotFound'
,
->
console
.
log
'package '
+
pkgName
+
' not found :('
process
.
exit
1
look_for
pkgName
look_for
=
(
pkgName
)
->
fs
.
readdir
'formulas'
,
(
err
,
files
)
->
return
eventDispatch
.
emit
'packageFound'
for
file
in
files
when
file
.
indexOf
(
pkgName
)
isnt
-
1
return
eventDispatch
.
emit
'packageNotFound'
download
=
(
pkgName
)
->
pkg
=
require
'./'
+
pkgName
+
'.coffee'
pkg
.
getBinary
()
search
=
(
pkgName
)
=>
@
pkg
pkgName
eventDispatch
.
on
'packageFound'
,
->
console
.
log
pkgName
+
' found!'
install
=
(
pkgName
)
->
download
=
(
pkgName
)
=>
@
pkg
pkgName
eventDispatch
.
on
'packageFound'
,
->
@
pkg
.
getSource
()
unless
@
pkg
.
getBinary
()
eventDispatch
.
on
'filename'
,
(
filename
)
->
@
pkg
.
filename
=
filename
eventDispatch
.
on
'gotPackage'
,
->
sha1sum
=
crypto
.
createHash
'sha1'
stream
=
fs
.
ReadStream
@
pkg
.
filename
stream
.
on
'data'
,
(
data
)
->
sha1sum
.
update
data
stream
.
on
'end'
,
->
digest
=
sha1sum
.
digest
'hex'
console
.
log
digest
install
=
(
pkgName
)
=>
download
pkgName
eventDispatch
.
on
'gotFile'
,
->
console
.
log
"installing..."
eventDispatch
.
on
'gotPackage'
,
->
@
pkg
.
build
()
unless
@
pkg
.
installBinary
()
switch
action
when
"search"
then
search
pkgName
,
console
.
log
when
"search"
then
search
pkgName
when
"download"
then
download
pkgName
when
"install"
then
install
pkgName
formulas/binutils.coffee
View file @
e77b6798
network
=
require
'./network.coffee'
network
=
require
'.
.
/network.coffee'
module
.
exports
=
binary_url
:
"https://dl.dropboxusercontent.com/s/u3cp7mpdyfx99ij/binutils-2.23.2-chromeos-i686.tar.gz?token_hash=AAGsFB9HXNb5tSAm_Wd2GyIUL59BkZYgMTHkj4CkHLxggg&dl=1"
...
...
formulas/mpfr.coffee
View file @
e77b6798
network
=
require
'./network.coffee'
network
=
require
'.
.
/network.coffee'
module
.
exports
=
binary_url
:
"https://dl.dropboxusercontent.com/s/lo9ks3g7ar3zpfu/mpfr-3.1.2-chromeos-i686.tar.gz?token_hash=AAH1GlLfYtUs4uxl1ayeGTBe8RJ5uTXzOAsXgSlv8G5rrA&dl=1"
binary_sha1
:
""
binary_sha1
:
"
763c0228359f99c8a6af5c8b8da628b089eb5451
"
getBinary
:
(
callback
)
->
network
.
getFile
@
binary_url
network.coffee
View file @
e77b6798
...
...
@@ -7,6 +7,7 @@ module.exports.getFile = (url) ->
len
=
parseInt
res
.
headers
[
'content-length'
],
10
content_disposition
=
res
.
headers
[
'content-disposition'
]
filename
=
content_disposition
.
substring
content_disposition
.
indexOf
(
'"'
)
+
1
,
content_disposition
.
length
-
1
eventDispatch
.
emit
'filename'
,
filename
console
.
log
();
bar
=
new
progressbar
' downloading [:bar] :percent :etas'
,
{
...
...
@@ -21,4 +22,4 @@ module.exports.getFile = (url) ->
bar
.
tick
chunk
.
length
res
.
on
'end'
,
->
eventDispatch
.
emit
'got
Fil
e'
eventDispatch
.
emit
'got
Packag
e'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment