Showing posts with label GNU/Linux. Show all posts
Showing posts with label GNU/Linux. Show all posts

Sunday, July 5, 2009

GNU/Linux: copy , organize and rename all files in directrory with new mask.

On this page, presented simple how-to for GNU/Linux newbie, that can be used for renaming files, for example photos in one directory.

This script will also work for other GNU/Linux's.
Please, be very accurate, to not lost all your files!

I have a set of folders, and each folder, contain some digital photo's.

the structure is like following:

~/
 Pictures/
    |
    +------- Folder1
               +---- Picture1.jpg
               +---- Picture2.jpg
               +---- Picture3.jpg
    +------- Private <--- be="" br="" excluded.="" folder="" have="" this="" to="">    |
    +------- Folder2 
    |
    +------- Folder3


I want to rename photo's and to put them into separate folder named AllPicts.

I also want to have the new name of file being concatenation (sum) of folder name and just some unique figure. For example Folder1/Picture1.jpg can be copied into AllPhotos/Folder1_1.jpg by this schema.

How to:

1) Start terminal. Alt-F2, xterm.

2) In terminal,
Prepare folders,
 
cd ~/Pictures
mkdir AllPhotos

check if you have enough space
du -sk
df


do renaming and organizing:
a=0 
for i in `find ./ -type d | sed "s/^\.\///" | egrep -v "^$" | egrep -v ^Private$`
do cd $i
echo $i
for j in `ls -1 | egrep -i \.*\.jpg`
do cp $j ~/Pictures/AllPhotos/$i$a.jpg
let a=(a+1) 
done 
cd ~/Pictures/
done 


Please be very patient in using and modifying of script.
to avoid lost data or trashed disk.

It is better to understand and check your man pages for meaning of commands in script.

From the other side, if you understand script, than it is probably
easy for you to modify this script for your needs.

Wednesday, May 13, 2009

Fix network problems after upgrade laptop to Ubuntu 9.04 Jaunty Jackalope

I have upgraded my Ubuntu(32-bit) version up to 9.04 (Jaunty Jackalope) on my HP Compaq 6720s laptop.

After upgrade, I got bluetooth working from the box, however I was not able to detect any network with NetworkManager. NetworkManager displayed absence of network availability, even with wired network working well.

After move to wicd tool for network connection and monitoring, I got wired and wireless networks working, and status of connection also displayed well.

What have I done:


$ sudo apt-get remove network-manager
$ sudo apt-get install wicd

reboot OS;


After reboot I have got new (wicd instead of network manager) icon for displaying network availability, and also ability to connect to wireless netowrk through wicd GUI like it was done before through network manager gui.



Left click on icon will provide you with panel of networks selection.

My laptop network cards, for which it is working:

~$ lspci | grep Netw
00:19.0 Ethernet controller: Intel Corporation 82562GT 10/100 Network Connection (rev 03)
10:00.0 Network controller: Intel Corporation PRO/Wireless 3945ABG [Golan] Network Connection (rev 02)

Saturday, January 24, 2009

SVN: Load dump in

create dump:


$ svnadmin dump OLD_REPO_PATH > dumpfile

restore on another machine:

$ svnadmin create ~/SVN_REPO
$ svnadmin load ~/SVN_REPO/ < dumpfile

make first checkout

$ svn co file:///home/bugmaker/SVN_REPO/ .

Monday, January 19, 2009

Join all avi files in one

join in 1 avi file from all found on card.

put files to join in one folder;

issue:

mencoder -forceidx -ovc copy -oac copy -o out.avi *.AVI


out.avi will be resulting file

Saturday, December 13, 2008

nftw command line version

POSIX C function nftw(p) walks directory tree and reports data on files.

Its just do something like piping of output of following line:

find  | xargs stat

Below is 100+ lines C++ version of previous line.


g++ exnftw.cpp -o nftw
------------%<---------------
#include <ftw.h>
#include <stdio.h>
#include <map>
#include <string>

/* 2008, Author: R.Gritsulyak
* public domain;
* g++ exnftw.cpp -o nftw
* no warranty for this utility.
* patch sendto: roman.gritsulyak@gmail.com
*
* example for:
int nftw(const char *path, int (*fn)(const char *,
const struct stat *, int, struct FTW *), int depth, int flags);
*/

