npm ERR! Error: EACCES, mkdir

I follow this tutorial https://scotch.io/tutorials/make-a-mobile-app-with-reactjs-in-30-minutes

and meet below error after “reapp new flickrapp"

$ reapp new flickrapp

Creating new reapp folder for: flickrapp...
Running git clone --depth=1 https://github.com/reapp/starter-default /home/owen/flickrapp...
Running git init...
Inserting your name...
Running npm install...

 Error
{ [Error: Command failed: npm WARN package.json flickrapp@1.0.0 No repository field.
npm ERR! Error: EACCES, mkdir '/home/owen/.npm/react/0.12.2'
npm ERR!  { [Error: EACCES, mkdir '/home/owen/.npm/react/0.12.2']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/home/owen/.npm/react/0.12.2',
npm ERR!   parent: 'reapp-platform' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.16.0-33-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/owen/flickrapp
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! path /home/owen/.npm/react/0.12.2
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/home/owen/.npm/react/0.12.2'
npm ERR! not ok code 0
] killed: false, code: 3, signal: null }

after a quick google, I found a solution here https://github.com/npm/npm/issues/5869

sudo chown -R $USER:$GROUP ~/.npm

and it works for me

how to install coturn, create postgres db and create adminuser for coturn

  1. wget http://turnserver.open-sys.org/downloads/v4.4.2.3/turnserver-4.4.2.3-debian-wheezy-ubuntu-mint-x86-64bits.tar.gz
  2. tar zxf turnserver-4.4.2.3-debian-wheezy-ubuntu-mint-x86-64bits.tar.gz
  3. sudo apt-get install gdebi-core
  4. sudo gdebi coturn*.deb
  5. sudo apt-get install postgresql
  6. sudo su postgres
  7. createuser -A -D -P -E coturn
  8. createdb -E UTF-8 -O coturn coturndb
  9. exit
  10. git clone https://github.com/svn2github/coturn.git
  11. cd coturn
  12. psql -h localhost –username coturn –file turndb/schema.sql coturndb
  13. turnadmin –psql-userdb="postgresql://coturn:xxxxxx@localhost:5432/coturndb" –add-admin –user="owen_wen" –password="xxxxxx"
  14. psql -h localhost –username coturn coturndb –command ‘select * from admin_user’

Q: 0: ERROR: Cannot open PostgreSQL DB connection , connection string format error: missing “=" after “postgresql://coturn:xxxxxx@localhost:5432/coturndb" in connection info string
A: Try another postgres connection string “host=localhost dbname=coturndb user=coturn password=xxxxxx connect_timeout=3600″

why coturn tot_recv_bytes is 0

My steps:
1. git clone https://github.com/svn2github/coturn.git
2. cd coturn
3. cd examples/scripts/basic
4. ./relay.sh
5. open another shell
6. ./tcp_client.sh

then I encounter below error:

$ ./tcp_client.sh                                                                                                                  [29/161]
0: Total connect time is 1
0: start_mclient: msz=10, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0
1: start_mclient: msz=10, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0
2: start_mclient: msz=10, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0
3: start_mclient: msz=10, tot_send_msgs=35, tot_recv_msgs=0, tot_send_bytes ~ 106295, tot_recv_bytes ~ 0
4: start_mclient: msz=10, tot_send_msgs=169, tot_recv_msgs=0, tot_send_bytes ~ 513253, tot_recv_bytes ~ 0
5: start_mclient: msz=10, tot_send_msgs=441, tot_recv_msgs=0, tot_send_bytes ~ 1339317, tot_recv_bytes ~ 0
6: start_mclient: msz=10, tot_send_msgs=801, tot_recv_msgs=0, tot_send_bytes ~ 2432637, tot_recv_bytes ~ 0
7: start_mclient: msz=10, tot_send_msgs=1305, tot_recv_msgs=0, tot_send_bytes ~ 3963285, tot_recv_bytes ~ 0
8: start_mclient: msz=10, tot_send_msgs=1806, tot_recv_msgs=0, tot_send_bytes ~ 5484822, tot_recv_bytes ~ 0
9: start_mclient: msz=10, tot_send_msgs=2312, tot_recv_msgs=0, tot_send_bytes ~ 7021544, tot_recv_bytes ~ 0
10: start_mclient: msz=10, tot_send_msgs=2815, tot_recv_msgs=0, tot_send_bytes ~ 8549155, tot_recv_bytes ~ 0
11: start_mclient: msz=10, tot_send_msgs=3320, tot_recv_msgs=0, tot_send_bytes ~ 10082840, tot_recv_bytes ~ 0
12: start_mclient: msz=10, tot_send_msgs=3825, tot_recv_msgs=0, tot_send_bytes ~ 11616525, tot_recv_bytes ~ 0
13: start_mclient: msz=10, tot_send_msgs=4276, tot_recv_msgs=0, tot_send_bytes ~ 12986212, tot_recv_bytes ~ 0
14: start_mclient: msz=10, tot_send_msgs=4782, tot_recv_msgs=0, tot_send_bytes ~ 14522934, tot_recv_bytes ~ 0
15: start_mclient: msz=10, tot_send_msgs=5285, tot_recv_msgs=0, tot_send_bytes ~ 16050545, tot_recv_bytes ~ 0
16: start_mclient: msz=10, tot_send_msgs=5788, tot_recv_msgs=0, tot_send_bytes ~ 17578156, tot_recv_bytes ~ 0
17: start_mclient: msz=10, tot_send_msgs=6293, tot_recv_msgs=0, tot_send_bytes ~ 19111841, tot_recv_bytes ~ 0
18: start_mclient: msz=10, tot_send_msgs=6795, tot_recv_msgs=0, tot_send_bytes ~ 20636415, tot_recv_bytes ~ 0
19: start_mclient: msz=10, tot_send_msgs=7298, tot_recv_msgs=0, tot_send_bytes ~ 22164026, tot_recv_bytes ~ 0
20: start_mclient: msz=10, tot_send_msgs=7803, tot_recv_msgs=0, tot_send_bytes ~ 23697711, tot_recv_bytes ~ 0
21: start_mclient: msz=10, tot_send_msgs=8305, tot_recv_msgs=0, tot_send_bytes ~ 25222285, tot_recv_bytes ~ 0
22: start_mclient: msz=10, tot_send_msgs=8810, tot_recv_msgs=0, tot_send_bytes ~ 26755970, tot_recv_bytes ~ 0
23: start_mclient: msz=10, tot_send_msgs=9274, tot_recv_msgs=0, tot_send_bytes ~ 28165138, tot_recv_bytes ~ 0
24: start_mclient: msz=10, tot_send_msgs=9637, tot_recv_msgs=0, tot_send_bytes ~ 29267569, tot_recv_bytes ~ 0
25: start_mclient: msz=10, tot_send_msgs=9863, tot_recv_msgs=0, tot_send_bytes ~ 29953931, tot_recv_bytes ~ 0
26: start_mclient: msz=10, tot_send_msgs=9999, tot_recv_msgs=0, tot_send_bytes ~ 30366963, tot_recv_bytes ~ 0
27: start_mclient: msz=10, tot_send_msgs=10000, tot_recv_msgs=0, tot_send_bytes ~ 30370000, tot_recv_bytes ~ 0
27: start_mclient: msz=10, tot_send_msgs=10000, tot_recv_msgs=0, tot_send_bytes ~ 30370000, tot_recv_bytes ~ 0
29: start_mclient: msz=10, tot_send_msgs=10000, tot_recv_msgs=0, tot_send_bytes ~ 30370000, tot_recv_bytes ~ 0
30: start_mclient: msz=10, tot_send_msgs=10000, tot_recv_msgs=0, tot_send_bytes ~ 30370000, tot_recv_bytes ~ 0
31: start_mclient: msz=10, tot_send_msgs=10000, tot_recv_msgs=0, tot_send_bytes ~ 30370000, tot_recv_bytes ~ 0
32: start_mclient: msz=10, tot_send_msgs=10000, tot_recv_msgs=0, tot_send_bytes ~ 30370000, tot_recv_bytes ~ 0
33: start_mclient: msz=8, tot_send_msgs=10000, tot_recv_msgs=0, tot_send_bytes ~ 30370000, tot_recv_bytes ~ 0
34: start_mclient: msz=6, tot_send_msgs=10000, tot_recv_msgs=0, tot_send_bytes ~ 30370000, tot_recv_bytes ~ 0
35: start_mclient: msz=4, tot_send_msgs=10000, tot_recv_msgs=0, tot_send_bytes ~ 30370000, tot_recv_bytes ~ 0
36: start_mclient: msz=1, tot_send_msgs=10000, tot_recv_msgs=0, tot_send_bytes ~ 30370000, tot_recv_bytes ~ 0
36: start_mclient: tot_send_msgs=10000, tot_recv_msgs=0
36: start_mclient: tot_send_bytes ~ 30370000, tot_recv_bytes ~ 0
36: Total transmit time is 36
36: Total lost packets 10000 (100.000000%), total send dropped 0 (0.000000%)
36: Average round trip delay 0.000000 ms; min = 4294967295 ms, max = 0 ms
36: Average jitter -nan ms; min = 4294967295 ms, max = 0 ms

After a quick google, found a solution

https://groups.google.com/forum/#!msg/turn-server-project-rfc5766-turn-server/IDNnSlujlXY/EOTO7xZPyl8J

the root cause is that I need to run example/scripts/basic/peer.sh first

1. git clone https://github.com/svn2github/coturn.git
2. cd coturn
3. cd examples/scripts/basic
4. ./relay.sh
5. open another shell
6. cd ../
7. ./peer.sh
8. cd basic
9. ./tcp_client.sh

$ ./tcp_client.sh 
0: Total connect time is 1
0: start_mclient: msz=10, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0
1: start_mclient: msz=10, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0
2: start_mclient: msz=10, tot_send_msgs=24, tot_recv_msgs=24, tot_send_bytes ~ 72888, tot_recv_bytes ~ 72888
3: start_mclient: msz=10, tot_send_msgs=146, tot_recv_msgs=146, tot_send_bytes ~ 443402, tot_recv_bytes ~ 443402
4: start_mclient: msz=10, tot_send_msgs=476, tot_recv_msgs=476, tot_send_bytes ~ 1445612, tot_recv_bytes ~ 1445612
5: start_mclient: msz=10, tot_send_msgs=944, tot_recv_msgs=944, tot_send_bytes ~ 2866928, tot_recv_bytes ~ 2866928
6: start_mclient: msz=10, tot_send_msgs=1448, tot_recv_msgs=1448, tot_send_bytes ~ 4397576, tot_recv_bytes ~ 4397576
7: start_mclient: msz=10, tot_send_msgs=1950, tot_recv_msgs=1950, tot_send_bytes ~ 5922150, tot_recv_bytes ~ 5922150
8: start_mclient: msz=10, tot_send_msgs=2451, tot_recv_msgs=2451, tot_send_bytes ~ 7443687, tot_recv_bytes ~ 7443687
9: start_mclient: msz=10, tot_send_msgs=2954, tot_recv_msgs=2953, tot_send_bytes ~ 8971298, tot_recv_bytes ~ 8968261
10: start_mclient: msz=10, tot_send_msgs=3457, tot_recv_msgs=3456, tot_send_bytes ~ 10498909, tot_recv_bytes ~ 10495872
11: start_mclient: msz=10, tot_send_msgs=3959, tot_recv_msgs=3958, tot_send_bytes ~ 12023483, tot_recv_bytes ~ 12020446
12: start_mclient: msz=10, tot_send_msgs=4461, tot_recv_msgs=4460, tot_send_bytes ~ 13548057, tot_recv_bytes ~ 13545020
13: start_mclient: msz=10, tot_send_msgs=4914, tot_recv_msgs=4913, tot_send_bytes ~ 14923818, tot_recv_bytes ~ 14920781
14: start_mclient: msz=10, tot_send_msgs=5417, tot_recv_msgs=5416, tot_send_bytes ~ 16451429, tot_recv_bytes ~ 16448392
15: start_mclient: msz=10, tot_send_msgs=5919, tot_recv_msgs=5918, tot_send_bytes ~ 17976003, tot_recv_bytes ~ 17972966
16: start_mclient: msz=10, tot_send_msgs=6421, tot_recv_msgs=6420, tot_send_bytes ~ 19500577, tot_recv_bytes ~ 19497540
17: start_mclient: msz=10, tot_send_msgs=6923, tot_recv_msgs=6923, tot_send_bytes ~ 21025151, tot_recv_bytes ~ 21025151
18: start_mclient: msz=10, tot_send_msgs=7424, tot_recv_msgs=7424, tot_send_bytes ~ 22546688, tot_recv_bytes ~ 22546688
19: start_mclient: msz=10, tot_send_msgs=7928, tot_recv_msgs=7928, tot_send_bytes ~ 24077336, tot_recv_bytes ~ 24077336
20: start_mclient: msz=10, tot_send_msgs=8431, tot_recv_msgs=8430, tot_send_bytes ~ 25604947, tot_recv_bytes ~ 25601910
21: start_mclient: msz=10, tot_send_msgs=8934, tot_recv_msgs=8933, tot_send_bytes ~ 27132558, tot_recv_bytes ~ 27129521
22: start_mclient: msz=10, tot_send_msgs=9412, tot_recv_msgs=9410, tot_send_bytes ~ 28584244, tot_recv_bytes ~ 28578170
23: start_mclient: msz=10, tot_send_msgs=9792, tot_recv_msgs=9792, tot_send_bytes ~ 29738304, tot_recv_bytes ~ 29738304
24: start_mclient: msz=10, tot_send_msgs=9965, tot_recv_msgs=9964, tot_send_bytes ~ 30263705, tot_recv_bytes ~ 30260668
24: start_mclient: tot_send_msgs=10000, tot_recv_msgs=10000
24: start_mclient: tot_send_bytes ~ 30370000, tot_recv_bytes ~ 30370000
24: Total transmit time is 24
24: Total lost packets 0 (0.000000%), total send dropped 0 (0.000000%)
24: Average round trip delay 0.002000 ms; min = 0 ms, max = 2 ms
24: Average jitter 0.220100 ms; min = 0 ms, max = 3 ms

So, what is “peer"?

https://code.google.com/p/coturn/wiki/turnutils_peer

turnutils_peer is a simple UDP-only echo backend server. This application is used for the test purposes only, as a ‘peer’ for the turnutils_uclient application.

To sum up, turnutils_peer is another client.

how to create sqlite db for coturn

1. git clone https://github.com/svn2github/coturn.git
2. cd coturn
3. sudo mkdir -p /usr/local/var/db/ (why here? https://code.google.com/p/coturn/wiki/Readme#FILES)
4. sudo sqlite3 /usr/local/var/db/turndb < turndb/schema.sql (read INSTALL and makesure what version of sqlite to use)

Q: what is “ERROR: Error retrieving SQLite DB information: file is encrypted or is not a database"
A: should be a wrong sqlite version

how to create turn_server_cert.pem for coturn server

1. refer here to create certificate and private key, http://grahamc.com/blog/openssl-madness-how-to-create-keys-certificate-signing-requests-authorities-and-pem-files/
2. copy the certificate and private key to /usr/local/etc(why here? https://code.google.com/p/coturn/wiki/turnserver#Config_file_setting)
3. restart the service and you should see

0: Config file found: /usr/local/etc/turn_server_cert.pem
0: Config file found: /usr/local/etc/turn_server_pkey.pem

Qualcomm chipcode web spider

Qualcomm chipcode web spider

In order to fetch chipcode from QCT automatically, I use Firebug to monitor the Header sent to chipcode when login and fetch git info

something matter below

you can simply analysis http://chipcode.qti.qualcomm.com/ to get login URI and param

wget --save-cookies cookies.txt --server-response --post-data 'SMENC=ISO-8859-1&SMLOCALE=US-EN&USER=XXX%40XXX.XXX&PASSWORD=XXXXXXX&target=HTTPS%3A%2F%2Fchipcode.qti.qualcomm.com%2F&smagentname=-SM-SLUS8QqcnzRRGvPvY33l1s3xpnEDhOnjsY6tAWAu2LAkp3RKERaMNP67RRT%2B2TSe' https://chipcode.qti.qualcomm.com/siteminderagent/forms/login.fcc

It’s very important to add “–server-response", since chipcode server will response session info in HEADERS, and you will need the session info to sent GET request

you will get a file named “login.fcc" and you can find all product you can access to

besides login.fcc, you should get a lot of stdout including HEADERS

Copy the value of last Set-Cookie from those HEADERS

use wget with –header to set SMSESSION you copied above

wget --header='cookie:tour_viewed_dashboard_projects=true; SMSESSION=BLtgPXCgOV1l+nFGsdRHjvWP9vPN0OXyq1d7nToGgInH/UuUvPlM7/qB07ijzeq2t2Ul/BBLtoy6q+OuQcFHEn57RB+mPERUonp0aRAHqm4PgmJg1SFn65dKK97YJ61E637X75VdOkR5VB2E933xsA+XCcjYfOpBLgaU9+7ToVyV4G9iyimoLAie1UuhEg40Ow7jLqvbAYaFrXtagsA7Gf1biOF5wb6hQ9esIC5FlxUjOWS83MnrYt29fQb5+zhLD3as3PXDmA8upo+PrNYadPh1drmeo/1t1tRtJGPlKOkVVUxNYq2h8PFUK4H1ddeeB6Ic1qHlKqIvmw4tmVgqQ6Ls85SxUKPVUHtlR9J2NY3ojC3wVZHOiHke4Hdmb0n0oxjWyaGbtaf5OFraJUvOKjJORxMXo+cdBimmucs8mEW10GZIsvJ6EKd7Hq/AfICekdQU7ImCHp7Ba5+aDbLiUtPKoNYgGPk3V4lqn32aLIZ+j8MKEMM1gzOHRy8foLDGQ80SLEvMKUxxRbsZsvyWut5vDXxmapt+3Bp0tvDxcilhZSKRVhzI87uA3XlxyJA8wGoX1FQFYPp1rmpU/RX7bxE0DOYQwX0znZ1NLFGvRQmrLt6tYfswfbg9f8N880bHuhJTFDqJMfx1gAO7+b+q9zGwHR20CwM2wodpjH9BEPTDsYCRP/k8EPzAmPTAO1N6Oo8bpDk1E19sM6GGca/qsSt3PhHiv2B+5klXBu8p7a2G/dcvETviCFBE6TKJOL8LB2K2jZ/HoCfrshXGAsao0Iin0J3X/tv67p65cIzBF3KAE0XR5gc+N11t3WGLfFHT4mW+cnPoh36fNtJSo37e+b4UyFlG4MpMVgacOccroSwz84vP8VlvPIQp+beZAVN4wUeQAHIg0hThhZcij/NPCL4b6mGeRAFnTmBK5ktXeXfv596rbeJ8V3x+IvtWga8wwShI5AX/2eiFGeMYmqgYZCX50e9USfiKtqSr/lXHSs8tWOWlRKd7GYsNrEHUGMxYOEalIcRpFrVAV1vcBa9u9q1wnWNeUWVyVMrTA3fs8c3CeNv/s2t7Q5lbAXjleUo7zVCUmEII2ZHU2i7R0PXzlLxTSlR+qMkI1TkV96DMKdyPkQlvgVfGcMnK1teMth+OGtGX65To0EfV/95kJBEG/+fLNSOcqPTG0BfEqW87pDuyHP3mmPpoD1RdvDb3Gz5EGYk7kYlWRWNtDa5hI8heH/MY77v3+EOySQ0rPwkJQ9vdetIbFy2ngirrvbQOSNYFlYY4Ogwup/Bx7ARfB5e5FeqH0FI5SL30; _gitlab_session=2e8eaad8b31de7355bcd2ebe1674b825; request_method=GET' https://chipcode.qti.qualcomm.com/dashboard/projects_by_product?product=APQ8026.LW.2.0

then you will get a json format string, all product info there

: )

Android INCLUDE_EXECUTABLE but not install to system image, e.g: recovery

最近工作上有個需求,我們複製了 recovery 修改成我們要的功能之後,發現除了 recovery image 之外, system image 也額外出現了我們修改過後的執行檔

Android 的 build system 裡面有$(INCULDE_EXECUTABLE)是設計用來編譯手機上面的執行檔的

例如 recovery 就是使用 $(INCLUDE_EXECUTABLE)

但是我們並不希望 recovery 被安裝到 /system/bin/ 裡面,如果安裝到 /system/bin/ 裡面的話

就可能被使用者直接 adb shell /system/bin/recovery 執行,雖然不一定會發生問題

但畢竟是不好的設計,我們只希望 recovery 出現在 recoveryimage 裡面,也就是只有進入 recovery mode 之後才載入具有 /system/bin/recovery 的 ramdisk

原本有看到 bootable/recovery/Android.mk 裡面有個 LOCAL_MODULE_TAGS := eng 原本可以設定只有 eng build 才安裝,但這樣也不夠好,最好的情況是不論 eng, userdebug 都不要安裝到 system image

後來我思考 $(INCLUDE_EXECUTABLE) 究竟是如何安裝 binary 到 system image 裡面的,一路找到 build/core/base_rule.mk 裡面

還順便發現了一個參數 $(LOCAL_UNINSTALLABLE_MODULE)

這個參數作用在 $(INCLUDE_XXXX) 要安裝檔案之前,會根據這個參數決定是否要安裝

所以在我們修改過後的 Android.mk 裡面加上 LOCAL_UNINSTALLABLE_MODULE := true 就不會讓執行檔案裝到 system image 裡面去了,但依然可以在 build time 被 build ,也就可以繼續保持打包到某某 image 裡面了