Thursday, May 11, 2017

[solved] Gitlab upgrade problem 'GitlabCiService'

 ================================================================================
    Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
    ================================================================================
    
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of "bash"  "/tmp/chef-script20170511-11989-rxzicg" ----
    STDOUT: rake aborted!
    StandardError: An error has occurred, this and all later migrations canceled:
    
    The single-table inheritance mechanism failed to locate the subclass: 'GitlabCiService'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Service.inheritance_column to use another column for that information./opt/gitlab/embedded/service/gitlab-rails/db/migrate/20140907220153_serialize_service_properties.rb:26:in `each'
    /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20140907220153_serialize_service_properties.rb:26:in `change'

    /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:50:in `block (3 levels) in <top (required)>'


try
> sudo gitlab-rails dbconsole 
gitlabhq_production=> DELETE FROM services WHERE type = 'GitlabCiService';

after run 
> gitlab-ctl reconfigure

then it should fix the table.




Monday, August 3, 2015

Homomorphic-Simon implementation: Flint library compile error

g++ -I/usr/local/include -I/opt/local/include -O3 -fopenmp -Wall -pedantic -DYASHE -o Simon main.o Simon.o timing.o YASHE/BitVector.o YASHE/Ciphertext.o YASHE/Entropy.o YASHE/Sampler.o YASHE/YASHEKey.o -L/opt/local/lib -lgmp -lgmpxx -lcrypto -lm -lmpfr -lflint
main.o: In function `YASHEParams::~YASHEParams()':
main.cpp:(.text._ZN11YASHEParamsD2Ev[_ZN11YASHEParamsD5Ev]+0x39): undefined reference to `_fmpz_clear_mpz'
main.cpp:(.text._ZN11YASHEParamsD2Ev[_ZN11YASHEParamsD5Ev]+0x51): undefined reference to `_fmpz_clear_mpz'
main.cpp:(.text._ZN11YASHEParamsD2Ev[_ZN11YASHEParamsD5Ev]+0x74): undefined reference to `_fmpz_clear_mpz'
main.o: In function `std::vector<Ciphertext, std::allocator<Ciphertext> >::~vector()':
main.cpp:(.text._ZNSt6vectorI10CiphertextSaIS0_EED2Ev[_ZNSt6vectorI10CiphertextSaIS0_EED5Ev]+0x1d): undefined reference to `fmpz_mod_poly_clear'
main.o: In function `std::vector<std::vector<Ciphertext, std::allocator<Ciphertext> >, std::allocator<std::vector<Ciphertext, std::allocator<Ciphertext> > > >::~vector()':
main.cpp:(.text._ZNSt6vectorIS_I10CiphertextSaIS0_EESaIS2_EED2Ev[_ZNSt6vectorIS_I10CiphertextSaIS0_EESaIS2_EED5Ev]+0x35): undefined reference to `fmpz_mod_poly_clear'
main.o: In function `void std::__uninitialized_fill_n<false>::__uninit_fill_n<std::vector<Ciphertext, std::allocator<Ciphertext> >*, unsigned long, std::vector<Ciphertext, std::allocator<Ciphertext> > >(std::vector<Ciphertext, std::allocator<Ciphertext> >*, unsigned long, std::vector<Ciphertext, std::allocator<Ciphertext> > const&)':
main.cpp:(.text._ZNSt22__uninitialized_fill_nILb0EE15__uninit_fill_nIPSt6vectorI10CiphertextSaIS3_EEmS5_EEvT_T0_RKT1_[_ZNSt22__uninitialized_fill_nILb0EE15__uninit_fill_nIPSt6vectorI10CiphertextSaIS3_EEmS5_EEvT_T0_RKT1_]+0x113): undefined reference to `fmpz_mod_poly_clear'
main.o: In function `main':
main.cpp:(.text.startup+0x6f): undefined reference to `fmpz_set_str'
main.cpp:(.text.startup+0x7c): undefined reference to `fmpz_cmp'
main.cpp:(.text.startup+0x531): undefined reference to `_fmpz_clear_mpz'

main.cpp:(.text.startup+0x5b1): undefined reference to `_fmpz_clear_mpz'
...
...
...

