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

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'


Ubuntu(Debian) package 관리

tips & tricks/Linux/Unix 2013. 10. 4. 10:16 by manywaypark

박스 A에 설치된 package들을 박스 B에도 그대로 적용하고 싶을 때:

설치 패키지 정보 복사 및 설치:

# box A:

$ dpkg --get-selections > selections.txt

$ scp selections.txt foo@boxB:/tmp/

# box B:

$ dpkg --set-selections < /tmp/selections.txt

$ sudo aptitude install                       # 설치

$ sudo apt-get -u dselect-upgrade


위와 같이하면 설치는 되지만, 의존성 관련 정보(사용자가 깔았는지, 의존성때문에 자동으로 깔렸는지) 등은 소실된다.

이 정보의 복구는 다음과 같이 한다.

# box A:

$ apt-mark showauto > pkgs_auto.lst

$ apt-mark showmanual > pkgs_manual.lst

# box B:

$ sudo apt-mark auto $(cat pkgs_auto.list)

$ sudo apt-mark manual $(cat pkgs_manual.list)


ref: http://askubuntu.com/questions/101931/restoring-all-data-and-dependencies-from-dpkg-set-selections


happy hackin'

ubuntu-desktop, xubuntu-desktop, kubuntu-desktop 패키지 중에 맘에 드는 것을 하나 설치하면 된다.


아래와 같이 하면, ubuntu-desktop 패키지 설치시에 쓸데 없는 패키지(OpenOffice 등)들을 제외하고 꼭필요한 것만 깐다.

sudo apt-get install --no-install-recommends ubuntu-desktop

ref: http://www.ubuntugeek.com/how-to-install-gui-on-ubuntu-12-04-precise-server.html


2013-10-04: xubuntu-desktop package를 --no-install-recommends 옵션을 주고 설치하면 아이콘등이 제대로 안나와서 모양이 어색하다. xubuntu-icon-theme package를 설치하면 해결된다.

happy hackin'



Ubuntu 한글 입력 설정

tips & tricks/Linux/Unix 2013. 9. 29. 17:28 by manywaypark

보통은 window manager의 상태바 등에 입력기 상태가 표시되어 별 문제가 없지만, 원격 접속등의 경우에는 설정을 바꾸려면 조금 난감한 경우가 있다.

명령행에서 ibus-setup을 실행하면 대화상자가 뜨면서 설정을 바꿀 수 있다.

물론 설치되지 않은 경우에는 ibus-setup, ibus-hangul 등의 package들을 먼저 설치한다.


happy hackin'

byobu

tips & tricks/Linux/Unix 2013. 5. 19. 23:45 by manywaypark

간만에 쓸만한 터미널을 발견했다. byobu는 '뵤부' 정도로 발음되는 것같다.

아래 설명 페이지에는 텍스트 기반의 윈도우 관리자(text based window manager)라고 소개하는데 예전에도 있던 screen을 좀 편리하게 만든 정도인 것같다.

예전에 screen의 설정을 좀 fancy하게 하면 비슷한 화면을 구성할 수도 있었지만, 고질적인 ctrl-a 문제는 항상 짜증이 났었는데...

byobu라는 멋진 놈이 있었구나. 한동안 서버쪽을 조금 멀리했더니 그 사이에 생긴듯. 여튼 아주 맘에 든다.

기본 설정으로도 다양한 서버 정보(배포판, CPU load, uptime, 현재 시간 등등)를 표시해주고, f2- new window, f3- prv window, f4- next window 등등 screen의 key 조합(ctrl-a + ...)보다 좀더 현대적이고 직관적이다. 무엇보다  개인적으로 맘에 든 것은 emacs key binding과 충돌나지 않게 설정가능한 점 (어렴풋한 기억으로 screen도 설정으로 가능하긴 했지만, 기본으로 지원되는 것이 중요하다).


refs:

https://help.ubuntu.com/community/Byobu


2013-10-07:  minimal로 설치했다면 맨 아래의 status line에 ubuntu logo가 깨지는 경우가 있다. ttf-ubuntu-font-family package를 추가로 설치하면 해결된다.

