Linux development Lection 3 25.01.2015. What we gonna do today Root privileges Software packages Managing software packages Build procedures Build components.

Slides:



Advertisements
Similar presentations
Separate compilation Large programs are generally separated into multiple files, e.g. tuples.h, ray.h, ray.c, tuples.c main.c With several files, we can.
Advertisements

Understanding Makefiles COMP 2400, Fall 2008 Prof. Chris GauthierDickey.
Systems Dev. Tutorial II: Make, utilities, & scripting Recitation Wednesday, Sept 13 th, 2006.
Software installation Chapter 7. Software installation Numerous software options Usually free Open source Several sources Installation CD Websites sourceforge.net.
Package Managers What are they and why we use them.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
Linux Shell. 2 Linux Command-Line Interface ■ Linux shells: A shell is a command interpreter that allows you to type commands from the keyboard to interact.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
Introduction to The Linaro Toolchain Embedded Processors Training Multicore Software Applications Literature Number: SPRPXXX 1.
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
Using the “CLI” Unix / Linux Preparation Course May 25 Djibouti.
V Avon High School Tech Crew Agenda Old Business –Delete Files New Business –Week 10 Topics: Coming up: –Yearbook Picture: Feb 7 12:20PM.
Lab 3 Department of Computer Science and Information Engineering National Taiwan University Lab3 - Cross Tools 2014/10/7/ 20 1.
Debian package manager Presenter: Lilian Wang. Install Software  先別管 package 了, 你有聽過重灌嗎 ?  Chrome/Firefox, Office, pietty, Notepad++, PCMan, LOL, …
Linux Operations and Administration
V Avon High School Tech Crew Agenda Old Business –Delete Files New Business –Week 9 Topics: Coming up: –Yearbook Picture: Feb 7 12:20PM.
workshop eugene, oregon UNIX ™ /Linux Overview Unix/IP Preparation Course July 19, 2009 Eugene, Oregon, USA
CIS 191 – Lesson 2 System Administration. CIS 191 – Lesson 2 System Architecture Component Architecture –The OS provides the simple components from which.
Introduction to Android. Android as a system, is a java based operating system that runs on the Linux kernel. The system is very lightweight and full.
Managing User Accounts. Module 2 – Creating and Managing Users ♦ Overview ► One should log into a Linux system with a valid user name and password granted.
Lab 11 Department of Computer Science and Information Engineering National Taiwan University Lab11 - Porting 2014/12/9/ 26 1.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction Unix-like system is everywhere Linux Android for smartphones Google Chrome OS for Chromebook Web.
Working with Ubuntu Linux Track 2 Workshop June 2010 Pago Pago, American Samoa.
Programming Tools gcc make utility Open Source code Static and Shared Libraries gdb Memory debugging tools.
Introduction to Linux ( I ) Sidney Fong 4 th Feb 2006.
CERN Manual Installation of a UI – Oxford July - 1 LCG2 Administrator’s Course Oxford University, 19 th – 21 st July Developed.
Old Chapter 10: Programming Tools A Developer’s Candy Store.
1 What is a Kernel The kernel of any operating system is the core of all the system’s software. The only thing more fundamental than the kernel is the.
UNIX ™ /Linux Overview Unix/Linux Preparation Course June 27, 2010 Pago Pago, American Samoa.
How to configure, build and install Trilinos November 2, :30-9:30 a.m. Jim Willenbring Mike Phenow.
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
Chapter 3 & 6 Root Status and users File Ownership Every file has a owner and group –These give read,write, and execute priv’s to the owner, group, and.
Tools – Ant-MakeEtc 1 CSCE 747 Fall 2013 CSCE 747 Software Testing and Quality Assurance Tools 12 – Hamcrest 10/02/
© 2006 ITT Educational Services Inc. Linux Operating System :: Unit 3 :: Slide 1 Downloading and Installing Software yum pirut Bit Torrent rmp.
CSCI 330 UNIX and Network Programming Unit XX: Linux Administration.
Yannick Patois - Datagrid Software Repository Presentation - March, n° 1 Datagrid Software Repository Presentation CVS, packages and automatic.
Linux Programming Schedule Lection Meet and greet Introduction to course Introduction to Linux Virtual machines Terminal Makefiles Lab Setup.
Installing Applications in FreeBSD lctseng. Computer Center, CS, NCTU 2 Before we start  Permission issue root: the super user Like administrator in.
The Kernel At a high level, the kernel in an operating system serves as the bridge between applications and the actual data processing of the hardware.
Build Tools 1. Building a program for a large project is usually managed by a build tool that controls the various steps involved. These steps may include:
How to configure, build and install Trilinos November 2, :30-9:30 a.m. Jim Willenbring.
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
 Prepared by: Eng. Maryam Adel Abdel-Hady
 Prepared by: Eng. Maryam Adel Abdel-Hady
