Archives

You are currently viewing archive for 15 November 2007

11/15: Linux > RPM

Category: Linux tips
Posted by: hajime osako
自分で作るRPMパッケージ(1/3)
7.3. 標準で定義されているマクロ
$ rpm --showrc
$ rpm --eval "%{マクロ}"

ちなみに、標準で定義されているマクロは /usr/lib/rpm/macros

一般ユーザーでRPMパッケージをビルドするには
$  mkdir -p ~/rpm/{BUILD,RPMS,SOURCES,SPEC,SRPMS}

~/.rpmmacros
%_topdir                /home/user_name/rpm
%_builddir              %{_topdir}/BUILD
%_rpmdir                %{_topdir}/RPMS
%_sourcedir             %{_topdir}/SOURCES
%_specdir               %{_topdir}/SPECS
%_srcrpmdir             %{_topdir}/SRPMS
ちなみに、rpmbuildをインストールするには、yum install rpm-build

rpmbuild -ba --define 'param_name value' spac_file_name
Category: Study
Posted by: hajime osako
IN() always returns NULL when used to test NULL, even if NULL is included in the list.

IF() and CASE as used in expressions have somewhat different syntax than the IF and CASE statements such can be used within compound statements.

For approximate values, ROUND() uses the rounding method provided in the C library.

 SELECT ROUND(11.5), ROUND(-11.5); <--- returns 12 and -12
 SELECT ROUND(1.15E1), ROUND(-1.15E1); <--- returns 11 and -11

FLOOR() returns the largest integer not greater than its argument.

 SELECT FLOOR(14.7), FLLOR(-14.7); <--- returns 14 and -15

The LENGTH() and CHAR_LENGTH() functions determine string lengths in byte and character units, respectively.

The CONCAT() returns NULL if any of its arguments are NULL, however CONCAT_WS() ignores NULL values.

The STRCMP() function compares two strings and returns -1, 0, or 1.

MySQL encription functions:

 PASSWORD() (one-way)
 ENCODE() and DECODE()
 DES_ENCRYPTY() and DES_DECRYPT()
 AES_ENCRYPT() and AES_DECRYPT()

MAKEDATE() takes two arguments year and day of the year.
MAKETIME() produces a time from hour, minute, and secound arguments.

To determine the current date or time, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, or NOW().

MySQL disallows a double dash (--) without a space as comment.
/*! */ is not a comment in MySQL.

 CREATE TABLE t (i INT) /*! ENGINE = MEMORY */
 SHOW /*!50002 FULL */ TABLES; <-- If MySQL is 5.0.2 or newer.