In this new release I have created a Manual page with some nice formatting. And expanded on some of the options now providing more meaningful information. The man page can be seen by typing:
man ./script
In the future this would be added to the PATH so that it can be seen from any location the same with the actual script.
As for the script I have expanded the help section to provide the information given in the man page.
Also I have automated the retrieval of the pidora kernel that I was previously unable to do it because I had no idea how to construct the url that provided me with the source RPM.
Some other notes:
For the Pidora source RPM it only looks for packages in the f19-rpfr Tag when changing to f20-rpfr this line would need to be modified.
The -b option now will take 3.11 instead of 3.11.y, using 3.11.y will cause errors. It is better anyways to use 3.11 just simpler.
There is no error checking so if the information provided is not right it will not finish successfully.
Still no name for the script .... Poor nameless script.
Since the scripts where getting too long I am instead linking to a file.
Man page:
https://drive.google.com/file/d/0B2G5T2vxJmLrUEhhZ1BrQ1JYWDA/edit?usp=sharing
Script:
https://drive.google.com/file/d/0B2G5T2vxJmLrTjJzcTNDeENEeDA/edit?usp=sharing
And I am off to Ecuador, it was great working on this. I will continue working on it when I return.
I plan on adding some error checking, some other useful options and cleaning up the the code more.
Friday, December 13, 2013
Thursday, December 5, 2013
Release 0.2.1
Various bugfixes
Added email option to report when a new kernel is building - could not test it because bell blocks port 25
-------------------------------------------------------------------------------------------------
#!/bin/bash
#Check if the file contain the commit long exists
#If it does not exist create the file
if [ ! -f ./branches ]; then
touch branches
fi
if [ ! -f ./long_commit ]; then
touch long_commit
fi
# Retrieve branches from github - Retrieving branches from ls-remote instead of wget
#wget -qO- https://github.com/raspberrypi/linux | cat | grep 'data-name="rpi' | cut -d '"' -f2 > ./branches
# Delete the patches branch - Used only when using the wget way
#sed -i '$ d' ./branches
# Storing git remote head values on a file
git ls-remote https://github.com/raspberrypi/linux.git > ls_remote
# Retrieving Branches from ls_remote
# The sort is only cheking for the decimal place if a version 4.x comes out this will stop working if 3.x versions
# remain when doing a git ls-remote
cat ls_remote | grep rpi | cut -d '/' -f3 | sort -t $'.' -n -k2,2 > ./branches
# Store latest branch in a variable
branch=$(tail -1 ./branches)
# Storing url for use with wget
url=$(echo "https://github.com/raspberrypi/linux/tree/$branch/kernel")
#wget -qO- $url > ./page_source
# Retrieving informacion from the git ls-remote command
#commit_date=$( cat ./page_source | grep 'committed <time class="js-relative-date"' | cut -d '"' -f6 | cut -d ' ' -f1 | cut -d '-' -f1-3 --output-delimiter='' )
commit_date=$( date +"%Y%m%d")
long_commit=$( cat ./ls_remote | grep $branch | cut -f1)
short_commit=$( echo $long_commit | cut -c 1-7)
stored_long_commit=$(cat ./long_commit)
# Finding out the %_topdir value to see where the rpmbuild directory is being created
topdir=$( rpm --eval '%{_topdir}')
# Find latest package submitted to rpfr18-updates-automated
koji_build=$( armv6-koji latest-pkg f18-rpfr-updates-automated raspberrypi-kernel | tail -1 | cut -d ' ' -f1)
# Safe to use koji URL
#koji_url=$( echo "http://japan.proximity.on.ca/kojifiles/packages/raspberrypi-kernel/3.11.6/4.20131023git10bc582.rpfr19/src/raspberrypi-kernel-3.11.6-4.20131023git10bc582.rpfr19.src.rpm" )
koji_url=$( echo "http://japan.proximity.on.ca/kojifiles/packages/raspberrypi-kernel/3.12.0/4.20131106git839f349.rpfr18/src/raspberrypi-kernel-3.12.0-4.20131106git839f349.rpfr18.src.rpm" )
# Usage function for the script
usage(){
echo "
usage: $0 -h | -l | -b <branch> | -k <URL> | -m <email@address.com>
If the -k option is not used the latest will be used
OPTIONS:
-h Shows this message
-l List Branches
-b Branch
-k Koji kernel url to download
-m address to mail
EXAMPLE:
$0 -h
$0 -l
$0 -b 3.11.y
$0 -k http://japan.proximity.on.ca/kojifiles/packages/raspberrypi...
$0 -b 3.12.y -k http://japan.proximity.on.ca/...
$0 -m somebody@senecacollege.ca
"
}
sendmail(){
echo "There is a new kernel" | mail -s "Kernel Update" $1
}
# Use options to find out which version of the kernel to use
# Also added an option to list all the branches
while getopts "hlb:k:m:" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
b)
branch=$OPTARG
;;
k)
koji_url=$OPTARG
;;
l)
cat ./branches
exit 1
;;
m)
mailFlag=1
email_address=$OPTARG
;;
# v)
# versionFlag=1
# version=$OPTARG
# ;;
?)
usage
exit 1
;;
esac
done
# Find version from koji url, if the -k option is not in use
if [ "$versionFlag" != "1" ]; then
version=$( echo $koji_url | cut -d '/' -f7 | cut -d '-' -f2)
fi
# Find source rpm file name downloaded from koji
srcrpm=$( echo $koji_url | cut -d '/' -f10 )
distro=$( echo $srcrpm | cut -d '.' -f5)
# If the file is empty store the long_commit variable
# Otherwise compare the long commit form Github with the one in the file
# If they are the same do nothing and exit
# If they are different store the new value in the file and download the new kernel
if [ ! -s ./long_commit ]; then
echo $long_commit > ./long_commit
else
if [ "$long_commit" == "$stored_long_commit" ] ; then
#Nothing to do
flag=0
echo "There is no new kernel"
else
# Replace the old commit with new commit
echo $long_commit > ./long_commit
#Proceed to build kernel
flag=1
fi
fi
if [ $flag -eq 1 ]; then
# Download previous built kernel to retrieve some necessary files including the spec file
wget $koji_url
# Download new kernel
new_kernel_url=$(echo "https://github.com/raspberrypi/linux/tarball/$long_commit")
wget $new_kernel_url
# Create and wipe rmbuild tree of directories
rpmdev-setuptree
rpmdev-wipetree
# Extract files from source rpm downloaded from koji
rpm2cpio $srcrpm | cpio -idmv
# Modifiying SPEC file with info from the new kernel
sed -i "s/commit_date\ .*/commit_date $commit_date/" raspberrypi-kernel.spec
sed -i "s/commit_short\ .*/commit_short $short_commit/" raspberrypi-kernel.spec
sed -i "s/commit_long\ .*/commit_long $long_commit/" raspberrypi-kernel.spec
# Copy spec file to ~/rpmbuild/SPECS
mv raspberrypi-kernel.spec $topdir/SPECS/
# Bump SPEC
rpmdev-bumpspec -c "Updated to latest commit" $topdir/SPECS/raspberrypi-kernel.spec
# Copye source files to ~/rpmbuild/SOURCES
mv first32k.bin.bz2 $topdir/SOURCES
newfile=$(echo "pidora-config-$version-"$short_commit".bz2")
file=$( ls -l | grep 'pidora-config' | awk '{print $9}' )
mv $file $newfile
mv $newfile $topdir/SOURCES
mv "$long_commit" $topdir/SOURCES
# Send Source Package to Koji
release=$( cat ~/rpmbuild/SPECS/raspberrypi-kernel.spec | grep Release | cut -d ' ' -f9 | cut -d '.' -f1)
modular_srcrpm=$(echo "raspberrypi-kernel-"$version"-"$release"."$commit_date"git"$short_commit"."$distro".src.rpm")
koji -s 'http://japan.proximity.on.ca/kojihub' build f18-rpfr-updates-automated $topdir/SRPMS/$modular_srcrpm
# Send email reporting about new build
if [ "$mailFlag" == "1" ]; then
sendmail $email_address
fi
fi
Subscribe to:
Posts (Atom)