int fnfn(const char *path, const struct stat *ptr,int type, struct FTW *pft)
{
const char *sflag;
switch (type)
{
case FTW_NS:
sflag="FTW_NS: no permission: exit by error;";
break;
case FTW_DNR:
sflag="FTW_DNR: can not read dir; no further reads in;";
break;
case FTW_SLN:
sflag="FTW_SLN: symbolic link on unknown path;";
break;
case FTW_SL:
sflag="FTW_SL: should detect if only FTW_SL set;";
break;
case FTW_DP:
sflag="FTW_DP: directory; we have been in subdirs;";
break;
case FTW_D:
sflag="FTW_D: directory;";
break;
case FTW_F:
sflag="FTW_F: file;";
break;
default:
sflag="unknown:";
}

printf("path=%s\ntype=%s\n",path,sflag);
printf("stat.st_ino=%d\n",ptr->st_ino);
printf("stat.st_mode=%o\n",ptr->st_mode);
printf("stat.st_nlink=%d\n",ptr->st_nlink);
printf("stat.st_uid=0%o\n",ptr->st_dev);
printf("stat.st_gid=0%o\n",ptr->st_gid);
printf("stat.st_rdev=%d\n",ptr->st_rdev);
printf("stat.st_size=%d\n",ptr->st_size);
printf("stat.st_blksize=%u\n",ptr->st_blksize);
printf("stat.st_blocks=%u\n",ptr->st_blocks);
printf("stat.st_atime=%d\n",ptr->st_atime);
printf("stat.st_mtime=%d\n",ptr->st_mtime);
printf("stat.st_ctime=%d\n",ptr->st_ctime);
printf("FTW.base=%d\nFTW.level=%d\n",pft->base,pft->level);
return 0;
}


struct chvali
{
std::string ch;
int vali;
};

const int FLAGS=4;

chvali stra[] = {
{"FTW_CHDIR",FTW_CHDIR},
{"FTW_DEPTH",FTW_DEPTH},
{"FTW_MOUNT",FTW_MOUNT},
{"FTW_PHYS",FTW_PHYS}
};

int usage()
{
fprintf(stderr,"Usage: nftw FLAG1 FLAG2 .. FLAGn depth path\n");
fprintf(stderr,"FLAGx is FTW_CHDIR, FTW_DEPTH, FTW_MOUNT, FTW_PHYS\n");
fprintf(stderr,"depth # number of file descriptors to use\n");
fprintf(stderr,"man p nftw # for further details on args\n");
return 0;
}

int main(int argc, char ** argv)
{
char * inipath;
int i;
int idepth;
int iflags;
int curflag;

std::map<std::string,int> chv;

for(i=0;i<FLAGS;i++)
chv[stra[i].ch]=stra[i].vali;

if (argc < 3)
{
exit(1);
}

iflags = 0;
std::map<std::string,int> iter;

for(i=1; i<argc-2; i++)
{
if( chv.find(argv[i]) != chv.end() )
iflags = iflags | chv[argv[i]];
else
{
fprintf(stderr, "Wrong argument type:%s\n",argv[i]);
usage();
exit(-1);
}
}

inipath = argv[argc-1];
char *dum;
idepth = strtol(argv[argc-2], &dum, 0);

if(nftw(inipath,fnfn,idepth,iflags) != 0)
{
perror("nftw");
exit(2);
}

exit(0);
}



related ftw example

Sunday, December 7, 2008

Long "which" command form

To display not only where is location of which argument,
but also attributes, and if it is symlink, on what binary this symlink points.

example of usage:


rtg@kubic-roman:~$ lwhich mine
error:no such
rtg@kubic-roman:~$ lwhich which
lrwxrwxrwx 1 root root 10 2008-05-01 01:30 /usr/bin/which -> /bin/which
rtg@kubic-roman:~$ lwhich nawk
lrwxrwxrwx 1 root root 22 2007-10-20 04:33 /usr/bin/nawk -> /etc/alternatives/nawk
rtg@kubic-roman:~$ ls -la /etc/alternatives/nawk
lrwxrwxrwx 1 root root 13 2008-05-01 16:49 /etc/alternatives/nawk -> /usr/bin/gawk


To use:
add in your .bashrc :


function lwhich
{
awhich=`which $1`
if [ "a$awhich" != "a" ] # or just if [ $awhich ]
then
ls -l $awhich
else
echo "error:no such"
fi
}


