def buildKernel(): os.chdir(getScriptDir()) loadSettings() # Install dependencies (Ubuntu needs u-boot-tools, Debian needs uboot-mkimage) ensureDependencies( ['gcc-arm-linux-gnueabi', 'u-boot-tools', 'device-tree-compiler']) # Clone the linux kernel source tree print('Cloning the Linux kernel source tree') linuxDirName = gitCloneAndEnter( 'git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git', 'master') os.chdir('..') # Clone RCN's git repository print('Building kernel') gitCloneAndEnter('git://github.com/RobertCNelson/stable-kernel.git', '4d82ccd1b2093') # Configure the kernel build script shutil.copyfile('system.sh.sample', 'system.sh') # Overwrites existing file file = open('system.sh', 'a') # Open for appending file.write('LINUX_GIT=' + os.path.join(os.path.realpath('..'), linuxDirName) + '\n') file.write('ZRELADDR=0x80008000' + '\n') # For TI: OMAP3/4/AM35xx (BB is OMAP3) #file.write('BUILD_UIMAGE=1' + '\n') # Do I need to build uImage? file.write('MMC=' + getSetting('mmc') + '\n') # Pull in Torvalds current master tree before applying local patchset # This is very useful during an intial 'rc0' merge. # It is never supported... Enable at your own risk #file.write('LATEST_GIT=1' + '\n') file.write( 'LOCAL_PATCH_DIR=' + os.path.join(os.path.realpath('..'), 'patches', 'stable-kernel') + '\n') file.close() # Adding the CC parameter is a little more complex... we need to seek out # the config line and uncomment it. replaceAll('system.sh', '#CC=arm-linux-gnueabi-', 'CC=arm-linux-gnueabi-') # Build the kernel subprocess.call(['./build_deb.sh']) os.chdir('..')
def api(): if request.method == 'POST' and len(request.form['replace']) > 0 : stringToReplace = request.form['replace'] result = { "data": { "Provided String" : stringToReplace, "Replaced String" : common.replaceAll(stringToReplace) } } mylist = f"{result}" return (render_template('output.html',output=result),result) else: return redirect(url_for('home'))
def buildKernel(): os.chdir(getScriptDir()) loadSettings() # Install dependencies (Ubuntu needs u-boot-tools, Debian needs uboot-mkimage) ensureDependencies(["gcc-arm-linux-gnueabi", "u-boot-tools", "device-tree-compiler"]) # Clone the linux kernel source tree print("Cloning the Linux kernel source tree") linuxDirName = gitCloneAndEnter("git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git", "master") os.chdir("..") # Clone RCN's git repository print("Building kernel") gitCloneAndEnter("git://github.com/RobertCNelson/stable-kernel.git", "4d82ccd1b2093") # Configure the kernel build script shutil.copyfile("system.sh.sample", "system.sh") # Overwrites existing file file = open("system.sh", "a") # Open for appending file.write("LINUX_GIT=" + os.path.join(os.path.realpath(".."), linuxDirName) + "\n") file.write("ZRELADDR=0x80008000" + "\n") # For TI: OMAP3/4/AM35xx (BB is OMAP3) # file.write('BUILD_UIMAGE=1' + '\n') # Do I need to build uImage? file.write("MMC=" + getSetting("mmc") + "\n") # Pull in Torvalds current master tree before applying local patchset # This is very useful during an intial 'rc0' merge. # It is never supported... Enable at your own risk # file.write('LATEST_GIT=1' + '\n') file.write("LOCAL_PATCH_DIR=" + os.path.join(os.path.realpath(".."), "patches", "stable-kernel") + "\n") file.close() # Adding the CC parameter is a little more complex... we need to seek out # the config line and uncomment it. replaceAll("system.sh", "#CC=arm-linux-gnueabi-", "CC=arm-linux-gnueabi-") # Build the kernel subprocess.call(["./build_deb.sh"]) os.chdir("..")
def buildImage(): os.chdir(getScriptDir()) loadSettings() # Look for a kernel image imgpath = False # Discovered image goes here for path in ['images', os.path.join('stable-kernel', 'deploy')]: if not os.path.exists(path): continue files = sorted(os.listdir(path), reverse=True) for f in files: if f.endswith('.deb') and 'image' in f: imgpath = os.path.realpath(os.path.join(path, f)) print('Found kernel image: ' + imgpath) print('rootstock will use this local image instead of http://rcn-ee.net') break if imgpath: break # Clone RCN's git repository print('Building Ubuntu image') gitCloneAndEnter('git://github.com/RobertCNelson/omap-image-builder.git', '73e92f5cef5d3') #subprocess.call(['git', 'reset', '--hard', 'HEAD']) patches = [ '0001-Only-build-Precise-image.patch', '0002-Include-additional-packages-specified-in-settings.xm.patch', '0003-Force-MAC-address.patch', '0004-Remove-text-from-etc-flash-kernel.conf.patch', '0005-Copy-keys-to-the-new-filesystem.patch'] if imgpath: patches.append('0006-Primary-kernel-is-on-local-filesystem.patch') if False: patches.append('0007-Run-script-to-install-ros.patch') for p in patches: subprocess.call(['git', 'am', os.path.join(getScriptDir(), 'patches', 'omap-image-builder', p)]) #subprocess.call(['git', 'checkout', 'v2012.4-1', '-b', 'v2012.4-1']) # Configure image builder replaceAll('build_image.sh', 'FQDN="arm"', 'FQDN="' + getSetting('fqdn') + '"') replaceAll('build_image.sh', 'USER_LOGIN="******"', 'USER_LOGIN="******"') replaceAll('build_image.sh', 'USER_PASS="******"', 'USER_PASS="******"') replaceAll('build_image.sh', 'USER_NAME="Demo User"', 'USER_NAME="' + getSetting('name') + '"') replaceAll('var/pkg_list.sh', '__MECANUM_PACKAGES__', ','.join(getSetting('packages'))) if imgpath: # Kernel image, e.g. linux-image-3.2.18-x12_1.0precise_armhf.deb replaceAll('build_image.sh', '__KERNEL_DEB_FILE__', imgpath) replaceAll('tools/fixup.sh', 'DE:AD:BE:EF:CA:FE', getSetting('macaddress')) # Attempt to copy our ssh keys to the new filesystem try: id_rsa = open(getScriptDir() + '../../ssh_keys/id_rsa', 'r') rsa_private = id_rsa.read() id_rsa.close() id_rsa_pub = open(getScriptDir() + '../../ssh_keys/id_rsa.pub', 'r') rsa_public = id_rsa_pub.read() id_rsa_pub.close() if (len(rsa_private) and len(rsa_public)): replaceAll('tools/fixup.sh', '#USER_NAME=__USER_NAME__', 'USER_NAME="' + getSetting('username') + '"') replaceAll('tools/fixup.sh', '__RSA_PRIVATE__', rsa_private) replaceAll('tools/fixup.sh', '__RSA_PUBLIC__', rsa_public) except: pass # Build the image subprocess.call(['./build_image.sh']) os.chdir('..')
def test_Google(self): self.assertEqual(common.replaceAll("Google"),"Google©")
def test_Oracle(self): self.assertEqual(common.replaceAll("Oracle"),"Oracle©")
def test_Google_Special(self): result = common.replaceAll("Google, has seen Google. and Oracle is now with Google and is now Google's GoogleTrademark") self.assertEqual(result,"Google©, has seen Google©. and Oracle© is now with Google© and is now Google©'s GoogleTrademark")
def test_GoogleTrademark(self): result = common.replaceAll("This is Google and it have a GoogleTrademark") self.assertEqual(result,"This is Google© and it have a GoogleTrademark")
def test_All_combine(self): self.assertEqual(common.replaceAll("Oracle Google Microsoft Amazon Deloitte"), "Oracle© Google© Microsoft© Amazon© Deloitte©")
def test_Oracle_And_Google_Together(self): self.assertEqual(common.replaceAll("Oracle and Google"),"Oracle© and Google©")
def buildImage(): os.chdir(getScriptDir()) loadSettings() # Look for a kernel image imgpath = False # Discovered image goes here for path in ['images', os.path.join('stable-kernel', 'deploy')]: if not os.path.exists(path): continue files = sorted(os.listdir(path), reverse=True) for f in files: if f.endswith('.deb') and 'image' in f: imgpath = os.path.realpath(os.path.join(path, f)) print('Found kernel image: ' + imgpath) print( 'rootstock will use this local image instead of http://rcn-ee.net' ) break if imgpath: break # Clone RCN's git repository print('Building Ubuntu image') gitCloneAndEnter('git://github.com/RobertCNelson/omap-image-builder.git', '73e92f5cef5d3') #subprocess.call(['git', 'reset', '--hard', 'HEAD']) patches = [ '0001-Only-build-Precise-image.patch', '0002-Include-additional-packages-specified-in-settings.xm.patch', '0003-Force-MAC-address.patch', '0004-Remove-text-from-etc-flash-kernel.conf.patch', '0005-Copy-keys-to-the-new-filesystem.patch' ] if imgpath: patches.append('0006-Primary-kernel-is-on-local-filesystem.patch') if False: patches.append('0007-Run-script-to-install-ros.patch') for p in patches: subprocess.call([ 'git', 'am', os.path.join(getScriptDir(), 'patches', 'omap-image-builder', p) ]) #subprocess.call(['git', 'checkout', 'v2012.4-1', '-b', 'v2012.4-1']) # Configure image builder replaceAll('build_image.sh', 'FQDN="arm"', 'FQDN="' + getSetting('fqdn') + '"') replaceAll('build_image.sh', 'USER_LOGIN="******"', 'USER_LOGIN="******"') replaceAll('build_image.sh', 'USER_PASS="******"', 'USER_PASS="******"') replaceAll('build_image.sh', 'USER_NAME="Demo User"', 'USER_NAME="' + getSetting('name') + '"') replaceAll('var/pkg_list.sh', '__MECANUM_PACKAGES__', ','.join(getSetting('packages'))) if imgpath: # Kernel image, e.g. linux-image-3.2.18-x12_1.0precise_armhf.deb replaceAll('build_image.sh', '__KERNEL_DEB_FILE__', imgpath) replaceAll('tools/fixup.sh', 'DE:AD:BE:EF:CA:FE', getSetting('macaddress')) # Attempt to copy our ssh keys to the new filesystem try: id_rsa = open(getScriptDir() + '../../ssh_keys/id_rsa', 'r') rsa_private = id_rsa.read() id_rsa.close() id_rsa_pub = open(getScriptDir() + '../../ssh_keys/id_rsa.pub', 'r') rsa_public = id_rsa_pub.read() id_rsa_pub.close() if (len(rsa_private) and len(rsa_public)): replaceAll('tools/fixup.sh', '#USER_NAME=__USER_NAME__', 'USER_NAME="' + getSetting('username') + '"') replaceAll('tools/fixup.sh', '__RSA_PRIVATE__', rsa_private) replaceAll('tools/fixup.sh', '__RSA_PUBLIC__', rsa_public) except: pass # Build the image subprocess.call(['./build_image.sh']) os.chdir('..')