Friday, January 28, 2005

rsync and samual taylor coleridge

This is part of the ongoing idea that i need to protect
my day to day work. My excuse for not doing this has
always been hey I only lost a days work. But that is
not really true, or rather some days are more important
that others. It may take me days to work back to that
day. and given the fact that so much of this work
i discribe is off the cuff it may take a month
before i can come back. so its never just a day.

the following comes from the book "the linux cookbook"
page 281 chapter 16.4 "Building an rsync Backup Server"

Problem
you wan users to back up their own data. But you really don't
want to give users shell accounts all over the place, just
so that they can do backups. You'd also like to make it easier
for them to share files, again without give all your users
shell accounts.
Solution
Use a dedicated PC for a central server, and run rsync in daemon mode.
Users will not need login accounts on the server, and you can use rsync's
own access controls and user authorization for security.

rsync must be installed on all machines.

First, on the rsync server, edit or create /etc/rsyncd.conf to create
an rsync module defining the archive:

#global settings
log file = /var/log/rsyncd.log
#modules
[backup_dir1]
path = /backups
comment = server1 archive
list = yes
read only = no

Make sure that /backups exists. Next, start rsync on the server in daemon mode:
# rsync --deamon

Now you can copy files from a remote machine to the server. In this example,
the remote PC is a "workstation" and the rsync server is "server1." First,
verify that the rsync server is accessible:

sue@workstation:~$ rsync server1::

backup_dir1 server1 archive

This command copies Sue's /spreadsheets directory to the module backup_dir1:

sue@workstation:~$ rsync -av spreadsheets server1::backup_dir
building file list.....done
spreadsheets/august03
spreadsheets/sept03
spreadsheets/oct_03
worte 126399 byets read 104 bytes 1522.0 bytes/sec
total size is 130228 speedup is 0.94

Now, view the nice, new uploaded files:

sue@workstation:~$ rsync server1::backup_dir
drwx----- 192 .....
[omitted by me]

Sue can easily retrieve files from server1 to her workstation:

sue@workstation:~$ rsync -av server1::backup_dir1/sept_03 ~/downloads

------

ok that is great but i want to do a relative mindless synchronization

------

some more excerpts from this book:

rsync server1::
Double colons are used when connecting to an rsync server running in
daemon mode. When you connect to an rsync server, you use the module
names, rather than the file paths.

rsync -av
-a means archive mode, This tells rsync to ocpy directories recursivle,
preserve permissions, copy symlinks,, preserve group, preserve owner, and perserve
timestamps. -a is the same as -rlptgoD. -v is vebose.

Chroot versus sudo

i dropped the sudoer idea ... i could never get the privileges for everything
correct. when i built a software it would have the ptxdist user as the creator
of the software. what a pain in neck. also i needed to be able to wipe whole
directores without questions. so i build a mandrake chroot.
i launched vmware build a small X-less mandrake 9.2 install made sure that
that i had the developement tools where installed.
i reworked a chroot script i had floating around and entered
the chroot.
i was missing bison and flex so installed these rpms
and i need mc (midnight commanderd) this needed glib (yuck).
so i download version 4.1.5 of mc and rebuilt and intstalled
it to the chroot, and did the same for subversion 1.0.6.
download the tarball compile and install. i am going to
see if i can just build everything in the chroot. if a
script goes haywire the worst that happens is i loose the chroot,
not my working system.

Saturday, January 22, 2005

DR. SUDOER and how learn to stop worrying and love rm -rf

