Install the minimal requirment to compile the kernel which are declared in below sites:
https://www.kernel.org/doc/html/v4.15/process/changes.html
Program:
# install Kernel minimal requriment compilation by Velraj.K
# Check : http://velrajcoding.blogspot.in
import subprocess
import shutil
import os
APT_INSTALL_COMMAND = "sudo apt-get --assume-yes install "
APT_UPDATE = "sudo apt update --assume-yes"
DICT_NAME = 'name'
DICT_CMD = 'command'
DICT_CMD_INST = 'command_install'
existing_sofware = []
installing_list = []
installing_err = []
def is_tool_present(name):
# var = os.system('which vim') will display the output on console and store success value 0 to var
# store the output of which in command line value into the var.
var = os.popen('which ' + name).read()
ret = var.find(name)
return ret != -1
def install_software(software):
#subprocess.call("sudo apt-get update", shell=True)
if is_tool_present(software[DICT_CMD]):
print(software[DICT_NAME] + " is already installed in the system, so not installing \n");
existing_sofware.append(software)
else:
# run the install command in the shell,
ret = subprocess.call(APT_INSTALL_COMMAND + software[DICT_CMD_INST], shell=True)
# check is the software is installed successfully, if success add in installing_list otherwise add in _err.
if ret == 0:
print "Installed " + software[DICT_NAME] + " Successfully"
installing_list.append(software)
else:
installing_err.append(software)
# Display the table header.
def table_header():
# The value 1,20,25 & 20 are constant based on the column name
print "{:<15} {:20} {:<20} {:<25} {:<20}".format('Package', '\"Command Name\"', '\"Newly Installed\"', '\"Error while installing\"', '\"Existing package\"')
line = []
for i in range(1, 82):
# creat the list with - for display a line
line.append('-')
# convert the list into a string other wise display as ['-', '-', '-', ...]
str1 = ''.join(str(e) for e in line)
print str1
# To display the row content in the table
def table_row(table_row):
# The value 22, 23,23 & 20 are constant based on the column adjust value row
print "{:<22} {:<22} {:<23} {:<23} {:<20}".format(table_row[0], table_row[1], table_row[2], table_row[3], table_row[4])
def result_tablular():
# Display the result table header
table_header()
# Display the row value in the tabl
for name in installing_list:
table_row([name[DICT_NAME], name[DICT_CMD_INST], 'Yes', 'NA', 'NA'])
for name in installing_err:
table_row([name[DICT_NAME], name[DICT_CMD_INST], 'NA', 'Yes', 'NA'])
for name in existing_sofware:
table_row([name[DICT_NAME], name[DICT_CMD_INST], 'NA', 'NA', 'Yes'])
def main():
software_name = ['gcc', 'make', 'ld', 'fdformat', 'depmod', 'e2fsck',
'pccardctl', 'pppd', 'ps', 'iptables', 'openssl', 'bc',
'fsck.jfs', 'reiserfsck', 'xfs_db', 'mksquashfs', 'btrfsck',
'quota', 'iudnctrl', 'showmount', 'oprofiled', 'udevd', 'grub',
'mcelog', 'sphinx-build' ]
dict_list_software = [ {DICT_NAME:'GNU C', DICT_CMD:'gcc', DICT_CMD_INST:'gcc'},
{DICT_NAME:'GNU make', DICT_CMD:'make', DICT_CMD_INST:'make'},
{DICT_NAME:'binutils', DICT_CMD:'ld', DICT_CMD_INST:'binutils'},
{DICT_NAME:'util-linux', DICT_CMD:'fdformat', DICT_CMD_INST:'util-linux'},
{DICT_NAME:'module-init-tools', DICT_CMD:'depmod', DICT_CMD_INST:'module-init-tools'},
{DICT_NAME:'e2fsprogs', DICT_CMD:'e2fsck', DICT_CMD_INST:'e2fsprogs'},
{DICT_NAME:'jfsutils', DICT_CMD:'fsck.jfs', DICT_CMD_INST:'jfsutils'},
{DICT_NAME:'reiserfsprogs', DICT_CMD:'reiserfsck', DICT_CMD_INST:'reiserfsprogs'},
{DICT_NAME:'xfsprogs', DICT_CMD:'xfs_db', DICT_CMD_INST:'xfsprogs'},
{DICT_NAME:'squashfs-tools', DICT_CMD:'mksquashfs', DICT_CMD_INST:'squashfs-tools'},
{DICT_NAME:'btrfs-progs', DICT_CMD:'btrfsck', DICT_CMD_INST:'btrfs-progs'},
{DICT_NAME:'pcmciautils', DICT_CMD:'pccardctl', DICT_CMD_INST:'pccardctl'},
{DICT_NAME:'quota-tools', DICT_CMD:'quota', DICT_CMD_INST:'quota'},
{DICT_NAME:'PPP', DICT_CMD:'pppd', DICT_CMD_INST:'pppd'},
{DICT_NAME:'isdn4k-utils', DICT_CMD:'isdnctrl', DICT_CMD_INST:'isdnutils-base'},
{DICT_NAME:'nfs-utils', DICT_CMD:'showmount', DICT_CMD_INST:'nfs-common'},
{DICT_NAME:'procps', DICT_CMD:'ps', DICT_CMD_INST:'procps'},
{DICT_NAME:'oprofile', DICT_CMD:'oprofiled', DICT_CMD_INST:'oprofile'},
{DICT_NAME:'udev', DICT_CMD:'udevd', DICT_CMD_INST:'udev'},
{DICT_NAME:'grub', DICT_CMD:'grub', DICT_CMD_INST:'grub-pc'},
{DICT_NAME:'mcelog', DICT_CMD:'mcelog', DICT_CMD_INST:'mcelog'},
{DICT_NAME:'iptables', DICT_CMD:'iptables', DICT_CMD_INST:'iptables'},
{DICT_NAME:'openssl & libcrypto', DICT_CMD:'openssl', DICT_CMD_INST:'openssl'},
{DICT_NAME:'bc', DICT_CMD:'bc', DICT_CMD_INST:'bc'},
{DICT_NAME:'Sphinx', DICT_CMD:'sphinx', DICT_CMD_INST:'python-sphinx'} ]
ret = subprocess.call(APT_UPDATE, shell=True)
# Check and install the list of software available in the software_name
for name in dict_list_software:
install_software(name)
# Package installed due to kernal compilation error
# sign-file.c:25:30: fatal error: openssl/opensslv.h: No such file or directorycompilation terminated.
# for install libssl-dev
dict_list_soft_cmp_err = [ {DICT_NAME:'OpenSSL Dev pkg', DICT_CMD:'libssl-dev', DICT_CMD_INST:'libssl-dev'} ]
for name in dict_list_soft_cmp_err:
install_software(name)
result_tablular()
if __name__ == "__main__":
main()
https://www.kernel.org/doc/html/v4.15/process/changes.html
Program:
# install Kernel minimal requriment compilation by Velraj.K
# Check : http://velrajcoding.blogspot.in
import subprocess
import shutil
import os
APT_INSTALL_COMMAND = "sudo apt-get --assume-yes install "
APT_UPDATE = "sudo apt update --assume-yes"
DICT_NAME = 'name'
DICT_CMD = 'command'
DICT_CMD_INST = 'command_install'
existing_sofware = []
installing_list = []
installing_err = []
def is_tool_present(name):
# var = os.system('which vim') will display the output on console and store success value 0 to var
# store the output of which in command line value into the var.
var = os.popen('which ' + name).read()
ret = var.find(name)
return ret != -1
def install_software(software):
#subprocess.call("sudo apt-get update", shell=True)
if is_tool_present(software[DICT_CMD]):
print(software[DICT_NAME] + " is already installed in the system, so not installing \n");
existing_sofware.append(software)
else:
# run the install command in the shell,
ret = subprocess.call(APT_INSTALL_COMMAND + software[DICT_CMD_INST], shell=True)
# check is the software is installed successfully, if success add in installing_list otherwise add in _err.
if ret == 0:
print "Installed " + software[DICT_NAME] + " Successfully"
installing_list.append(software)
else:
installing_err.append(software)
# Display the table header.
def table_header():
# The value 1,20,25 & 20 are constant based on the column name
print "{:<15} {:20} {:<20} {:<25} {:<20}".format('Package', '\"Command Name\"', '\"Newly Installed\"', '\"Error while installing\"', '\"Existing package\"')
line = []
for i in range(1, 82):
# creat the list with - for display a line
line.append('-')
# convert the list into a string other wise display as ['-', '-', '-', ...]
str1 = ''.join(str(e) for e in line)
print str1
# To display the row content in the table
def table_row(table_row):
# The value 22, 23,23 & 20 are constant based on the column adjust value row
print "{:<22} {:<22} {:<23} {:<23} {:<20}".format(table_row[0], table_row[1], table_row[2], table_row[3], table_row[4])
def result_tablular():
# Display the result table header
table_header()
# Display the row value in the tabl
for name in installing_list:
table_row([name[DICT_NAME], name[DICT_CMD_INST], 'Yes', 'NA', 'NA'])
for name in installing_err:
table_row([name[DICT_NAME], name[DICT_CMD_INST], 'NA', 'Yes', 'NA'])
for name in existing_sofware:
table_row([name[DICT_NAME], name[DICT_CMD_INST], 'NA', 'NA', 'Yes'])
def main():
software_name = ['gcc', 'make', 'ld', 'fdformat', 'depmod', 'e2fsck',
'pccardctl', 'pppd', 'ps', 'iptables', 'openssl', 'bc',
'fsck.jfs', 'reiserfsck', 'xfs_db', 'mksquashfs', 'btrfsck',
'quota', 'iudnctrl', 'showmount', 'oprofiled', 'udevd', 'grub',
'mcelog', 'sphinx-build' ]
dict_list_software = [ {DICT_NAME:'GNU C', DICT_CMD:'gcc', DICT_CMD_INST:'gcc'},
{DICT_NAME:'GNU make', DICT_CMD:'make', DICT_CMD_INST:'make'},
{DICT_NAME:'binutils', DICT_CMD:'ld', DICT_CMD_INST:'binutils'},
{DICT_NAME:'util-linux', DICT_CMD:'fdformat', DICT_CMD_INST:'util-linux'},
{DICT_NAME:'module-init-tools', DICT_CMD:'depmod', DICT_CMD_INST:'module-init-tools'},
{DICT_NAME:'e2fsprogs', DICT_CMD:'e2fsck', DICT_CMD_INST:'e2fsprogs'},
{DICT_NAME:'jfsutils', DICT_CMD:'fsck.jfs', DICT_CMD_INST:'jfsutils'},
{DICT_NAME:'reiserfsprogs', DICT_CMD:'reiserfsck', DICT_CMD_INST:'reiserfsprogs'},
{DICT_NAME:'xfsprogs', DICT_CMD:'xfs_db', DICT_CMD_INST:'xfsprogs'},
{DICT_NAME:'squashfs-tools', DICT_CMD:'mksquashfs', DICT_CMD_INST:'squashfs-tools'},
{DICT_NAME:'btrfs-progs', DICT_CMD:'btrfsck', DICT_CMD_INST:'btrfs-progs'},
{DICT_NAME:'pcmciautils', DICT_CMD:'pccardctl', DICT_CMD_INST:'pccardctl'},
{DICT_NAME:'quota-tools', DICT_CMD:'quota', DICT_CMD_INST:'quota'},
{DICT_NAME:'PPP', DICT_CMD:'pppd', DICT_CMD_INST:'pppd'},
{DICT_NAME:'isdn4k-utils', DICT_CMD:'isdnctrl', DICT_CMD_INST:'isdnutils-base'},
{DICT_NAME:'nfs-utils', DICT_CMD:'showmount', DICT_CMD_INST:'nfs-common'},
{DICT_NAME:'procps', DICT_CMD:'ps', DICT_CMD_INST:'procps'},
{DICT_NAME:'oprofile', DICT_CMD:'oprofiled', DICT_CMD_INST:'oprofile'},
{DICT_NAME:'udev', DICT_CMD:'udevd', DICT_CMD_INST:'udev'},
{DICT_NAME:'grub', DICT_CMD:'grub', DICT_CMD_INST:'grub-pc'},
{DICT_NAME:'mcelog', DICT_CMD:'mcelog', DICT_CMD_INST:'mcelog'},
{DICT_NAME:'iptables', DICT_CMD:'iptables', DICT_CMD_INST:'iptables'},
{DICT_NAME:'openssl & libcrypto', DICT_CMD:'openssl', DICT_CMD_INST:'openssl'},
{DICT_NAME:'bc', DICT_CMD:'bc', DICT_CMD_INST:'bc'},
{DICT_NAME:'Sphinx', DICT_CMD:'sphinx', DICT_CMD_INST:'python-sphinx'} ]
ret = subprocess.call(APT_UPDATE, shell=True)
# Check and install the list of software available in the software_name
for name in dict_list_software:
install_software(name)
# Package installed due to kernal compilation error
# sign-file.c:25:30: fatal error: openssl/opensslv.h: No such file or directorycompilation terminated.
# for install libssl-dev
dict_list_soft_cmp_err = [ {DICT_NAME:'OpenSSL Dev pkg', DICT_CMD:'libssl-dev', DICT_CMD_INST:'libssl-dev'} ]
for name in dict_list_soft_cmp_err:
install_software(name)
result_tablular()
if __name__ == "__main__":
main()
No comments:
Post a Comment