2015-02-23: 한글 입력이 (기본 터미널에서는 잘 됨에도 불구하고) byobu에서만 잘 안되는 경우가 있는데 (현재 ibus-hangul 사용중) ~/.byobu/profile 파일이 sourcing하는 파일(보통 ubuntu는 /usr/share/byobu/profiles/common 파일이다)의 내용 중에 defutf8 on을 주석처리하면 제대로 동작한다.
ref: http://codecat.tistory.com/entry/gnu-screen-byobu-%ED%95%9C%EA%B8%80-%EC%84%A4%EC%A0%95


happy hackin'

[펌] Window Manager 선택

tips & tricks/Linux/Unix 2013. 5. 14. 13:17 by manywaypark

Ubuntu Server 설치 후 Window Manager 선택 가이드: 

http://complete-concrete-concise.com/ubuntu-2/ubuntu-12-04-server/ubuntu-12-04-server-how-to-install-a-gui


happy hackin'

OpenLDAP(slapd)의 설치 및 설정에 관해서 간단히 알아본다.
언제나 그렇듯 Ubuntu (12.04.2 LTS) 기준이다.
Ubutu 10.04부터 OpenLDAP 기본 패키지 설치는 RTC(RunTime Configuration)를 사용한다.
(예전에 내가 알던 그 slapd.conf 방식이 아닌 것이다. 한참 삽질한 후에 알았다. Orz)
ldap-utils에 포함된 도구를 사용해서 그냥 일반적인 레코드 수정하듯이 cn=config의 엔트리를 조작하면 된다. 이름대로 변경하면 반영된다고 한다.

준비:
먼저 테스트 접속을 위해 Apache Directory Studio(이하 ADS)를 다운 받아 설치한다.

설치:

$ sudo apt-get install slapd ldap-utils

설치 과정에서는 admin password만 입력하면 된다.

설정: (dc 등이 제대로 설정되지 않을 때만 필요. hostname 설정이 제대로 되어 있다면 설치 과정에서 dc도 제대로 설정되었을 것이다.)

$ sudo dpkg-reconfigure slapd

주의 깊게 설명을 읽고 답변을 선택하거나 값을 입력한다 (내 경우에는 dc를 입력하는 것 말고는 별달리 할 것이 없다). DB 지우는 것을 물어보는 부분이 조금은 혼란을 일으키지만, Yes로 답하면 된다 (방금 설치했는데 뭘...)

여기서부터 편의 상 dc설정을 "dc=foo,dc=bar"로 가정한다.
확인하려면 대충 이렇게 해보자;

$ sudo ldapsearch -Y EXTERNAL -H ldapi:/// -b cn=config | grep cn=admin


시험:
ADS에서 새로운 연결을 만든다.
왼쪽 아래에 보면 Connections pane이 있고 LDAP+ 아이콘이 있다. 클릭!
Network Parameter 입력:

Connection name: 연결이름 아무거나
Hostname: 호스트의 FQDN 또는 IP 주소
Port: 389 (기본값)
Encryption method: No encryption (기본값)
Provider: Apache Directory LDAP Client API (기본값)

입력후 Check Network Parameter 버튼을 눌러서 확인.
성공했다면 Next로 가서 인증정보를 입력한다.

Authentication 입력:

Authentication Method: Simple Authentication
Bind DN or user: cn=admin,dc=foo,dc=bar
Bind password: [package 설치시 입력했던 password]

입력후 Check Authentication 버튼을 눌러서 확인.

TLS 설정:
참조링크에 자세히 나오는데, 그대로 발췌했다.