(re)start bash shell.

My Ubuntu installation config variables:

Linux kubic-roman 2.6.24-22-generic #1 SMP Mon Nov 24 18:32:42 UTC 2008 i686 GNU/Linux

generated by APUE2 book chapter 2 program:

opt.txt


_POSIX_ADVISORY_INFO is defined (val is 200112)
sysconf says _POSIX_ADVISORY_INFO = 200112

_POSIX_ASYNCHRONOUS_IO is defined (val is 200112)
sysconf says _POSIX_ASYNCHRONOUS_IO = 200112

_POSIX_BARRIERS is defined (val is 200112)
sysconf says _POSIX_BARRIERS = 200112

_POSIX_CPUTIME is defined (val is 0)
sysconf says _POSIX_CPUTIME = 200112

_POSIX_CLOCK_SELECTION is defined (val is 200112)
sysconf says _POSIX_CLOCK_SELECTION = 200112

_POSIX_FSYNC is defined (val is 200112)
sysconf says _POSIX_FSYNC = 200112

_POSIX_IPV6 is defined (val is 200112)
sysconf says _POSIX_IPV6 = 200112

_POSIX_MAPPED_FILES is defined (val is 200112)
sysconf says _POSIX_MAPPED_FILES = 200112

_POSIX_MEMLOCK is defined (val is 200112)
sysconf says _POSIX_MEMLOCK = 200112

_POSIX_MEMLOCK_RANGE is defined (val is 200112)
sysconf says _POSIX_MEMLOCK_RANGE = 200112

_POSIX_MONOTONIC_CLOCK is defined (val is 0)
sysconf says _POSIX_MONOTONIC_CLOCK = 200112

_POSIX_MEMORY_PROTECTION is defined (val is 200112)
sysconf says _POSIX_MEMORY_PROTECTION = 200112

_POSIX_MESSAGE_PASSING is defined (val is 200112)
sysconf says _POSIX_MESSAGE_PASSING = 200112

_POSIX_PRIORITIZED_IO is defined (val is 200112)
sysconf says _POSIX_PRIORITIZED_IO = 200112

_POSIX_PRIORITIZED_SCHEDULING is undefined
no symbol for _POSIX_PRIORITIZED_SCHEDULING

_POSIX_RAW_SOCKETS is defined (val is 200112)
sysconf says _POSIX_RAW_SOCKETS = 200112

_POSIX_REALTIME_SIGNALS is defined (val is 200112)
sysconf says _POSIX_REALTIME_SIGNALS = 200112

_POSIX_SEMAPHORES is defined (val is 200112)
sysconf says _POSIX_SEMAPHORES = 200112

_POSIX_SHARED_MEMORY_OBJECTS is defined (val is 200112)
sysconf says _POSIX_SHARED_MEMORY_OBJECTS = 200112

_POSIX_SYNCHRONIZED_IO is defined (val is 200112)
sysconf says _POSIX_SYNCHRONIZED_IO = 200112

_POSIX_SPIN_LOCKS is defined (val is 200112)
sysconf says _POSIX_SPIN_LOCKS = 200112

_POSIX_SPAWN is defined (val is 200112)
sysconf says _POSIX_SPAWN = 200112

_POSIX_SPORADIC_SERVER is defined (val is -1)
sysconf says _POSIX_SPORADIC_SERVER = (no limit)

_POSIX_THREAD_CPUTIME is defined (val is 0)
sysconf says _POSIX_THREAD_CPUTIME = 200112

_POSIX_TRACE_EVENT_FILTER is defined (val is -1)
sysconf says _POSIX_TRACE_EVENT_FILTER = (no limit)

_POSIX_TIMEOUTS is defined (val is 200112)
sysconf says _POSIX_TIMEOUTS = 200112

_POSIX_TIMERS is defined (val is 200112)
sysconf says _POSIX_TIMERS = 200112

_POSIX_THREAD_PRIO_INHERIT is defined (val is 200112)
sysconf says _POSIX_THREAD_PRIO_INHERIT = 200112

_POSIX_THREAD_PRIO_PROTECT is defined (val is 200112)
sysconf says _POSIX_THREAD_PRIO_PROTECT = 200112

