Commit a526e777 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

updated. rocko - py 3.5.2, jethro - py 2.7.12

parent 5127c1fa
...@@ -33,21 +33,24 @@ python do_target_scp () { ...@@ -33,21 +33,24 @@ python do_target_scp () {
# hardcodign for now # hardcodign for now
MMC2 = "/dev/mmcblk0p2" MMC2 = "/dev/mmcblk0p2"
MMC2MNT = "/mnt/mmc2" MMC2MNT = "/mnt/mmc2"
#cmd = "tar -czvf "+WORKDIR+"/image.tar.gz -C "+WORKDIR+"/image ." #cmd = "tar -czvf "+WORKDIR+"/image.tar.gz -C "+WORKDIR+"/image ."
#print("cmd: "+cmd) #print("cmd: "+cmd)
#subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) #subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
cmd = "ping "+REMOTE_IP+" -c 1" cmd = "ping "+REMOTE_IP+" -c 1"
print("cmd: "+cmd) print("cmd: "+cmd)
try: try:
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) subprocess.run(cmd,stderr=subprocess.STDOUT,shell=True)
except subprocess.CalledProcessError: except subprocess.CalledProcessError as e:
print("MOST EPIC FAIL 1: "+str(e.output))
print("MOST EPIC FAIL 2: "+str(e.cmd))
raise Exception("No route to target "+REMOTE_IP) raise Exception("No route to target "+REMOTE_IP)
nandboot = command_over_ssh(d,"'if [ -d /tmp/rootfs.ro ]; then echo 1; else echo 0;fi'") nandboot = command_over_ssh(d,"'if [ -d /tmp/rootfs.ro ]; then echo 1; else echo 0;fi'")
if COPY_TO_NAND=='1': if COPY_TO_NAND=='1':
print("Copy to NAND") print("Copy to NAND")
...@@ -56,7 +59,7 @@ python do_target_scp () { ...@@ -56,7 +59,7 @@ python do_target_scp () {
#copy archive #copy archive
cmd = "scp -i "+IDENTITY_FILE+" -p "+WORKDIR+"/image.tar.gz "+REMOTE_USER+"@"+REMOTE_IP+":/" cmd = "scp -i "+IDENTITY_FILE+" -p "+WORKDIR+"/image.tar.gz "+REMOTE_USER+"@"+REMOTE_IP+":/"
print("cmd: "+cmd) print("cmd: "+cmd)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) subprocess.run(cmd,stderr=subprocess.STDOUT,shell=True)
#unpack archive to / #unpack archive to /
command_over_ssh(d,"'tar -C / -xzpf /image.tar.gz; sync'") command_over_ssh(d,"'tar -C / -xzpf /image.tar.gz; sync'")
#unpack archive to /tmp/rootfs.ro #unpack archive to /tmp/rootfs.ro
...@@ -64,16 +67,16 @@ python do_target_scp () { ...@@ -64,16 +67,16 @@ python do_target_scp () {
else: else:
raise Exception("\033[1;37mPlease, reboot from NAND\033[0m") raise Exception("\033[1;37mPlease, reboot from NAND\033[0m")
else: else:
if nandboot=="1": if nandboot=="1":
print("Copy to MMC while booted from NAND") print("Copy to MMC while booted from NAND")
mmc2 = command_over_ssh(d,"'if [ -b "+MMC2+" ]; then echo 1; else echo 0;fi'") mmc2 = command_over_ssh(d,"'if [ -b "+MMC2+" ]; then echo 1; else echo 0;fi'")
if mmc2=="1": if mmc2=="1":
# nobody likes empty output # nobody likes empty output
mmc2_mnt = command_over_ssh(d,"'TEST=`df -h | grep "+MMC2+"`;echo \"0\"$TEST'") mmc2_mnt = command_over_ssh(d,"'TEST=`df -h | grep "+MMC2+"`;echo \"0\"$TEST'")
if mmc2_mnt!="0": if mmc2_mnt!="0":
tmp = mmc2_mnt.split() tmp = mmc2_mnt.split()
mountpoint = tmp[5] mountpoint = tmp[5]
...@@ -82,32 +85,32 @@ python do_target_scp () { ...@@ -82,32 +85,32 @@ python do_target_scp () {
command_over_ssh(d,"'mkdir "+MMC2MNT+"; mount "+MMC2+" "+MMC2MNT+"'") command_over_ssh(d,"'mkdir "+MMC2MNT+"; mount "+MMC2+" "+MMC2MNT+"'")
mountpoint = MMC2MNT mountpoint = MMC2MNT
print("Created and mounted "+MMC2+" to "+mountpoint) print("Created and mounted "+MMC2+" to "+mountpoint)
#copy archive #copy archive
print("Copy archive") print("Copy archive")
cmd = "scp -i "+IDENTITY_FILE+" -p "+WORKDIR+"/image.tar.gz "+REMOTE_USER+"@"+REMOTE_IP+":/" cmd = "scp -i "+IDENTITY_FILE+" -p "+WORKDIR+"/image.tar.gz "+REMOTE_USER+"@"+REMOTE_IP+":/"
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) subprocess.run(cmd,stderr=subprocess.STDOUT,shell=True)
#unpack archive to mountpoint #unpack archive to mountpoint
print("Unpack archive then delete") print("Unpack archive then delete")
command_over_ssh(d,"'tar -C "+mountpoint+" -xzpf /image.tar.gz; rm -f /image.tar.gz; sync'") command_over_ssh(d,"'tar -C "+mountpoint+" -xzpf /image.tar.gz; rm -f /image.tar.gz; sync'")
else: else:
raise Exception("\033[1;37mMMC rootfs partition "+MMC2+" not found.\033[0m") raise Exception("\033[1;37mMMC rootfs partition "+MMC2+" not found.\033[0m")
else: else:
print("Copy to MMC while booted from MMC") print("Copy to MMC while booted from MMC")
#copy archive #copy archive
cmd = "scp -i "+IDENTITY_FILE+" -p "+WORKDIR+"/image.tar.gz "+REMOTE_USER+"@"+REMOTE_IP+":/" cmd = "scp -i "+IDENTITY_FILE+" -p "+WORKDIR+"/image.tar.gz "+REMOTE_USER+"@"+REMOTE_IP+":/"
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) subprocess.run(cmd,stderr=subprocess.STDOUT,shell=True)
#unpack archive to / #unpack archive to /
command_over_ssh(d,"'tar -C / -xzpf /image.tar.gz; rm -f /image.tar.gz; sync'") command_over_ssh(d,"'tar -C / -xzpf /image.tar.gz; rm -f /image.tar.gz; sync'")
} }
addtask do_target_scp after do_install addtask do_target_scp after do_install
do_target_scp[doc] = "scp installed files to the target. TARGET_USER and TARGET_IP should be defined (ssh-copy-id -i KEY.pub TARGET_USER@TARGET_IP should be issued once)" do_target_scp[doc] = "scp installed files to the target. TARGET_USER and TARGET_IP should be defined (ssh-copy-id -i KEY.pub TARGET_USER@TARGET_IP should be issued once)"
...@@ -121,4 +124,4 @@ do_target_scp[doc] = "scp installed files to the target. TARGET_USER and TARGET_ ...@@ -121,4 +124,4 @@ do_target_scp[doc] = "scp installed files to the target. TARGET_USER and TARGET_
# echo "REMOTE_USER=${REMOTE_USER}" # echo "REMOTE_USER=${REMOTE_USER}"
# echo "REMOTE_IP=${REMOTE_IP}" # echo "REMOTE_IP=${REMOTE_IP}"
# echo "DESTDIR=${D}" # echo "DESTDIR=${D}"
#scp -pr image/* root@192.168.0.9:/ #scp -pr image/* root@192.168.0.9:/
...@@ -8,8 +8,9 @@ def command_over_ssh(d,command): ...@@ -8,8 +8,9 @@ def command_over_ssh(d,command):
cmd = "ssh -i "+id+" "+user+"@"+ip+" "+command cmd = "ssh -i "+id+" "+user+"@"+ip+" "+command
print("cmd: "+cmd) print("cmd: "+cmd)
try: try:
ret = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) ret = subprocess.run(cmd,stderr=subprocess.STDOUT,shell=True)
except subprocess.CalledProcessError: except subprocess.CalledProcessError as e:
print("Error code: "+e.returncode)
raise Exception("Copying to target requires access by public key. Run: \033[1;37mssh-copy-id "+REMOTE_USER+"@"+REMOTE_IP+"\033[0m") raise Exception("Copying to target requires access by public key. Run: \033[1;37mssh-copy-id "+REMOTE_USER+"@"+REMOTE_IP+"\033[0m")
return ret.strip() return str(ret).strip()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment