manywaypark's Blog
개발, 검색, 함수

일단 레드마인 박스에 루트 권한으로 적당한 곳에 소스를 저장할 디렉토리를 만든다.

(현재 내가 알기로 git은 간단히 remote url 입력해서 해결 되지는 않는다)

$ sudo -i

# mkdir /var/src-repos

# mkdir /var/src-repos/[redmine-prj-name]     # 여러 개의 project가 아니라면 이 단계는 생략

# cd $_

# git clone --mirror [url-of-git-repo] [local-dir-name]


이제는 redmine의 프로젝트 설정에서 (Settings > Repositories) +New repository를 선택해서 local directory를 repositiory로 추가한다.

SCM: Git

Identifier: what-ever-you-want

URL: /var/src-repos/[redmine-prj-name]/[local-dir-name]

프로젝트의 repository 에 가보면 추가된 것을 확인 할 수 있다.

여기서 끝이면 좋겠지만, 자동 업데이트 따위가 지원되지 않는다. Orz.


루트로 아래와 같은 파일을 하나 만들어서 crontab에 등록해 적당한 주기로 sync 시키면 해결된다.

#!/bin/bash


REPOS=`ls -d /var/src-repos/*/*`        # 다중 프로젝트 아니면 */* -> *


for repo in $REPOS

do

    cd $repo

    git remote update

done


내 경우 ~/bin/sync-src-repos.sh로 저장했고 crontab -e 하면 다음과 같이 나온다.
......
*/30 * * * * /root/bin/sync-src-repos.sh

......


happy hackin'


일단 npm을 설치하고 나서 bower를 설치한다.

$ sudo apt-get npm

$ sudo npm install -g bower

대충 아래와 같이 하면 다운로드 받아서 설정해주는 건데...

bower install angular#1.2.17

or

bower install angular#1.3.0-beta.11

현재 내 ubuntu box(Linux my-lin 3.13.0-29-generic #53-Ubuntu SMP Wed Jun 4 21:00:20 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux)에서는 npm만 설치해서는 안됐고 nodejs-legacy package도 같이 설치해야 동작했다.

그냥 node라고 치면 아무것도 실행 안되고 node 또는 nodejs-legacy에 있다고 나오는데,

The program 'node' can be found in the following packages:

 * node

 * nodejs-legacy

Try: sudo apt-get install <selected package>

생각 없이 node를 설치했더니 완전히 꼬임. Orz
여튼 nodejs-legacy를 설치하고 하면 잘 됨.

refs:
http://bower.io/
https://github.com/bower/bower/issues/201
 

happy hackin'

mail notification 문제

tips & tricks/Linux/Unix 2014. 5. 19. 17:26 by manywaypark

Jenkins, ReviewBoard 등 개발 지원 도구를 최초 설치하고나서 알림 메일 설정한 후에 메일이 발송되지 않는 경우가 있다.

로그를 보면 대충 다음과 같다.

ReviewBoard의 경우:

root@cr:/var/log/review-board# tail -f reviewboard.log

2014-04-02 05:29:21,272 - ERROR -  - Error sending e-mail notification with subject 'Review Request 25: test' on behalf of '"mr foo" <foo@bar.com>' to '"A team" <a@bar.com>,"mr foo" <foo@bar.com>': [Errno 111] Connection refused

Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.7.11-py2.7.egg/reviewboard/notifications/email.py", line 244, in send_review_mail

    message.send()

  File "/usr/local/lib/python2.7/dist-packages/Django-1.4.5-py2.7.egg/django/core/mail/message.py", line 248, in send

    return self.get_connection(fail_silently).send_messages([self])

  File "/usr/local/lib/python2.7/dist-packages/Django-1.4.5-py2.7.egg/django/core/mail/backends/smtp.py", line 85, in send_messages

    new_conn_created = self.open()

  File "/usr/local/lib/python2.7/dist-packages/Django-1.4.5-py2.7.egg/django/core/mail/backends/smtp.py", line 48, in open

    local_hostname=DNS_NAME.get_fqdn())

  File "/usr/lib/python2.7/smtplib.py", line 249, in __init__

    (code, msg) = self.connect(host, port)

  File "/usr/lib/python2.7/smtplib.py", line 309, in connect

    self.sock = self._get_socket(host, port, self.timeout)

  File "/usr/lib/python2.7/smtplib.py", line 284, in _get_socket

    return socket.create_connection((port, host), timeout)

  File "/usr/lib/python2.7/socket.py", line 571, in create_connection

    raise err

error: [Errno 111] Connection refused


Jenkins의 경우:

......

Sending e-mails to: a@bar.com

ERROR: Could not connect to SMTP host: localhost, port: 25

javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;

  nested exception is:

    java.net.ConnectException: Connection refused

    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934)

    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)

    at javax.mail.Service.connect(Service.java:295)

    at javax.mail.Service.connect(Service.java:176)

    at javax.mail.Service.connect(Service.java:125)

    at javax.mail.Transport.send0(Transport.java:194)

    at javax.mail.Transport.send(Transport.java:124)

    at hudson.tasks.MailSender.execute(MailSender.java:117)

    at hudson.tasks.Mailer.perform(Mailer.java:137)

    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)

    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:804)

    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:776)

    at hudson.model.Build$BuildExecution.post2(Build.java:183)

    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:725)

    at hudson.model.Run.execute(Run.java:1701)

    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)

    at hudson.model.ResourceController.execute(ResourceController.java:88)

    at hudson.model.Executor.run(Executor.java:231)

Caused by: java.net.ConnectException: Connection refused

    at java.net.PlainSocketImpl.socketConnect(Native Method)

    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)

    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)

    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)

    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:385)

    at java.net.Socket.connect(Socket.java:546)

    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:286)

    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:231)

    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1900)

    ... 17 more

Finished: FAILURE


내 경우 fresh install한 ubuntu box에 mailutils package가 깔려있지 않아서 생긴 문제였다.

$ sudo apt-get install mailutils


happy hackin'

lists exported symbols

tips & tricks/Linux/Unix 2014. 5. 19. 16:05 by manywaypark

shared object 파일에서 어떤 symbol들이 export되는지 궁금해지는 경우가 있다.

(특히 unsolved external symbol 따위 linker error가 발생할 경우)

다음과 같이 하면 symbol들을 human-readable한 형태로 뽑아준다.

$ (find . -name '*.a'|xargs nm -f posix; find . -name '*.so' | xargs nm -f posix -D)|cut -f1 -d' '|LANG=C sort -u > all_symbols

$ grep '^_Z' all_symbols | c++filt|sort > demangled_c++_symbols


refs:

http://gcc.gnu.org/wiki/Cxx11AbiCompatibility

http://stackoverflow.com/questions/1237575/how-do-i-find-out-what-all-symbols-are-exported-from-a-shared-object


happy hackin'

framewerk(오타 아님)는 일종의 autotools wrapper이다.

c/c++은 물론이고 javascript와 erlang도 지원하는 점이 맘에든다.

사용법은 참조링크에 쉽고 자세하게 나온다.

간단한 예제를 하나 들자면 erlang project에서 rebar 및 git을 사용할 경우 다음과 같이 한다.

$ fw-init --name myprj --template erlang-rebar --revision git

$ cd myprj

$ ./bootstrap

$ ./configure

$ make

지원되는 버전 관리 도구(revision에서 설정): git, svn, cvs

지원되는 개발 환경(template에서 설정): c, c++, erlang, erlang-rebar, java-mvn


refs: https://code.google.com/p/fwtemplates/


2014-11-11 추가: project configuration(version number 설정 등)은 fw-pkgin/config 파일을 편집한다.


2016-06-07 추가: 원래 프로젝트 페이지는 관리 안된지 좀 오래 인듯. 비교적 최근까지 관리되는 곳은 여기: https://github.com/dukesoferl/fw

또한 빌드 및 사용 법은, ./bootstrap -> ./build (--prefix=/usr/local) -> sudo make install 로 하면 좀더 간편하다.


happy hackin'

분명히 현재 scope에 nUnit이라는 변수가 있음에도 불구하고 아래처럼 symbol을 제대로 찾지 못했다.


......

(gdb) p nUnit

No symbol "nUnit" in current context.

(gdb)


gcc4.8 + gdb7.5에서는 컴파일 옵션에 "-g -gdwarf-2"를 줘야 제대로 동작한다.

즉 debug build는 아래처럼 configure한다.

./configure --prefix=/path/to/prefix CPPFLAGS=-DDEBUG CXXFLAGS="-g -gdwarf-2 -O0"


refs:

http://stackoverflow.com/questions/12595631/debugging-with-gdb-on-a-program-with-no-optimization-but-still-there-is-no-symbo


happy hackin'

erlang + autotools + rebar

tips & tricks/Linux/Unix 2014. 4. 11. 18:18 by manywaypark

항상 멋진 도구를 찾아내고 나면 기쁨 뒤에 후회와 허탈함이 밀려온다.

'좀더 찾아볼걸... Orz'

'이거 해결하려고 쓴 시간이 얼마인가... ㅠㅠ'

여튼 erlang에서 autotools와 rebar등을 묶어줄 뿐만 아니라 .deb package까지도 만들어주는 멋진 놈이 존재하고 있었던 것이다.

(물론 erlang 말고 javascript, c, c++도 지원함)

또한 추가적으로 대부분의 메이저 scm도 지원하며, 빌드번호 등도 관리되는 듯하다. 넘 멋지다.

이젠 잘 쓰는 일만 남았다.


refs: 