_POSIX_THREAD_PRIORITY_SCHEDULING is defined (val is 200112)
sysconf says _POSIX_THREAD_PRIORITY_SCHEDULING = 200112

_POSIX_TRACE is defined (val is -1)
sysconf says _POSIX_TRACE = (no limit)

_POSIX_TRACE_INHERIT is defined (val is -1)
sysconf says _POSIX_TRACE_INHERIT = (no limit)

_POSIX_TRACE_LOG is defined (val is -1)
sysconf says _POSIX_TRACE_LOG = (no limit)

_POSIX_THREAD_ATTR_STACKADDR is defined (val is 200112)
sysconf says _POSIX_THREAD_ATTR_STACKADDR = 200112

_POSIX_THREAD_SAFE_FUNCTIONS is defined (val is 200112)
sysconf says _POSIX_THREAD_SAFE_FUNCTIONS = 200112

_POSIX_THREAD_PROCESS_SHARED is defined (val is 200112)
sysconf says _POSIX_THREAD_PROCESS_SHARED = 200112

_POSIX_THREAD_SPORADIC_SERVER is defined (val is -1)
sysconf says _POSIX_THREAD_SPORADIC_SERVER = (no limit)

_POSIX_THREAD_ATTR_STACKSIZE is defined (val is 200112)
sysconf says _POSIX_THREAD_ATTR_STACKSIZE = 200112

_POSIX_THREADS is defined (val is 200112)
sysconf says _POSIX_THREADS = 200112

_POSIX_TYPED_MEMORY_OBJECTS is defined (val is -1)
sysconf says _POSIX_TYPED_MEMORY_OBJECTS = (no limit)

_XOPEN_UNIX is defined (val is 1)
sysconf says _XOPEN_UNIX = 1

_XOPEN_STREAMS is undefined
no symbol for _XOPEN_STREAMS

_XOPEN_CRYPT is defined (val is 1)
sysconf says _XOPEN_CRYPT = 1

_XOPEN_LEGACY is defined (val is 1)
sysconf says _XOPEN_LEGACY = 1

_XOPEN_REALTIME is defined (val is 1)
sysconf says _XOPEN_REALTIME = 1

_XOPEN_REALTIME_THREADS is defined (val is 1)
sysconf says _XOPEN_REALTIME_THREADS = 1

_POSIX_JOB_CONTROL is defined (val is 1)
sysconf says _POSIX_JOB_CONTROL = 1

_POSIX_READER_WRITER_LOCKS is defined (val is 200112)
sysconf says _POSIX_READER_WRITER_LOCKS = 200112

_POSIX_REGEXP is defined (val is 1)
sysconf says _POSIX_REGEXP = 1

_POSIX_SAVED_IDS is defined (val is 1)
sysconf says _POSIX_SAVED_IDS = 1

_POSIX_SHELL is defined (val is 1)
sysconf says _POSIX_SHELL = 1

_XOPEN_ENH_I18N is defined (val is 1)
sysconf says _XOPEN_ENH_I18N = 1

_XOPEN_SHM is defined (val is 1)
sysconf says _XOPEN_SHM = 1

_POSIX_VERSION is defined (val is 200112)
sysconf says _POSIX_VERSION = 200112

_XOPEN_VERSION is defined (val is 600)
sysconf says _XOPEN_VERSION = 600

_POSIX_CHOWN_RESTRICTED is defined (val is 1)
pathconf says _POSIX_CHOWN_RESTRICTED = 1

_POSIX_NO_TRUNC is defined (val is 1)
pathconf says _POSIX_NO_TRUNC = 1

_POSIX_VDISABLE is defined (val is 0)
pathconf says _POSIX_VDISABLE = 0

POSIX_ASYNC_IO is undefined
pathconf says POSIX_ASYNC_IO = (no limit)

POSIX_PRIO_IO is undefined
pathconf says POSIX_PRIO_IO = (no limit)