Embedded Software Design Week II Linux Intro Linux Kernel.
Wed Mar Michael Imamura / The GNU Autotools Your very own./configure.
CLHEP Infrastructure Improvements CHEP 2004 Lynn Garren, FNAL and Andreas Pfeiffer, CERN.
August 31, 2010Joris Geurts1 2IN05 Operating Systems Introduction to Linux More information for this course:
Building programs LinuxChix-KE. What happens in your CPU? ● It executes a small set of instructions called "machine code" ● Each instruction is just a.
Using Grsync with Ubuntu Presented by Dave Mawdsley, DACS Member, Linux SIG August 20, 2008 (making rsync easy with a memory key or a server)
Developing Portable Applications ● Introduction GNU autotools – GNU toolchain ● Goals - cross-platform ● Supported platforms (POSIX compliant) ● GNU autotools.
Packaging Software for Debian Roberto C. Sánchez Ohio Linuxfest Saturday, September 29, 2007.
Autoconf, Automake, and Libtool Tom Tromey. Copyright ● Copyright 2006 Tom Tromey ● Parts Copyright 2006 Alexandre Duret-Lutz ●
Installing Applications in FreeBSD
Outline Installing Gem5 SPEC2006 for Gem5 Configuring Gem5.
Chapter 11: Managing Users
The Linux Operating System
Compiling from source code
9 Linux on the Desktop.
Ubuntu Working in Terminal
More Scripting & Chapter 11
Makefile Tutorial CIS5027 Prof: Dr. Shu-Ching Chen
What is make? make is a system utility for managing the build process (compilation/linking/etc). There are various versions of make; these notes discuss.
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Hector Cen Fall 2017
University of Texas Rio Grande Valley Systems Administration CSCI 6175
Introduction Paul Flynn
Overview Unit testing Building Version control.
Download and Installation of code::blocks
Preparation for Assignment 2
What is make? make is a system utility for managing the build process (compilation/linking/etc). There are various versions of make; these notes discuss.
Presentation transcript:

Linux development Lection

What we gonna do today Root privileges Software packages Managing software packages Build procedures Build components Cross-compiling tool chains

Root privileges

What is root root is the user name or account that by default has access to all commands and files on a Linux or other Unix-like operating system. It is also referred to as the root account, root user and the superuser.

root directory The top level directory of a systems cd /

root data directory /root Same as /home/

root privileges Powers that the root has on the systems Root account has the absolute power on the system Can grant and revoke access permissions

rootkit Software tools inserted as an intruder Has the same privileges as root Can be used to do bad things to the OS

User ID (UID) Each user has UID. In order to check the UID of a user use: echo $UID

/etc/passwd There is information about the users Use cat /etc/passwd to open the info about all the users How many users we see ?

How to create new user :# adduser testuser Follow the instructions

User groups /etc/shadow – secure user account info /etc/passwd – user accounts info /etc/group – defines the groups that user belongs /etc/sudoers – list of users who can execute sudo Used to determine equal privileges to all users in a group

How to add user as sudo # adduser newSudoUser # adduser newSudoUser sudo

How to remove user # userdel –r newSudoUser (if newSudoUser is used you must logout)

How to edit user # usermod –u UID username – this will change the UID number

Administrator vs root Every user can become administrator The root is a user that is administrator with highest possible privileges

Questions ?

Software packages

Software packages are packages of source files that are unachieved and build for each unique device. That way each software on Linux/UNIX can be build for every different machine One package can run on different OS architectures

How to install software on Debian Dpkg APT Unachieve

# dpkg Debian package management system Low level Installs, remove, provide information about.deb packages

# dpkg use # dpkg –i - to install something # dpkg –l - to list available packages # dpkg –r - to remove

APT – Advanced Packaging Tool High-level user friendly interface to manage packages Automatic retrieves, configures and install software packages

# apt-get APT package handling utility – cmd interface # apt-get install # apt-get update – retrieve new list of packages # apt-get upgrade – performs an upgrade # apt-get remove, – removes a package # apt-get clean – Erase downloaded archive files # apt-get dist-upgrade – distribution upgrade

# apt-get # apt-get source – Download source archives # apt-get download - Download binary # apt-get build-dep - Finds the libraries required to build a source

# apt-cache Used for searching and identifying a package # apt-cache search

# dpkg and # apt lab – task 1 – 10 min Update / upgrade Search for openssh Download source and binary of openssh Install with# dpkg Remove openssh Clean

