Challenge
Shell Scripting
Objective: Shell scripting is a basic skill every Linux developer has Proficiency Level: Advanced
We require a script to do some "processing" for every kernel released:
First, make it work
Second, optimize it
We need the following working directory structure
Script Arguments
The script will receive 3 arguments: the file location, version of the kernel and the file type
If file location is the internet then use this repository to grab the kernel tar file:
and download it to kernelimages directory.
If file location is local then use kernelimages directory to grab the kernel tar file
Processing
We will gather statistics and do some work in 2 phases, right after we have decompressed the kernel file under the preworkspace directory and after we make some changes to its directory structure under postworkspace, statistics will be populated in 2 different files under our top working directory, their names will be:
stats.pre
stats.post
Pre Processing
Take kernel image from kernelimages directory and decompress under the preworkspace directory. We will require the following information under stats.pre files:
File Names
File Content
Some Tasks To Do
Sort in alphabetical order all the inclusion of libraries using this format #include only under drivers/i2c/ directory, please make sure you identify all files you have modified, you will need their identity in the post processing phase
Let's populate our file called intel.contributors under our top level working directory directory, search for all Intel contributors matching @intel.com and identify the file where their name was located, then write one line per contributor, cannot be repeated e.g.
Post Processing
Create 3 directories under postworkspace and move all files from preworkspace where kernel was decompressed according to the file extensions:
In all 3 directories, if we have files with the same name, add a number as identifier that will increase by 1 as required, e.g.
Some Tasks To Do
Add your name to the beginning, middle and end of every .c file
In all files substitute #include for every #include found
Fix your #include's order for the files coming from driver/i2c
We will need the following information under stats.post files:
File Names
File Content
Results
A message of Pass / Fail should be printed to stdout for each of the following:
Our Total number of files is the same in both stats.pre and stats.post
Last updated