POSIX_SYNC_IO is undefined
pathconf says POSIX_SYNC_IO = (no limit)
----%<----
ARG_MAX defined to be 131072
ARG_MAX = 131072
no symbol for ATEXIT_MAX
ATEXIT_MAX = 2147483647
CHARCLASS_NAME_MAX defined to be 2048
CHARCLASS_NAME_MAX = 2048
no symbol for CHILD_MAX
CHILD_MAX = 8125
no symbol for CLOCKTICKSPERSECOND /*clock ticks/second*/
CLOCKTICKSPERSECOND /*clock ticks/second*/ = 100
COLL_WEIGHTS_MAX defined to be 255
COLL_WEIGHTS_MAX = 255
HOST_NAME_MAX defined to be 64
HOST_NAME_MAX = 64
IOV_MAX defined to be 1024
IOV_MAX = 1024
LINE_MAX defined to be 2048
LINE_MAX = 2048
LOGIN_NAME_MAX defined to be 256
LOGIN_NAME_MAX = 256
NGROUPS_MAX defined to be 65536
NGROUPS_MAX = 65536
no symbol for OPEN_MAX
OPEN_MAX = 1024
no symbol for PAGESIZE
PAGESIZE = 4096
no symbol for PAGE_SIZE
PAGE_SIZE = 4096
RE_DUP_MAX defined to be 32767
RE_DUP_MAX = 32767
no symbol for STREAM_MAX
STREAM_MAX = 16
no symbol for SYMLOOP_MAX
SYMLOOP_MAX = (no limit)
TTY_NAME_MAX defined to be 32
TTY_NAME_MAX = 32
no symbol for TZNAME_MAX
TZNAME_MAX = 6
MAX_CANON defined to be 255
MAX_CANON = 255
MAX_INPUT defined to be 255
MAX_INPUT = 255
no symbol for FILESIZEBITS
FILESIZEBITS = 64
no symbol for LINK_MAX
LINK_MAX = 32000
NAME_MAX defined to be 255
NAME_MAX = 255
PATH_MAX defined to be 4096
PATH_MAX = 4096
PIPE_BUF defined to be 4096
PIPE_BUF = 4096
no symbol for SYMLINK_MAX
SYMLINK_MAX = (no limit)

Tuesday, December 2, 2008

Different signal handling under FreeBSD and Linux

Signals Delivery and SA_RESTART:

Under 2.6 i386 Linux at home I have got all of this signals.

Under amd64 FreeBSD I have got only some of them.

That way under FreeBSD there are no warranty on signals delivery.


#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <semaphore.h>

const int MAX_CHI=1000;

volatile int chld_count;

sem_t asem;

void handler(int sig)
{
pid_t pid;
sem_wait(&asem);
chld_count ++;
pid = wait(NULL);

printf("Pid %d exited. count: %d\n", pid, chld_count);
sem_post(&asem);
}

int main(void)
{
int i;
chld_count=0;
struct sigaction sa;
sem_init(&asem,0,1);

signal(SIGCHLD, handler);

sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
sa.sa_handler = handler;

sigaction(SIGCHLD, &sa, NULL);

for(i=0;i<MAX_CHI;i++)
{
int ret_val;
ret_val=fork();

if(ret_val==-1)
{
perror("fork()");
}
else if(!ret_val)
{
printf("in child;Child pid is %d\n", getpid());
exit(0);
}
else
{
printf("Parent pid is %d; child is %d;\n",
getpid(),ret_val);
}
}

for(i=0;i<MAX_CHI;i++)
{
int wparam;
wait(&wparam);
}

return 0;
}

Sunday, November 30, 2008

ftw example for systems comparison.

ftw(3) has some inconsistencies.

For example ftw don't call its processing function for symlinks pointed from starting directory to starting directory, or its subdirs.

However, link to parent dir from starting directory reported in further walk.

From the other side, ftw checks and doesn't segfault in looping symlinks.

Checked under Linux 2.6.

source of example:

#include <ftw.h>
#include <stdio.h>
/*
* example for
* int ftw(const char *path, int (*fn)(const char *,
* const struct stat *ptr, int flag, int ndirs);
*/

int ffn(const char *path, const struct stat *ptr, int flag)
{
printf("Found\n path:%s\nflag%d\n", path, flag);
return 0;
}

int main(int argc, char ** argv)
{
char * inipath;
// example:
if (argv[1] && *argv[1])
{
inipath = argv[1];
}
else
{
fprintf(stderr,"usage: exftw PATH\n");
exit(-1);
}

if(ftw(inipath,ffn,20) != 0)
{
perror("ftw");exit(2);
}

return 0;
}

note: on my system it processed homedir with links for one minute.
when i have removed output by printf in ffn function from code, the time was just 1 second;

It looks like it is fast enough in comparison with output.