Build procedure Install build-essential (# apt-get install build-essential) # apt-get build-dep #./configure If configure successful continue else google it # make # make install

In case of failure in the middle of installation # apt-get –f install # dpkg –configure –a

# dpkg and # apt lab task 2 – 15 min Configure compile and install openssh

# aptitude GUI for installing packages Press + or - to change the status of application

Qustions ?

Creating build procedures

Before you start In order to create a build procedure you must first know the target of the build procedure You must know all the libraries and dependencies that the build needs to build

Target Linux/GNU is supported by almost all processors with more than 84 MHz clock frequency In most of the cases the whole core must be recompiled and then uploaded to the target using UART/SPI/JTAG The code must be optimized as possible in order to work fast and not to waste resources

Libraries There are different options for core libraries to be used for the different processors. For simple application developed for embedded systems it is better to use libraries like: uClibc-ng (uclibc-ng.org) – optimized for space not for speed Musl C – optimized for speed and simplicity

uClibc High configurability: many features can be enabled or disalbled Supports most embedded architectures Must recompile every time there is a change Low performance Size of helloworld using uClibc – 18 kB Size of helloworld using glibc – 361 kB download

Important note NEVER USE : sudo rm –rf /*

Build steps 1.Optimize for target 2.Make configure file 3.Make Makefile 4.(Optional make Makefile for install) 5.(Optional make uploading to board script)

Optimize for target Part of the process is reviewing the code for any unused libraries and functions, because if no code optimization is used in the compiler all the libraries and their functions will be used If used uClibc start its GUI (graphic user interface) in order to set all that you are going to need in the compilation

Build and release tool chain for Debian

Make configuration file Used to check if all the dependencies are available in the system Used to collect and add all system information into a Makefile

Make configuration file Install autoconf and automake Write hello wolrd.c file in a folder Then we start making the lines configure file $ nano configure.ac

configure.ac AC_INIT([programName], [ver], AM_INIT_AUTOMAKE AC_PROG_CC AC_CONFIG_FILES([Makefile]) AC_OUTPUT

Making configuration file We must add a Makefile.in in order to be autoset after the execution of./configure Developers are lazy and they we have an automation script that is generating this file too $ nano Makefile.am

Makefile.am AUTOMAKE_OPTIONS = foreign # we say to linux that this software is not following the standart layout of GNU project bin_PROGRAMS = helloworld # this is the name of the final app helloworld_SOURCES = main.c # the sources

Putting all together $ aclocal # set up on m4 enviroment $ autoconf # generate configuration from configure.ac $ automake –add-missing # generate makefile.in from makefile.am $./configure # generate Makefile $ make dist # use makefile to build $ make distcheck # use this to check the tarball to distribute

How to convert binary to.deb Make a new folder hello_world_for_debian Copy the main.c file from the first folder and paste in in the new one Make directory DEBIAN Then $ nano DEBIAN/control

DEBIAN/control Package: hello_world Version: 0.1 Section: custom Priority: optional Architecture: all Essential: no Installed-Size: 1024 Maintainer: Description: Print hello world to the screen

How to convert binary to.deb Inside the directory hello_world_for_deb make directori usr/bin/ Then move the executable file to usr/bin/ Go one level up from the directories DEBIAN/ and usr/ $ dpkg-deb --build hello_world_for_deb Then $ ls Then $ sudo dpkg –i hello_world_for_deb.deb Then $ cd /usr/bin And finally./helloworld

Questions ?

Make a tool-chain for embedded platforms

How to compile for ARM based CPU Two approaches: Use buildroot Create custom makefile

Using Buildroot Install Buildroot with $ wget Run $ make menuconfig Run $ make

Create custom Makefile You can write only one Makefile for all of your software and just change few lines in order to compile everything This is the most comfortable way to have full control of the code you compile

Makefiles – starting point all: [tab] GCC main.c hello_master.c –o outputfile

Makefiles – define macros CC = GCC # define compiler CFLAGS = -O –lm # define output compilation flags LIBS = “-lnurses –lm –lsdl” PINGUIN = (“)>

Makefiles – spacial macros - the name of the file to be made $? – the names of the changed dependents $< - the name of the related file that caused the action $* - the prefix shared by target and dependent files // using $ make –p in the terminal will show you the default predefined macros

Makefiles – with macros CC:=gcc CFLAGS:=-O -Wall all: $(CC) main.c hello_master.c $(CFLAGS) -o outputfile

Makefiles - dependencies Similar to the functions in the programming languages Helps to recompile only what you need, not everything

Makefiles – with dependencies CC:=gcc CFLAGS:=-O -Wall –c all: compile compile: main.o hello_master.o $(CC) main.o hello_master.o -o outputfile main.o: main.c $(CC) $(CFLAGS) main.c hello_master.o: hello_master.c $(CC) $(CFLAGS) hello_master.c

Makefiles What if we have 500 files that we must compile ????

Makefiles – using macros in dependencies CC=gcc CFLAGS=-c -Wall -O LDFLAGS= SOURCES=main.c hello_master.c OBJECTS=$(SOURCES:.c=.o) EXECUTABLE=binary all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) -o $(CC) $(CFLAGS) $< -o clean: -rm -f *.o core *.core

And cross compilation for AVR Install arduino-mk Use avr-gcc instead of gcc in the Makefile

Qustions ?

Lab

Task 1 Write a C program that: Calculates perimeter and surface of given equilateral figure by given side and number of angles Program must have files main.c surface.c and perimeter.c Compile and run Pack to archive Pack to.deb Prepare manual Makefile