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
1a2a3c4e
Commit
1a2a3c4e
authored
Aug 16, 2013
by
Michał Siwek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement working install and remove commands
parent
e77b6798
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
11 deletions
+44
-11
cbrew.coffee
cbrew.coffee
+36
-5
device.json
device.json
+6
-0
formulas/mpfr.coffee
formulas/mpfr.coffee
+2
-6
No files found.
cbrew.coffee
View file @
1a2a3c4e
...
...
@@ -5,16 +5,23 @@ fs = require 'fs'
events
=
require
'events'
global
.
eventDispatch
=
new
events
.
EventEmitter
crypto
=
require
'crypto'
tgz
=
require
'tar.gz'
ncp
=
require
'ncp'
ncp
=
ncp
.
ncp
network
=
require
'./network.coffee'
ncp
.
limit
=
16
program
.
version
'0.0.1'
program
.
parse
process
.
argv
@
device
=
require
'./device.json'
action
=
process
.
argv
[
2
]
pkgName
=
process
.
argv
[
3
]
@
pkg
=
(
pkgName
)
->
eventDispatch
.
on
'packageFound'
,
->
@
pkg
=
require
'./formulas/'
+
pkgName
+
'.coffee'
global
.
pkgVersion
=
@
pkg
.
version
eventDispatch
.
on
'packageNotFound'
,
->
console
.
log
'package '
+
pkgName
+
' not found :('
process
.
exit
1
...
...
@@ -34,7 +41,8 @@ search = (pkgName) =>
download
=
(
pkgName
)
=>
@
pkg
pkgName
eventDispatch
.
on
'packageFound'
,
->
@
pkg
.
getSource
()
unless
@
pkg
.
getBinary
()
if
@
pkg
.
binary_url
then
network
.
getFile
@
pkg
.
binary_url
else
network
.
getFile
@
pkg
.
source_url
eventDispatch
.
on
'filename'
,
(
filename
)
->
@
pkg
.
filename
=
filename
eventDispatch
.
on
'gotPackage'
,
->
...
...
@@ -42,17 +50,40 @@ download = (pkgName) =>
stream
=
fs
.
ReadStream
@
pkg
.
filename
stream
.
on
'data'
,
(
data
)
->
sha1sum
.
update
data
stream
.
on
'end'
,
-
>
stream
.
on
'end'
,
=
>
digest
=
sha1sum
.
digest
'hex'
console
.
log
digest
checksum
=
@
pkg
.
binary_sha1
or
@
pkg
.
source_sha1
eventDispatch
.
emit
'packageSumOk'
unless
digest
isnt
checksum
install
=
(
pkgName
)
=>
eventDispatch
.
on
'extractedPackage'
,
=>
console
.
log
'installing package...'
ncp
'./usr'
,
'./xd'
,
(
error
)
=>
@
device
.
installed_packages
.
push
{
name
:
pkgName
,
version
:
pkgVersion
}
fs
.
writeFile
'./device.json'
,
JSON
.
stringify
@
device
,
null
,
2
ncp
'./filelist'
,
'./meta/'
+
pkgName
+
'.filelist'
,
(
error
)
->
console
.
log
'package '
+
pkgName
+
' installed!'
unless
error
eventDispatch
.
on
'packageSumOk'
,
->
console
.
log
'extracting archive...'
new
tgz
().
extract
'./'
+
@
pkg
.
filename
,
'.'
,
(
error
)
->
eventDispatch
.
emit
'extractedPackage'
unless
error
download
pkgName
eventDispatch
.
on
'gotPackage'
,
->
@
pkg
.
build
()
unless
@
pkg
.
installBinary
()
remove
=
(
pkgName
)
=>
fs
.
readFile
'./meta/'
+
pkgName
+
'.filelist'
,
(
error
,
data
)
->
throw
error
if
error
lines
=
data
.
toString
().
split
'
\n
'
fs
.
unlink
'.'
+
line
for
line
in
lines
console
.
log
pkgName
+
' removed!'
showStatus
=
=>
console
.
log
pkg
.
name
+
': '
+
pkg
.
version
for
pkg
in
@
device
.
installed_packages
switch
action
when
"search"
then
search
pkgName
when
"download"
then
download
pkgName
when
"install"
then
install
pkgName
when
"remove"
then
remove
pkgName
when
"status"
then
showStatus
()
device.json
0 → 100644
View file @
1a2a3c4e
{
"architecture"
:
"i686"
,
"installed_packages"
:
[
]
}
formulas/mpfr.coffee
View file @
1a2a3c4e
network
=
require
'../network.coffee'
module
.
exports
=
version
:
"3.1.2"
binary_url
:
"https://dl.dropboxusercontent.com/s/lo9ks3g7ar3zpfu/mpfr-3.1.2-chromeos-i686.tar.gz?token_hash=AAH1GlLfYtUs4uxl1ayeGTBe8RJ5uTXzOAsXgSlv8G5rrA&dl=1"
binary_sha1
:
"763c0228359f99c8a6af5c8b8da628b089eb5451"
getBinary
:
(
callback
)
->
network
.
getFile
@
binary_url
binary_sha1
:
"ad8a29c21322f245ea0a03045aeb0b07b36cd361"
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