to check previous statement:


gcc exftw.c -o exftw
ln -s . dirlnsym
./exftw
./exftw | grep dirlnsym
# no reported dirlnsym reported
rm dirlnsym
ln -s ../../ dirlnsym
./exftw | grep dirlnsym
# ok; all reported and no looping

Tuesday, November 25, 2008

Signal delivery failed under FreeBSD.

Some unexpected staff from system well known for stability:
http://www.freebsd.org/cgi/query-pr.cgi?pr=129172

Strange, thу code cited under the link works fine under (Ubuntu 8.04) GNU/Linux.

Sunday, October 19, 2008

simple malloc test for systems comparison

#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
static int *intarr;
static const int iMax = 200000;
static const int iiMax = 500000;
int main()
{
int i;
for(i=0; i<iiMax; i++)
{
intarr = (int *) malloc(sizeof(int)*iMax);
if (errno)
{
perror(sys_errlist[errno]);
break;
}
else
printf("ok\n");
}
char c;
printf("%d",i*iMax);
scanf("%c",&c);
return 0;
}



output of top on centos:


top - 20:53:09 up 2 days, 22:52, 9 users, load average: 2.74, 1.13, 0.77
Tasks: 168 total, 1 running, 167 sleeping, 0 stopped, 0 zombie
Cpu(s): 3.6%us, 1.7%sy, 0.0%ni, 94.2%id, 0.3%wa, 0.2%hi, 0.0%si, 0.0%st

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
28315 rtg 16 0 290g 999m 596 S 0 53.1 0:06.64 my_tst
4296 rtg 15 0 451m 5268 2360 S 0 0.3 0:20.46 nautilus

Saturday, October 4, 2008

eee pc ubuntu psx (playstation emulator)

get and unpack psx
from there:

http://psxemulator.gazaxian.com/


find and install bios (get from your device)

install lib:

sudo apt-get install libgtkglext1


cd pSX
./pSX

eee pc ubuntu zsnes with sound


start it.

# zsnes -ad sdl {romfile}

Monday, September 29, 2008

build autotools project with gcov support

usage:


./configure CFLAGS='-fprofile-arcs -ftest-coverage'
./configure CFLAGS='-fprofile-arcs -ftest-coverage' CXXFLAGS='-fprofile-arcs -ftest-coverage'

cd src
./
gcov
vim
...
-: 25:
1: 26:if (argv[1][0]=='-') {
#####: 27:std::cout << "options not supported yet;" << std::endl;
#####: 28:exit(1);
-: 29:}
-: 30:
...


'#####' lines there indicate dead code in this run;
ciphers indicate number of times this peace of code was run.

Sunday, September 28, 2008

Using autotools HOWTO

Following is autotools buildsystem example/introduction that can be used to create build system that:

- creates libraries
- creates binaries
- creates tests
- executes tests

It is intended for C/C++ project.

Following directory structure used:


project/ +-- reconfig.sh
+-- configure.ac
+-- Makefile.am
+-- src +
tests+
lib/libname/


project/reconfig.sh :


#!/bin/sh
# after editing configure.ac and|or Makefile.am
aclocal
autoheader
autoconf
automake -a
./configure



project/Automake.am :


SUBDIRS = lib/libname src tests

project_pre = 1.0





project/configure.ac :



AC_PREREQ(2.59)

AC_INIT(src/project.h)

AM_INIT_AUTOMAKE(project,1.0)