YASHE/YASHEKey.o:YASHEKey.cpp:(.text._ZNSt6vectorIN5flint26fmpz_mod_polyxx_expressionINS0_10operations9immediateENS0_6detail18fmpz_mod_poly_dataEEESaIS6_EE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPS6_S8_EEmRKS6_[_ZNSt6vectorIN5flint26fmpz_mod_polyxx_expressionINS0_10operations9immediateENS0_6detail18fmpz_mod_poly_dataEEESaIS6_EE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPS6_S8_EEmRKS6_]+0x4d4): more undefined references to `fmpz_mod_poly_clear' follow
collect2: error: ld returned 1 exit status


This is caused by the installation of the old flint library. Typically done by apt-get install. 
So get remove the error, you need to run
$> sudo apt-get remove libflint-dev

then soft symlink the flint.h to the /usr/local/include/ by this command
$> sudo ln -s /usr/local/include/flint/flint.h /usr/local/include/flint.h


LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH

then it should work.

Monday, June 29, 2015

NTL library: symbol(s) not found for architecture x86_64


It took me a few days to resolve this problem with the NTL library on Mac OS X.
http://www.shoup.net/ntl/doc/tour-unix.html

So I am going to share the solution with anyone who might run into this problem.

The error:

ph$ clang++ -v -g -O2   -o bv_scheme NTL_examples.o  -lm -lgmp -lntl
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o bv_scheme NTL_examples.o -lm -lgmp -lntl -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "NTL::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, NTL::ZZ const&)", referenced from:
      _main in NTL_examples.o
  "std::istream::get()", referenced from:
      NTL::SkipWhiteSpace(std::istream&) in libntl.a(tools.o)
  "std::istream::peek()", referenced from:
      NTL::SkipWhiteSpace(std::istream&) in libntl.a(tools.o)
  "std::ostream& std::ostream::_M_insert<long>(long)", referenced from:
      NTL::PrintTime(std::ostream&, double) in libntl.a(tools.o)
  "std::ios_base::Init::Init()", referenced from:
      __GLOBAL__sub_I_lip.c in libntl.a(lip.o)
      __GLOBAL__sub_I_tools.c in libntl.a(tools.o)
  "std::ios_base::Init::~Init()", referenced from:
      __GLOBAL__sub_I_lip.c in libntl.a(lip.o)
      __GLOBAL__sub_I_tools.c in libntl.a(tools.o)
  "std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)", referenced from:
      NTL::TerminalError(char const*) in libntl.a(tools.o)
  "std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)", referenced from:
      NTL::TerminalError(char const*) in libntl.a(tools.o)
      NTL::PrintTime(std::ostream&, double) in libntl.a(tools.o)
  "std::cerr", referenced from:
      NTL::TerminalError(char const*) in libntl.a(tools.o)
ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Because Mac OS X now using libc++ rather than libstdc++, so you will need to compile the NTL library with libc++. You have to force it to use the libc++ option. The new compiling steps:

1. ./configure  NTL_GMP_LIP=on
2. open makefile under src/ and change to the following
CXX=clang++
# A C++ compiler, e.g., g++, CC, xlC 
LDLIBS=-lm -lc++
# libraries for linking C++ programs

3. make & sudo make install

Then you should be able to use the NTL library natively in Mac OS X.

Thursday, May 21, 2015

Things about PhoneLab

I am starting this post to document things about PhoneLab (www.phone-lab.org). Hopefully you find it useful.
https://www.phone-lab.org/experiment/start/


Download source

Initialize the repo
repo init -u http://platform.phone-lab.org:8080/platform/manifest -b phonelab/android-4.4.4_r1/develop

actually download the code with
repo sync


Build the source


source build/envsetup.sh
lunch aosp_hammerhead-userdebug
Compile the code with multiple cores.
make -j4



Build the Cruncher tool

source: https://www.phone-lab.org/experiment/data/#cruncher


git clone http://platform.phone-lab.org:8080/p/phonelab/cruncher.git
cd cruncher/crunchersudo



add these packages to the packages.txt
gfortran
libblas-dev
liblas-bin
liblas-c-dev
libatlas-dev
libatlas-base-dev
 
 
xargs -a packages.txt apt-get install
sudo pip install -r requirements.txt

Monday, April 13, 2015

node-red-contrib-bean installation error

> xpc-connection@0.1.3 install /Users/ph/.node-red/node_modules/node-red-contrib-bean/node_modules/ble-bean/node_modules/noble/node_modules/xpc-connection
> node-gyp rebuild

  CXX(target) Release/obj.target/binding/src/XpcConnection.o
cc1plus: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
make: *** [Release/obj.target/binding/src/XpcConnection.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Darwin 14.3.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/ph/.node-red/node_modules/node-red-contrib-bean/node_modules/ble-bean/node_modules/noble/node_modules/xpc-connection
gyp ERR! node -v v0.10.36
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok 
npm WARN optional dep failed, continuing xpc-connection@0.1.3

> noble@0.3.13 install /Users/ph/.node-red/node_modules/node-red-contrib-bean/node_modules/ble-bean/node_modules/noble
> node-gyp rebuild

  LINK(target) Release/hci-ble
  LINK(target) Release/hci-ble: Finished
  LINK(target) Release/l2cap-ble
  LINK(target) Release/l2cap-ble: Finished
node-red-contrib-bean@0.3.2 .node-red/node_modules/node-red-contrib-bean

└── ble-bean@2.1.0 (noble-device@0.1.3, crc@2.1.1, noble@0.3.13)


This is because the use of wrong GCC, as documented in 
https://github.com/sandeepmistry/node-xpc-connection/issues/2

$ which gcc
/usr/bin/gcc
Try setting the path, just before npm install:
export PATH=/usr/bin:$PATH

Tuesday, December 9, 2014

Adafruit kernel module for PWM for RaspberryPi

I was trying to use the Adafruit kernel source to build my customized kernel. But for some reasons, the USB hub was not working after installing the kernel. So I spent sometime to extract the kernel modules from Adafruit from their source tree.

Here is the patch that I generate for official RaspberryPi kernel source tree.


Wednesday, November 12, 2014

RISC-v emulator

Changes are based on https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html For Ubuntu/Debian, in addition to sud...