I wiped my my / directory from a wayward script
rm -rf $(DIRECTORY)/*
the define for DIRECTORY was empty so what i got was
rm -rf /* great! luckly my /home directory was
located on diferent physical partition and
rm choked ... but i lost my subversion repos.

ok i have been lazy i never wanted to move
to using sudo ... but guess what i am moving
now.
here is my sudo file:

# User privilege specification
root ALL=(ALL) ALL
ptxdist ALL=(root) NOPASSWD:/usr/bin/patch,NOPASSWD:/bin/rpm,NOPASSWD:/bin/mount
,NOPASSWD:/bin/cp,NOPASSWD:/bin/umount,NOPASSWD:/usr/bin/install,NOPASSWD:/bin/r
m,NOPASSWD:/bin/mv,NOPASSWD:/bin/tar,NOPASSWD:/bin/cpio,NOPASSWD:/bin/chown,NOPA
SSWD:/bin/mkdir,NOPASSWD:/usr/bin/strip,NOPASSWD:/bin/mknod

and i have started replacing the above commands in $ defines in the
makefiles.

Friday, January 21, 2005

emacs file with props to johnjglynn and dotemacs.de

http://www.dotemacs.de/dotfiles/JohnJGlynn.emacs.html
http://www.math.umn.edu/~aoleg/emacs/shortcuts.shtml

;; .emacs
;;
;; John Glynn

;; General Emacs Options
;; =====================
;;
(setq truncate-partial-width-windows nil)
(setq indent-tabs-mode nil)
(setq enable-recursive-minibuffers t)
(setq line-number-mode t)
(setq column-number-mode t)
(setq find-file-visit-truename t)
(setq search-highlight t)
(setq query-replace-highlight t)
(auto-compression-mode 1)
(auto-show-mode 1)
(setq auto-save-list-file-name nil)
(setq cast-fold-search t)
(require 'paren)
(setq byte-compile-verbose t)
(server-start)

(load-library "pc-select") ; a package which enables text selection ...


(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(auto-compression-mode t nil (jka-compr))
'(case-fold-search t)
'(current-language-environment "English")
'(default-input-method "latin-1-prefix")
'(global-font-lock-mode t nil (font-lock))
'(indent-tabs-mode nil)
'(save-place t nil (saveplace))
'(show-paren-mode t nil (paren))
'(uniquify-buffer-name-style (quote forward) nil (uniquify)))

;; Fonts
;; ============
;;
(setq font-lock-maximum-decoration t)
(add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock)
(add-hook 'cc-mode-hook 'turn-on-font-lock)
(add-hook 'c-mode-hook 'turn-on-font-lock)
(add-hook 'c++-mode-hook 'turn-on-font-lock)
(add-hook 'java-mode-hook 'turn-on-font-lock)
(add-hook 'sh-mode-hook 'turn-on-font-lock)
(add-hook 'shell-script-mode-hook 'turn-on-font-lock)
(add-hook 'makefile-mode-hook 'turn-on-font-lock)
(add-hook 'perl-mode-hook 'turn-on-font-lock)
(add-hook 'xrdb-mode-hook 'turn-on-font-lock)
(add-hook 'ps-mode-hook '(lambda ()
(make-local-variable 'font-lock-support-mode)
(make-local-variable 'lazy-lock-defer-on-scrolling)
(setq font-lock-support-mode 'lazy-lock-mode
lazy-lock-defer-on-scrolling t)
(turn-on-font-lock)))
(add-hook 'ps-run-mode-hook '(lambda () (turn-on-font-lock)))

;; Printing Options
;; ================
;;
(setq lpr-command "lpr")
(require 'ps-print)
(setq ps-print-color-p nil)
(setq ps-bold-faces '(
font-lock-keyword-face font-lock-function-name-face))
(setq ps-italic-faces '(
font-lock-comment-face font-lock-string-face))

; Syntax coloring
(setq font-lock-maximum-decoration t)
(global-font-lock-mode t)

; Show selections
(transient-mark-mode 1)
; Colors
(set-face-foreground 'region "white")
(set-face-background 'region "blue")

(set-face-foreground 'modeline "black") ; status bar
(set-face-background 'modeline "grey")

(set-background-color "black")
(set-foreground-color "green")

(set-face-foreground 'highlight "DarkGreen") ; hyperlink
(set-face-background 'highlight "white") ; hyperlink

(set-face-foreground 'font-lock-comment-face "DarkGreen")
(set-face-foreground 'font-lock-variable-name-face "Brown");dimgray
(set-face-foreground 'font-lock-string-face "DarkOrchid")
(set-face-foreground 'font-lock-keyword-face "blue")
(set-face-foreground 'font-lock-function-name-face "Navy")
(set-face-foreground 'font-lock-type-face "Red")

(custom-set-faces)

;; Text Options
;; ============

(setq-default fill-column 70)
(setq-default fill-prefix " ")

;; Time & Date Options
;; ===================

(setq supress-day-of-week nil)
(setq display-time-day-and-date t)

;; Mode Options
;; ============

(autoload 'c++-mode "cc-mode" "C++ Editing Mode" t)
(autoload 'c-mode "cc-mode" "C Editing Mode" t)
(autoload 'objc-mode "cc-mode" "Objective C Editing Mode" t)
(autoload 'text-mode "indented-text-mode" "Indented Text Editing Mode" t)
(autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t)
(autoload 'ps-mode "ps-mode" "Major mode for editing PostScript" t)
(setq auto-mode-alist
(append '(("\\.C$" . c++-mode)
("\\.cc$" . c++-mode)
("\\.c$" . c-mode)
("\\.h$" . c++-mode)
("\\.i$" . c++-mode)
("\\.ii$" . c++-mode)
("\\.m$" . objc-mode)
("\\.pl$" . perl-mode)
("\\.sql$" . c-mode)
("\\.sh$" . shell-script-mode)
("\\.mak$" . makefile-mode)
("\\.GNU$" . makefile-mode)
("makefile$" . makefile-mode)
("Imakefile$" . makefile-mode)
("\\.Xdefaults$" . xrdb-mode)
("\\.Xenvironment$" . xrdb-mode)
("\\.Xresources$" . xrdb-mode)
("*.\\.ad$" . xrdb-mode)
("\\.[eE]?[pP][sS]$" . ps-mode)
) auto-mode-alist))

(setq default-tab-width 3)
(setq initial-major-mode 'text-mode)
(setq default-major-mode 'text-mode)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(global-unset-key "\M-[")
(global-unset-key "\M-O")
(setq default-auto-fill-hook 'do-auto-fill)
(add-hook 'c-mode-common-hook
'(lambda () (c-toggle-auto-hungry-state 1)))
(add-hook 'c-mode-common-hook '(lambda () (c-set-style "Ellemtel")))

;; Remote Login Options
;; ====================

(setq rlogin-password-paranoia t)
(setq rlogin-process-connection-type t)


;; Command Interpreter Options
;; ===========================
;;
(setq comint-input-ignoredups t)
(setq comint-scroll-show-maximum-output t)
(add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt)

;; Ediff Options
;; =============
;;
(setq ediff-window-setup-function 'ediff-setup-windows-plain)

;; Dired Options
;; =============
;;
(add-hook 'dired-load-hook
(function (lambda ()
(load "dired-x")
(define-key dired-mode-map "a" 'dired-mark-extension)
(define-key dired-mode-map "b" 'dired-flag-extension)
(define-key dired-mode-map "E" 'dired-unmark-all-files-no-query)
(define-key dired-mode-map "\M-!" 'background)
(setq dired-listing-switches "-alF"
dired-ls-F-marks-symlinks t
dired-bind-vm t
dired-dwim-target t
dired-guess-shell-gnutar "gnutar"
dired-guess-shell-alist-user '(("\\.tgz$" "gnutar zxvf"))
)
)))

(setq dired-enable-local-variables nil)
(setq dired-local-variables-file nil)

;; Full ISO Latin-1 Character Set
;; ==============================

(standard-display-european 1)
(load "iso-insert")

;; Move date and time to frame-status line
;; =======================================

(display-time)
(setq global-mode-string '("" vip-mode string))
(setq frame-title-format
'(multiple-frames
"%b" ("" invocation-name "@" system-name " :: " display-time-string)))

(if (not (fboundp 'display-time)) (load "time"))

;; Key Bindings
;; ============

(define-key global-map "\C-h" 'delete-backward-char)
(define-key global-map "\C-[[H" 'beginning-of-line)
(define-key global-map "\M-[K" 'end-of-line)
(define-key global-map "\M-OL" 'backward-word)
(define-key global-map "\M-OR" 'forward-word)
(define-key global-map "\M-On" 'overwrite-mode)
(define-key global-map "\M-Op" 'delete-char)
(define-key global-map "\M-OA" 'previous-line)
(define-key global-map "\M-OB" 'next-line)
(define-key global-map "\M-OD" 'backward-char)
(define-key global-map "\M-OC" 'forward-char)
(define-key global-map "\M-O1" 'scroll-down)
(define-key global-map "\M-O2" 'scroll-up)
(define-key global-map "\M-O3" 'beginning-of-buffer)
(define-key global-map "\M-O4" 'end-of-buffer)
(define-key global-map "\M-OP" 'describe-bindings)

(global-set-key [kp-f1] 'kill-compilation)
(global-set-key [S-f9] 'kill-compilation)
(global-set-key [C-f9] 'remote-compile)
(global-set-key [S-f12] 'mail)
(global-set-key [S-f10] 'ps-print-buffer-with-faces)
(global-set-key [f2] 'man)
(global-set-key [f3] 'ispell-buffer)
(global-set-key [f4] 'imenu)
(global-set-key [f5] 'copy-file)
(global-set-key [f6] 'delete-file)
(global-set-key [f7] 'rename-file)
(global-set-key [f8] 'tags-search)
(global-set-key [f9] 'compile)
(global-set-key [f11] 'calander)
(global-set-key [f12] 'vm)
(global-set-key "\C-x\C-b" 'electric-buffer-list)
(global-set-key [pause] '[?\C-x ?\C-f ?/ ?t ?m ?p ?/ ?s ?t ?e ?p ?h return])

(defalias 'switch-to-next-buffer 'bury-buffer)
(defun switch-to-previous-buffer ()
"Switches to previous buffer"
(interactive)
(switch-to-buffer (nth (- (length (buffer-list)) 1) (buffer-list)))
)

(global-set-key [C-tab] 'switch-to-previous-buffer)
(global-set-key [-backtab] 'switch-to-next-buffer)

;; Desktop
;; =======

(load "desktop")
(desktop-load-default)
(desktop-read)

;; Man Page Options
;; ================

(setq Man-notify 'bully
Man-overstrike-face 'blue-bold
Man-underline-face 'red-bold
Man-see-also-regexp "SEE ALSO\\|RELATED INFORMATION")

;; FTP Options
;; ===========

(setq ange-ftp-generate-anonymous-password t
ange-ftp-retry-time 60
ange-ftp-smart-gateway t
ange-ftp-binary-file-name-regexp ".")

;; Makefile Options
;; ================

(setq makefile-electric-keys t)

;; Compilation Options
;; ===================

(setq compile-command "make -k")
(setq compilation-window-height 20)
(defadvice compile-internal (after my-scroll act comp)
"Forces compile buffer to scroll "
(let* ((ob (current-buffer))
(obw (get-buffer-window ob t))
win
)
(save-excursion
(if (or (null (setq win (get-buffer-window ad-return-value t)))
(null obw))
nil
(select-window win)
(goto-char (point-max))
(select-window obw)
))))

important lessons

dont do development as the root directory
if any script goes haywire you're screwed ...
and i got screwed. i did lost the subversion
directory but i was lucky and didnt loose
the home directory. so it goes.

Sunday, January 16, 2005

tar exclud tricks

these came from the web page
this is bomb:
tar --exclude proc --exclude mnt1 -cvf - . | gzip -9 > /mnt1/bu.tar.gz

Saturday, January 15, 2005

tinylogin and inittab

I want to push the lived cd to something more robust.
what stands in the way are existence of scripts /etc
directory.

i found the following:
------------------------------------------------------------------------------------
# /etc/inittab: init(8) configuration.

# $Id: inittab,v 1.6 1997/01/30 15:03:55 miquels Exp $

# Modified for LEM 2/99 by Sebastien HUET



# default rl.

id:2:initdefault:

# first except in emergency (-b) mode.

si::sysinit:/etc/init.d/rcS

# single-user mode.

~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change

# 0:halt 1:single-user 2-5:multi-user (5 may be X with xdm or other) 6:reboot.

l0:0:wait:/etc/init.d/rc 0

l1:1:wait:/etc/init.d/rc 1

l2:2:wait:/etc/init.d/rc 2

l3:3:wait:/etc/init.d/rc 3

l4:4:wait:/etc/init.d/rc 4

l5:5:wait:/etc/init.d/rc 5

l6:6:wait:/etc/init.d/rc 6

# CTRL-ALT-DEL pressed.

ca:12345:ctrlaltdel:/sbin/shutdown -t1 -r now

# Action on special keypress (ALT-UpArrow).

# Action on special keypress (ALT-UpArrow).

kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work."

# /sbin/mingetty invocations for runlevels.

1:2345:respawn:/sbin/getty 9600 tty1

2:23:respawn:/sbin/getty 9600 tty2

#3:23:respawn:/sbin/getty tty3 #you may add console there

#4:23:respawn:/sbin/getty tty4

-----------------------------------------------------------------------------------

I found something called minidoochun linux while looking
for anything on tinylogin.

Tuesday, January 11, 2005

Using VNC to connect to a CS host

the following came from the page: http://www.cs.utexas.edu/users/UTCS/vnc/

About VNC
VNC (Virtual Network Computing) is a system that allows you to view and control the desktop environment of another computer remotely. It operates independently of the operating system, meaning the server and client do not need to be of the same architecture (that is, you can control a MS-Windows machine from a Unix machine, and vice versa). This web page describes how to access a CS X-window environment from a remote Windows or Unix machine with a VNC client or java-enabled web browser installed. The computers available for use in the seminar rooms in ACES are such machines.

For more information on VNC visit the VNC website.
Starting a VNC server

1. The first step is to connect to a CS host; for this example we'll use ahab.cs.utexas.edu, a public Sun Ultra 10. You may need to visit the available sessions page to quickly find a machine with an available vnc server slot.
2. On the machine which you are physically logged into, use an ssh client to connect to the cs host. An ssh client is installed on the ACES seminar room machines, it can be started via Start Menu->Programs->Secure Shell Client, and then choosing the menu "Window"->New Terminal.
3. Once connected to the CS machine, you may want to configure your vnc session. It will run the window manager twm by default, which is probably not the same thing you have configured for your normal X window setup (ie when you run startx). To choose a different window manager such as fvwm or kde, edit the ~/.vnc/xstartup file to contain the things you'd like to run in your x-session, minimally something like
fvwm
or
startkde
The xstartup file has the exact function of your ~/.xinitrc file, so just copying that over to ~/.vnc/xstartup may server to duplicate your regular session. Like .xinitrc, the xstartup file must be executable (chmod u+x ~/.vnc/xstartup) or its contents will not be run.
4. Once connected to the CS machine, type the command vncserver . The CS copy of the vncserver command is modified to only allow 2 sessions per host to be run. Please do not attempt to circumvent these measures. Creating more than 2 vncserver sessions on a machine tends to degrade machine performance for everyone.
5. If this is the first time you have run vncserver it will ask for a password. Enter a password, and then type the command again to proceed to the next step. If you have run vncserver before just proceed to the next step.
Note: The password you set is stored in your home directory in .vnc/passwd. Remove this file if you wish to change the password.
6. At this step you'll be told the display the vncserver was started up on, for example:
New 'X' desktop is ahab.cs.utexas.edu:1
Make note of the display number for the next stage.

* One final note about VNC server: to stop the server when you are finished using it type the command vncserver -kill :1. Make sure to use the same display number the server was initailly assigned.
Please be sure to log in to the CS host and kill the server with this command!
Failure to do so will leave it running forever, which prevents someone else from using that vnc display, which is a fairly scarce resource.

Using VNC viewer

1. Find and run the program called "vncviewer.exe" on the Windows machine. (or, 'vncviewer' on a unix machine.) you may need to download this software (for any OS) from the vnc website if it is not already installed on your machine. On the ACES seminar room machines, it can be found as Start Menu->Programs->Run VNC Viewer.
2. Enter the host and display of the server you started as follows:
picture of vnc connection dialog box
3. Enter the password you previously chose.
4. A window should now open allowing you to access the X11 session which you previously started (with 'vncserver' above) on the unix host.

* Alternatively, you can connect to your vnc session with most java-enabled web browsers. Just visit http://vncserverhostname.cs.utexas.edu:580X.


The value of X in the above example will vary with the display name (match it precisely).
Questions?
The Windows machines in the ACES seminar rooms are not maintained by the CS staff. Questions concerning them should be directed to ACES tech support.
Questions concerning the operation of the VNC server or vncviewer on the CS machines should be directed to gripe@cs.
This document was last modified on Tuesday, 30-Mar-2004 07:40:32 CST.

the above was copied from the link http://www.cs.utexas.edu/users/UTCS/vnc/
(No plagarism)

Monday, January 10, 2005

Ptxdist build/Makefile system

PTXDIST Build system use a backbone of targets.

The main makefile in the root directory contains the following

PACKAGES=
export TAR TOPDIR STATEDIR PACKAGES


PACKAGES variable is now "blank" and will be added to dependant
on the values found in Config.in.

For example the following config in the Config.in file
.....
config ZLIB:
bool "zlib"
.....
Results in option:

[ ] zlib

when you call make menuconfig.

which creates the define PTXCONF_ZLIB

ifeq (y, $(PTXCONF_ZLIB))
PACKAGES += zlib
endif

and tada the whole makefile is turned "on" or "off".



makefile.make

Sunday, January 09, 2005

Autoconf and Makefile variables

Throught the project autoconf is used and here is a brief explanation of some of the autoconf macros.
(cd $(SOME_DIR2); rm -rf config.cache; $(TARGET_CONFIGURE_OPTS) CFLAGS="$(TARGET_CFLAGS)" CPPFLAGS="$(SED_CFLAGS)" ./configure --target=$(GNU_TARGET_NAME) --host=$(GNU_TARGET_NAME) --build=$(GNU_HOST_NAME) --prefix=/usr );
The macros are defined in the file Virutual.mk and are the following
ARCH:=i386
OPTIMIZE_FOR_CPU=$(ARCH)
GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
GNU_HOST_NAME:=$(HOST_ARCH)-pc-linux-gnu

the following triplet will be defined throughout the buid process:

--target=$(GNU_TARGET_NAME)
--host=$(GNU_TARGET_NAME)
--build=$(GNU_HOST_NAME)

and are infact called a configuration triplet and are as follows cpu-manufacturer-operating_system.


uclibc cross compiler

First I cheated. I used the gcc cross compiler that came from the uclibc
libc project. Why? It seems to be very stable, I seemed to work on mandrake 9.2
and 10.x and gentoo, and probably debian woody. I started out using ptxdist 0.4.0 to build a small system but ptxdist 0.4.0 didnt work on mandrake 9.2. (Mandrake 9.2 runs the wireless card i have as well as vmware).

The uclibc compiler uses a Canadian Cross [1] and this is abbreviated set of steps are:

1. Setup the Kernel headers and locate in the correct dir.
2. Build Binutils.
3. Build Bootstrap GCC with no headers and c only.
4. Build GLibc/uClibc
5. Build GCC with full support for c,c++ and headers and uClibc.

the files used in the build system are:
binutils-uclibc.mk
elf2flt.mk
kernel-headers.mk
sed.mk
ccache.mk
gcc-uclibc-3.3.mk
libfloat.mk
uclibc.mk

These all came from the uclibc project's gcc.3.3.x tarball
but have been modified to be used inside a modified ptxdist project.

The original uclibc toolchain project [5] contained a toplevel Makefile, this was moved into the file Virtual.make.

The trick that gets Virtual.make to work is to include all the .mk files
and define a backbone of target dependencies. This is done with the statment:
TARGETS+=host-sed kernel-headers uclibc-configured binutils gcc3_3 ccache
Later the statement

.PHONY: world $(TARGETS)
says please build all these targets which are defined in the included makefiles.


1. The file binutils-uclibc.mk will build the the binary utilies (strip ar) these are necessary to build the compiler.

2. The file kernel-headers.mk while build the kernle headers. The kernel header describe the type of system you have: i386 versus ARM verus MIPS and sizes of basic types.

3. The file gcc-uclibc-3.3.mk Is used to build the bootstrap compiler and later the full compiler. A bootstrap compiler is a static compiler with only c languague support. The bootstrap compiler also depends on the uclibc.mk make file or rather the ublic system to be unpacked and configured. The second pass compiler depends on static build compiler and the build uclibc.
see the line:
gcc3_3_target: uclibc_target binutils_target $(TARGET_DIR)/usr/bin/gcc

4. file elf2flt.mk is only compile for mmuless systems with is not i386 system and doesnt apply to us.

5. File sed.mk is used to make sed for target systems.

http://kegel.com/crosstool/crosstool-0.28-rc37/doc/crosstool-howto.html
[2] http://efault.net/npat/docs_and_postings/cross-toolchain-build/cross-toolchain-build.txt
[3] http://sources.redhat.com/autobook/autobook/autobook_17.html
[4] http://www.airs.com/ian/configure/
[5] http://www.uclibc.org/cgi-bin/cvsweb/toolchain/gcc-3.3.x

Saturday, January 08, 2005

Building util-linux

I have decided to build the standard getty and login not to use tinylogin.
but building this thing is proving to be a pain.
i ramdom picked version 12p but its a no go. I went over to
buildroot and tried to see how the build it, the build
fails for util linux ... mostly problems find the ncurses
headers and libraries it looks like.

probably what i should be thinking about is how getty works?

this comes from http://www.geekcomix.com/cgi-bin/classnotes/wiki.pl?UNIX01/Init-Getty-Login-Shell

GETTY
Recall that

"TTY" comes from the industry-wide abbreviation for "Teletype" since original Unix computers used these devices for input and output.

A TTY today is simply some sort of I/O device for interfacing with your UNIX box (this is a bit of an over-exaggeration... but for the purposes of this class, it's okay).

GETTY is a program that is invoked by init. It is the second process in series that ultimately connects a user with the UNIX system. Usually getty outputs the contents of /etc/issue (which can contain introductory messages about the system) and then starts login sessions for the user to connect. These login sessions will then spawn the shell whenever a user connects. This procedure is generally refered to as init-getty-login-shell and has been a common mantra throughout UNIX history. If there is ever a problem connecting to a UNIX system as a user, then one of these four elements is to blame.

getty is spawned by init based upon entries inside the /etc/inittab file (which is to be expected). When it is invoked, it is generally given a baud rate (connection speed) and a device name to use (one of /dev/tty1, /dev/tty2, etc.). For example, the following is a possible entry from /etc/inittab

# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
# :::
1:12345:respawn:/sbin/getty 38400 tty1
2:2345:respawn:/sbin/getty 38400 tty2
3:2345:respawn:/sbin/getty 38400 tty3
4:2345:respawn:/sbin/getty 38400 tty4
5:2345:respawn:/sbin/getty 38400 tty5
6:2345:respawn:/sbin/getty 38400 tty6

Note that here, the first field of inittab, the "id", must be the same as the device specification. Or "1" must correlate to "tty1" and so on. Also note that the first invocation (id "1") runs at all non-halt/reboot modes including "single user", whereas the others do not. This is because, when booting into single user mode for maintenance, you will need one and only one terminal.

mingetty
mingetty is an alternative to getty which is most often employed on Red Hat and Red Hat-based systems. It's only real difference is that it is not suitable for other, more arbitrary, terminal connections (such as serial line connections.) It's format inside of inittab is not much different than getty. It simply lacks the baud rate:

# Run gettys in standard runlevels
1:12345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

so i could use mingetty? i may if util linux proves to to much of a pain to build.
but how does mingetty and login work/interact?

more about that from this page
http://www.comptechdoc.org/os/linux/startupman/linux_suiglog.html

Recall that in /etc/inittab file there were lines like this:

1:2345:respawn:/sbin/mingetty tty1

These lines cause init to spawn the mingetty process on runlevels 2 through 5 for tty1 and other terminals. To do this init will use the "fork" function to make a new copy of itself and use an "exec" function to run the getty program. Getty will wait for the user, then read the username. Then init will use the "exec" function to run the login program which will read the password (Some documentation says getty invokes login with the user's name as an argument). If the password entered does not match for the user, init will load and run getty again. If the login is successful, init will use the "exec" function to run the shell program. When the shell exits through the "logout" command, init will load and run the getty program again. The shell is loaded by init or login and the file "/etc/passwd" determines the shell to be used for the user.

Note that network logins are handled differently than console logins since it is impractical to have a getty provided for each potential network login. Network logins are handled through the internet super daemon, inetd using either the telnet or rlogin communication protocol.
Getty

Getty performs the following functions:

1. Open tty lines and set their modes
2. Print the login prompt and get the user's name
3. Begin a login process for the user



1. At startup, it parses its command line, then reads it's default file, usually "/etc/conf.getty" to determine runtime values. After setting up the "line", getty outputs the contents of the "/etc/issue" file. Then getty reads the user's name and invokes login with the user's name as an argument. While reading the user's name, getty attempts to adapt the system to the speed of the terminal being used, and also sets certain terminal parameters to conform with the user's login procedure. See the termio man page.
2. The tty device used by getty is determined by the argument on the command line. The speed argument is a label to an entry in the "/etc/gettydefs" file. this entry defines the initial speed and tty settings, the login prompt to be used, the final speed and tty settings and a pointer to another entry to try if the user indicates that the speed is not correct. This is done by sending a break character.
3. Getty scans the gettydefs file looking for a matching entry to the speed. The first entry is used if no speed was given or no match was found.
4. The type argument names the type of terminal attached to the line such as 3101. The type should be a valid name listed in the termcap database. Getty uses this value to determine how to clear the video display and sets the environment variable "TERM" to the contents of this value.
5. The lined argument describes the line discipline to use on the line. The default is "LDISC0".

During its startup, getty looks for the file "/etc/conf.getty.line" or "/etc/conf.getty". It reads the contents for lines with the form "NAME=value".
SYSTEM
VERSION
LOGIN
INIT=string
ISSUE=string
Login

The login program will prompt for the user name if no argument is given on the command line.

If the file "/etc/nologin" exists and the user is not root, the contents of the "/etc/nologin" file are printed to the screen and the login is terminated. If special access restrictions are specified for the user logging in in the file "etc/usertty", the restrictions must be met or the log in will be denied and the program syslog will log the attempt. If the user is root the login must be on a terminal listed in the file "etc/securetty".

If the above conditions are met the user password will be requested and then it will be checked (If a password is required for this username). After three unsuccessful attempts to login the response gets very slow, and after 10 attempts, login dies. As usual all login failures will be reported by the syslog facility. If the file ".hushlogin" exists in the user's home directory then a "quiet" login is performed which disables checking of mail and the printing of the last login time and the message of the day. Otherwise if the file "var/log/lastlog" exists the last login time is printed and then the current login is recorded in this file. Is the current login recorded in this file if it does not already exist or if the file ".hushlogin" exists.

At this point the login program will perform standard administrative tasks. These include:

1. setting the UID and GID of the tty
2. Preserving the TERM environment variable if it exists.
3. Preserving other environment variables if the –p option is used
4. The HOME, PATH, SHELL, TERM, MAIL, and LOGNAME environment variables are set.
5. The default path is set to "/usr/local/bin:/bin:/usr/bin:." for normal users and "/sbin:/bin:/usr/sbin" for root.
6. If this is not a "quiet" login, the message of the day is printed and the file with the user's name in "/usr/spool/mail" will be checked and a message will be printed if it has non-zero length.
7. The users shell is started. The shell is specified in the file "/etc/passwd". If it is not specified, login will use "/bin/sh" as a default shell.
8. If there is no directory specified for the user in "/etc/passwd", login will use "/" by default for the user's home directory.

Files used:

* /etc/nologin
* /etc/usertty
* /etc/seruretty
* .hushlogin
* /var/log/lastlog
* /etc/passwd

Thursday, January 06, 2005

linux timer threads

current problem and not for fun but for work.
is making a watchdog timer threads
http://www-106.ibm.com/developerworks/linux/library/l-rt5/
http://docs.hp.com/en/B9106-90009/timers.2.html

http://www.pc860.com/VxDemo/posixTimerStartDemo.c

pthread_cond_signal in a signal handler?
http://www.llnl.gov/LCdocs/pthreads/index.jsp?show=s8.2.3

Sunday, January 02, 2005

init and initab

i went to yaghmour's book and he discusses sysvinit on page 191
and points to an only article by Alessandro Rubini.

the highlights of what rubini states "almost anything can be used as init."
that is a shell scrip but goes to says the real init is sysvinit.
and from there there are a multitude of ways to handle the startup.

--------------------------inittab script--------------------------
# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.8 1998/05/10 10:37:50 miquels Exp $

# The default runlevel.
id:2:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

# Action on special keypress (ALT-UpArrow).
kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work."

# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop

# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
# :::
1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100

# Example how to put a getty on a modem line.
#
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3

--------------------------end inittab script----------------------

first this is directly from the man page.

ok here is a step by step disection of the inittab file.
1)
The inittab file describes which processes are started at bootup and
during normal operation (e.g. /etc/init.d/boot, /etc/init.d/rc, get-
tys...). Init(8) distinguishes multiple runlevels, each of which can
have its own set of processes that are started. Valid runlevels are
0-6 plus A, B, and C for ondemand entries.
An entry in the inittab file has the following format:

id:runlevels:action:process

so the entry id:2:initdefault:

so the means the default runlevel is 2.

after reading the inittab man page i see that the file
i have is almost the same as the example shown
on the man page.

it might be for the best to use a debian system starup but
trimmed down. i could then use the scripts an documentation
that comes for debian ... i eventually want to use xwindows.

the need for init means a couple of things.
1) i need to be able to login. this means what?
passwords?
from a naive understanding

init and inittab

so i am at the point where i have to create the
init infrastructure.
this isnt so bad. the kernel is boot init is
running and wants an inittab i just have to
decide what to build.

it would be nice to just launch a bash script.
i am going to go back to Yaghmour's book and
see what it says. and i think will just
try to launch a bash prompt.

Saturday, January 01, 2005

the thing boots but has errors:
exec: 64: chroot not found
kernel panic: Attempted to kill init!

i am going to check out the busy box build maybe i didnt
tell busybox to build chroot!

what i found out. i was indeed building busybox with
chroot support. so that wasnt the issue.
i looked on google of coarse and i found similar
issues but not exactly the same as mine.
then i notice that 64 probably meant line 64 or the linuxrc script.
-------------------------- linuxrc ---------------------------------
#!/bin/sh
#
# /linuxrc: System initialization script.
#

# where should all the output go
# OUTPUT=/dev/stdout if you want to see the error messages
OUTPUT=/dev/stdout

mount -t proc proc /proc

# test /dev/sr*, if we can mount it test for
# the file /mnt/cdrom/RESCUECD, if it is there we assume it is the RESCUECD
mountCD() {
for i in /dev/sr*; do
if mount -t iso9660 $i /mnt/cdrom 2> $OUTPUT 1> $OUTPUT; then
if test -f /mnt/cdrom/RESCUECD -o -f /mnt/cdrom/rescuecd; then
DEVICE=$i
return 0
else
umount $i
fi
fi
done
return 1
}

# first load some modules if necessary
(cat /etc/modules; echo) | # make sure there is a LF at the end
while read module args
do
case "$module" in
\#*|"") continue ;;
esac
insmod /lib/modules/$module $args
done

# so long no rescue cd found prompt for it
while ! mountCD; do
echo "Can't find valid cdrom in any drive - Fix that and press Enter"
read TMP
done

# copy the imagefile with the /var filesystem to /dev/ram1
# - saves a lot of space in contrast to using a tar archive and
# - compiling tar/gzip support into busybox and adding
# - an mke2fs binary
dd if=/mnt/cdrom/usr/lib/varbase/ram1.img of=/dev/ram1 2> $OUTPUT 1> $OUTPUT
mount /dev/ram1 /mnt/cdrom/var 2> $OUTPUT 1> $OUTPUT

# link /dev/cdrom and /dev/root_dev to the proper target
ln -sf $DEVICE /mnt/cdrom/dev/cdrom
ln -sf $DEVICE /mnt/cdrom/var/dev/root_dev

# umount /proc
umount /proc

# let's do some root device changing
cd /mnt/cdrom
pivot_root . initrd

# and finally start the real init
# at this point /dev/ram1 is mounted on /var
exec chroot . /sbin/init dev/console 2>&1 #line 64
----------------------------- end linuxrc --------------------------

so line 64 was giving the issue i went back to my minimal
timo cd install. and tried some things.
first i removed removed /sbin/init. with the result:
chroot: cannot execute /sbin/init: No such file or directory
Kernel panic: Attempted to kill init!

that is not my error.

then i tried killing all the contents of the etc directory:
INIT: No inittab file found.

i then wondered whose chroot am i really talking about?
i found when i had build the coreutils that i never
bothered to build chroot, i went back and installed chroot
onto my system and i got the above error:

INIT: No inittab file found.

this make sense as i have a totally empty /etc
directory. this is purposeful i wanted to start
from nothing a truly clean slate. timos is
great bit i have no idea was is absolutely
necessary or was caried over from the debian distro
it was builton.

THE BIG IDEA.
above script

pivot_root . initrd
this command must move from being an intial ram
disk to being what is on the cd.





gnu makefile foreach and addprefix useage.

this i have leaned recenly.

1) older version of the kernel may not work with newer version of gcc.
see post:

http://www.buoy.com/pipermail/lilug/2004-March/024154.html

so if want to used 2.4.17 i may have to use gcc-2.95.3
currently the uclibc gcc-3.3.x build process works well
and seems to build 2.4.26 of the kernel. so guess what
i am going to use these later version of the 2.4 kernel!

2) i dropped ptxdist and adopted a modded version of
gcc-3.3.x and ptxdist. life would probably be easier
if i just used buildroot out right but then i wouldn't learn
anything. so i slowly added to my "own" system.

3) atmel is not the choice for usb microcontrollers but
cypress. cypress has lots of inexpensive kits and extensive
user base. i found a nice usb dev kit for around 79
bucks.