Here, we will be our own Certificate Authority and then create and sign our LDAP server certificate as that CA. Since slapd is compiled using the gnutls library, we will use the certtool utility to complete these tasks.

  1. Install the gnutls-bin and ssl-cert packages:

    sudo apt-get install gnutls-bin ssl-cert
    
  2. Create a private key for the Certificate Authority:

    sudo sh -c "certtool --generate-privkey > /etc/ssl/private/cakey.pem"
    
  3. Create the template/file /etc/ssl/ca.info to define the CA:

    cn = Example Company
    ca
    cert_signing_key
    
  4. Create the self-signed CA certificate:

    sudo certtool --generate-self-signed \
    --load-privkey /etc/ssl/private/cakey.pem \ 
    --template /etc/ssl/ca.info \
    --outfile /etc/ssl/certs/cacert.pem
    
  5. Make a private key for the server:

    sudo certtool --generate-privkey \
    --bits 1024 \
    --outfile /etc/ssl/private/ldap01_slapd_key.pem
    

    Replace ldap01 in the filename with your server's hostname. Naming the certificate and key for the host and service that will be using them will help keep things clear.

  6. Create the /etc/ssl/ldap01.info info file containing:

    organization = Example Company
    cn = ldap01.example.com
    tls_www_server
    encryption_key
    signing_key
    expiration_days = 3650
    

    The above certificate is good for 10 years. Adjust accordingly.

  7. Create the server's certificate:

    sudo certtool --generate-certificate \
    --load-privkey /etc/ssl/private/ldap01_slapd_key.pem \
    --load-ca-certificate /etc/ssl/certs/cacert.pem \
    --load-ca-privkey /etc/ssl/private/cakey.pem \
    --template /etc/ssl/ldap01.info \
    --outfile /etc/ssl/certs/ldap01_slapd_cert.pem
    

Create the file certinfo.ldif with the following contents (adjust accordingly, our example assumes we created certs using https://www.cacert.org):

dn: cn=config
add: olcTLSCACertificateFile
olcTLSCACertificateFile: /etc/ssl/certs/cacert.pem
-
add: olcTLSCertificateFile
olcTLSCertificateFile: /etc/ssl/certs/ldap01_slapd_cert.pem
-
add: olcTLSCertificateKeyFile
olcTLSCertificateKeyFile: /etc/ssl/private/ldap01_slapd_key.pem

Use the ldapmodify command to tell slapd about our TLS work via the slapd-config database:

sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f /etc/ssl/certinfo.ldif

Contratry to popular belief, you do not need ldaps:// in /etc/default/slapd in order to use encryption. You should have just:

SLAPD_SERVICES="ldap:/// ldapi:///"

LDAP over TLS/SSL (ldaps://) is deprecated in favour of StartTLS. The latter refers to an existing LDAP session (listening on TCP port 389) becoming protected by TLS/SSL whereas LDAPS, like HTTPS, is a distinct encrypted-from-the-start protocol that operates over TCP port 636.

Tighten up ownership and permissions:

sudo adduser openldap ssl-cert
sudo chgrp ssl-cert /etc/ssl/private/ldap01_slapd_key.pem
sudo chmod g+r /etc/ssl/private/ldap01_slapd_key.pem
sudo chmod o-r /etc/ssl/private/ldap01_slapd_key.pem

Restart OpenLDAP:

sudo service slapd restart

Check your host's logs (/var/log/syslog) to see if the server has started properly.


TLS 시험:
ADS에서 새로운 연결을 하나 만들어서 테스트한다. 연결설정에서 다른 설정들은 모두 이전과 같이 하고 Encryption methodUse StartTLS extension으로 선택한다.
연결시 인증서 관련 경고 비슷한게 나오는데, 사설(self-signed) 인증서라 그런 것이므로 무시하고, trust하는 것으로....

refs:
https://help.ubuntu.com/12.10/serverguide/openldap-server.html

https://help.ubuntu.com/community/OpenLDAPServer

http://www.openldap.org/faq/data/cache/185.html

happy hackin'

1 2 3 4 5 6 
분류 전체보기 (306)
잡담 (20)
함수형 언어 (65)
emacs (16)
java (18)
tips & tricks (154)
Linux/Unix (57)
Win (19)
Qt (11)
Xcode (1)
Mac (8)
사랑 (1)
가사 (0)
독서 (4)
mobile (6)
비함수형 언어 (2)

공지사항

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

03-29 04:16