http://dukesoferl.blogspot.kr/2008/02/erlang-and-automake.html

https://code.google.com/p/fwtemplates/


happy hackin'


ps. 이런 식으로 쓴다.

$ fw-init --name prj-name --template erlang-rebar --revision git


debug/release mode on linux

tips & tricks/Linux/Unix 2014. 3. 31. 14:32 by manywaypark

autotools 또는 configure 사용시 debug 정보 넣기


$ mkdir debug

$ mkdir release

$ cd debug && /path/to/configure --prefix=/dbg CPPFLAGS=-DDEBUG CXXFLAGS="-g -O0" && make && make install

$ cd ../release && /path/to/configure CPPFLAGS=-DNDEBUG && make && make install

debug에는 debug 정보가 포함된 바이너리가 생기고 release에는 debug 정보가 포함되지 않은 바이너리가 생긴다.

install target directory(prefix)가 다른 것에 주의한다.


box 레벨에서는 다음과 같이 해서 파일을 하나 생성해두면 prefix를 /dbg 로 해서 configure를 실행한 경우 자동으로 debug 정보를 포함하게 된다.

echo 'CPPFLAGS=-DDEBUG CFLAGS="-g -O0"' >> /dbg/share/config.site


ref: http://stackoverflow.com/questions/4553735/gnu-autotools-debug-release-targets


happy hackin'



core file은 어디에??

tips & tricks/Linux/Unix 2014. 3. 21. 18:19 by manywaypark

아래와 같은 어마무시한 메시지가 나왔는데...

Segmentation fault (core dumped)

'코흘리던 시절 많이 보던 거지만, 간만에 보니 새롭다.' 라는 감상에 잠시 빠졌다가...

고쳐야지 하고 봤는데 파일이 없다. Orz.

분명히 core 파일은 CWD(current working directory)에 생성되는데... 잠시 맨붕.

좀 뒤져보니 그동안 많은 변화가 있었던듯...

여튼 /proc/sys/kernel/core_pattern 파일에서 core 관련 처리에 관해서 정의하고 있었고 (bar(|)로 시작하면 리다이렉션 한다든지 하는 제법 향상된 기능을 제공), 내 경우(Ubuntu) 아래와 같이 설정되어 있었고,

|/usr/share/apport/apport %p %s %c

apport라는 놈이 /var/crash에 많은 정보를 포함한 파일을 남기고 있었다.

그 파일들은 apport-unpack이라는 utility로 풀 수 있는데 그 안에 CoreDump 파일이 있었다.


ref: http://stackoverflow.com/questions/2065912/core-dumped-but-core-file-is-not-in-current-directory


happy hackin'


ps. 후일[각주:1]을 위해 간단히 backtrace하는 방법도 남김

(별거 없고 그냥 실행파일과 core 파일을 파라미터로 해서 gdb 실행 시킨후 bt 명령으로 backtrace하면 됨).

gdb /path/to/executable /path/to/CoreDump

GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04

Copyright (C) 2012 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.  Type "show copying"

and "show warranty" for details.

This GDB was configured as "x86_64-linux-gnu".

......

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Core was generated by `/usr/lib/erlang/erts-5.8.5/bin/beam.smp -- -root /usr/lib/erlang -progname erl'.

Program terminated with signal 11, Segmentation fault.

#0  0x00007f3528fb5f28 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)

    () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6

(gdb) bt

#0  0x00007f3528fb5f28 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)

    () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6

......


2018-04-03 추가[각주:2]:

core file 생성되었다는 메시지만 나오고 아무데도 생성되지 않는 경우가 발생했는데...

ulimit -a 해보면 core file size가 0으로 되어있다. 머지 이건?

여튼 ulimit -c unlimited 해준 후에 실행하면 현재 작업 디렉토리에 core 파일이 생성되었다.

ref: https://stackoverflow.com/questions/2065912/core-dumped-but-core-file-is-not-in-current-directory

  1. core 파일은 진짜 몇년만에 처음본다. 그래서 몇년 뒤에 참조할 일이 생길지도... [본문으로]
  2. 진짜 몇년 지나서 또 보게 되었구나. 구글링하다 갑자기 내가 쓴 글이 생각났다. Orz. [본문으로]

Autotools로 library 만들기

tips & tricks/Linux/Unix 2014. 2. 27. 16:56 by manywaypark

아주 잘 정리된, 간략한 페이지가 있구나.

http://www.openismus.com/documents/linux/building_libraries/building_libraries


happy hackin'


1 ··· 4 5 6 7 8 9 10 ··· 16 
분류 전체보기 (306)
잡담 (20)
함수형 언어 (65)
emacs (16)
java (18)
tips & tricks (154)
사랑 (1)
가사 (0)
독서 (4)
mobile (6)
비함수형 언어 (2)

공지사항

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

05-17 14:13