AC_CONFIG_HEADER([config.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC

# Checks for libraries.
AC_PROG_RANLIB
# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

# Checks for library functions.
AC_HEADER_STDC
AC_CHECK_FUNCS([memset])

AC_OUTPUT([Makefile src/Makefile
lib/libname/Makefile
tests/Makefile])




project/src/Makefile.am



bin_PROGRAMS = project
clones_SOURCES = main.cpp

clones_LDADD = ../lib/libname/libname.a

#clones_LIBADD = ../lib/libname/libname.a

AM_CPPFLAGS = -I$(top_srcdir)/lib/libname/ -I$(top_builddir)/lib/libname/



project/src/libname/Makefile.am:


noinst_LIBRARIES = libname.a
libname_a_SOURCES = libname.c



project/tests/Makefile.am:


bin_PROGRAMS = libname_test test_test
libname_test_SOURCES = libname_test.c
test_test_SOURCES = test_test.c

critbit_test_LDADD = ../lib/libname/libname.a

check_PROGRAMS = libname_test test_test

TESTS = $(check_PROGRAMS)

AM_CPPFLAGS = -I$(top_srcdir)/lib/libname/ -I$(top_builddir)/lib/libname/




To try this example:

- create directory structure;
- create .sh , .in and .ac files described above
- Create .c files with names defined in .am files above in corresponding dirs.


reconfig.sh
should create makefiles that could be used.

make - creates binaries
make check - performs tests

another introduction could be found there:
http://www.gnu.org/software/automake/manual/html_node/Creating-amhello.html#Creating-amhello

Sunday, September 21, 2008

EPEL repository for CentOS 5

To make your x64 CentOS more Desktop-friendly
create file "/etc/yum.repos.d/EPEL.repo"


with contest:

[epel]
name=Epel from fedora
baseurl=http://download.fedora.redhat.com/pub/epel/5/x86_64/
gpgcheck=0


From now it is possible to install such applications,that are not available in original CentOS installation,
as Wine,DosBox, fbreader, gnochm, gnokii, gparted, kdiff3, octave and so on.

Priorities plugin for yum should be enabled for that.

Wednesday, September 17, 2008

MySql basics CentOs 5


# mysql --version
mysql Ver 14.12 Distrib 5.0.45, for redhat-linux-gnu (x86_64) using readline 5.0

# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.soc
k' (2)

to resolve :

# sudo mysql_install_db --user=mysql


Set password:


/usr/bin/mysqladmin -u root password 'new-password'


start engine:


# sudo /usr/bin/mysqld_safe &

Starting mysqld daemon with databases from /var/lib/mysql

# ps -efa| grep mysql
root 20687 4414 0 23:19 pts/2 00:00:00 /bin/sh /usr/bin/mysqld_safe
mysql 20730 20687 0 23:19 pts/2 00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock
rtg 20749 4414 0 23:19 pts/2 00:00:00 grep mysql


change password:


# sudo /usr/bin/mysqladmin -u root password 'NEWpassword'


login and issue some commands:


# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)

mysql> help contents
You asked for help about help category: "Contents"
For more information, type 'help ', where is one of the following
categories:
Account Management
Administration
Data Definition
Data Manipulation
Data Types
Functions
Functions and Modifiers for Use with GROUP BY
Geographic Features
Language Structure
Storage Engines
Stored Routines
Table Maintenance
Transactions
Triggers


Create user:


mysql> CREATE USER rtg identified by 'password'
-> ;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[rtg@rtgCent usr]$ mysql -u rtg -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Friday, August 15, 2008

Minix3 book version under qemu




# prepare for running image from qemu


cd work
bunzip2 minix-3.1.0-book.iso.bz2
sudo mkdir /mnt/minix3
sudo mount -t iso9660 -o loop minix-3.1.0-book.iso /mnt/minix3

mkdir minix
cd minix
qemu-img create minix3.img 2048M

# we are in the work/minix ; iso is in up directory



qemu -boot a -fda /mnt/minix3/bootflop.img -hda "minix3.img" -cdrom ../minix-3.1.0-book.iso -m 64 -localtime


to install with network better proceed with manual:
http://wiki.minix3.org/wikis/minix3/Running_MINIX_3_on_Qemu

Thursday, August 14, 2008

Cygwin pthreads exit causes access violation example

Example of stack overflow in cygwin.

While researched linking and AIX portability, tried example from there:
http://www.ibm.com/developerworks/aix/library/au-gnu.html?S_TACT=105AGX99&S_CMP=CP
(it is erroneous; simple mistakes were fixed):

After exit on cygwin it warns with access violation.

Executable than blocked (for removal).

Sunday, July 27, 2008

ddd installation on centOS



get ddd there:

http://ftp.gnu.org/gnu/ddd/

Through yum, install following package:


RPM Group : Development/Libraries
Source : openmotif-2.3.0-0.5.el5.src.rpm
Yum Group : Development/X Software Development
-> Type : Optional
Build Time : Sun May 25 06:14:11 2008
Install Time : Sun Jul 27 23:56:16 2008
License : Open Group Public License


and it dependencies

then

tar -xf ddd-.tar.gz
cd ddd
./configure
make
sudo make install