Development Experience of senior Linux programmers

Source: Internet
Author: User
Tags ftp site
About the development experience of senior Linux programmers-general Linux technology-Linux programming and kernel information. The following is a detailed description. Post:
Sppence Murray is one of the Linux developers and has long been a strong supporter of UNIX. This article describes the basic technology used by Murray and his colleagues in Codemonks Consulting in daily Linux development and application service work: shell script, I believe that all Linux developers will benefit from this useful and common technology.

Spence Murray is one of the founders of Codemonks Consulting. Since the earliest code written on SunOS in 1980s, Spence Murray has been committed to UNIX/Linux development. Since then, he has worked in IBM's AIX and SGI Irix to write cross-platform UNIX code for a long time, including HP/UX, Irix, Solaris/SunOS, sco unix, various BSD, MacOS X, and of course Linux. He has done everything from graphics/Video device drivers to UI code. The cross-platform Code Compiled by Murray includes the X Window System Xserver code and the core browser code as part of Netscape Navigator.

The most common Linux tools used by Murray are vi, bash, and Emacs. "Whether I am writing C, C ++, Java, shell scripts, or HTML, I switch back and forth among these tools most of the time," he said.

Linux secret weapon

Murray believes that for a Linux developer, shell is a powerful software development tool, which is not rated as much. "In every job I do, I need to use shell scripts to quickly read and modify common text or write code," he said. "It's lightweight and fast, and its short Command makes moving code back and forth a fast and painless process. As an editor, it will soon become the second instinct ".

For Murray, Emacs emerged later as a development tool. "In the early 1990s S, I tried to use Emacs as an IDE and soon switched to the foyer. Emacs is very powerful. In those days, I will always open an Emacs window and often open dozens of source files, each has the context I edited, the debugging session using gdb, And the bash script running in different source directories. There is a lot of information about Emacs, which can be said to be a terrible tool... In addition, you can run Emacs on any system that you want to spend time developing.

Since the first time using the simple environment vi supported by SunOS In The Middle Of 1980s, the Emacs editor has become a standard tool for Murray. "It can be used on UNIX of various genres, which is one of the main reasons I chose for cross-platform development," he said.

Linux developers: Understand your shell

Murray requires that you understand your shell. "Bash, tcsh, csh ?? Shell is your most basic software development tool, "he stressed. "It can do a lot of amazing things. All work depends on it ...... And its powerful functions ". As an example to illustrate the powerful functions of common shell scripts, there is a file that can be downloaded in the references section, including a set of scripts, used to obtain updated RPM packages released by Red Hat and merge them into the original and customized packages. After downloading and decompressing the file, you can find the script in the/developerworks/rpm_update_scripts directory. The final result is a directory that includes the latest version of all software packages and an hdlist file for network installation upgrades.

The following code snippet implements automatic updates to the Red Hat RPM package to create an installable version that uses the latest RPM. This is a basic step for anyone who maintains a public Linux server. For us, we usually maintain a large number of network services on many public Linux servers. The following are some scripts that can automatically update the latest security and functions.

The script below demonstrates that common shell programming technology can be widely used in various system configurations and program design applications. The script uses the bourne shell, which is the most common shell in different UNIX systems. This ensures that these very lightweight codes can be slightly modified or used on different UNIX systems without modification. It is easy to modify the Red Hat software package specification to apply it to other Linux releases.

Freshen. sh update the RPM package on the site using the specified RPM ftp to update the original RPM list. Execute the filter to replace the updated RPM package. Finally, the long release list is updated based on the new RPM Software Package obtained from the image Update site.

Listing 1. fresh. sh


#! /Bin/sh
Rh_ver = $1
Rh_path = $2
Update_dir =$ {rh_path}/RH $ {rh_ver}-updates
Custom_dir =$ {rh_path}/RH $ {rh_ver}-custom
Install_dir =$ {rh_path}/RH $ {rh_ver}-install

# Sanity check for the original directory.

# Create update and install directories if they don't exist

[-D $ {update_dir}] | mkdir $ {update_dir}
[-D $ {install_dir}/RedHat/RPMS] | mkdir-p $ {install_dir}/RedHat/RPMS

# Get latest updates from fresh rpms FTP site

./Get_update.sh $ {rh_ver }$ {update_dir}

# Create/update hardlinks from update, and custom directories
# To the install directory. We assume that original RPMS are already
# Hardlinked to the install directory, so all we need to do is filter
# Out any replaced by updated packages.

./Do-links.sh $ {update_dir }$ {install_dir}/RedHat/RPMS
[-D $ {custom_dir}] &./do-links.sh $ {custom_dir}
$ {Install_dir}/RedHat/RPMS

# Filter out all but the latest version of everything.

/Filter-rpms.pl $ install_dir/RedHat/RPMS

# Rebuild the hard disk lists
/Usr/lib/anaconda-runtime/genhdlist $ {install_dir}


Freshen. sh calls the do-links.sh and get_update.sh to set the source, destination (omitted from the source RPM package; hard link used to set the target RPM), and retrieve updates, respectively.

Listing 2. do-links.sh


#! /Bin/sh

Src = $1
Dest = $2

# For file in $ src/*; do
For file in 'Find $ src-name *. rpm-! -Name *. src. rpm-print '; do
Base = 'basename $ file ;'
If test! -F $ dest/$ base; then
Echo "Linking $ file ";
Ln $ file $ dest
Else
Echo "EXISTS: $ file ";
Fi
Done


Listing 3. get_update.sh


#! /Bin/sh
Rh_ver = $1
Dest = $2
Echo "Retrieving updates for version $ {rh_ver} to $ dest"
Lftp <EOF
Open ftp.freshrpms.net

Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/i386 $ dest/i386
Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/IST $ dest/IST
Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/i586 $ dest/i568
Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/i686 $ dest/i686
Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/SRPMS $ dest/SRPMS
Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/noarch $ dest/noarch
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.