Commit 1603777c authored by Mick Michalski's avatar Mick Michalski
Browse files

Merge branch 'Micks-test' into 'master'

Micks test

Merging in

See merge request !1
parents e790c224 ddc46092
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int setBuffer(char *buffer, int pos, int value){
if(buffer[pos] == value) return 0;
buffer[pos] = value;
return 1;
}
int main(void) {
char *devSettings = getenv("DEVICE_SETTINGS");
char buffer[128];
/* Get the current boot settings */
FILE *f = fopen(devSettings, "r");
fread(buffer, 1, 4, f); /* read 4 bytes (4 * 1) from f */
fclose(f);
int doUpdate = 0;
/* Set the boot partition to the opposite of the current partition */
if(buffer[3] == '0') doUpdate += setBuffer(buffer, 1, '1');
else doUpdate += setBuffer(buffer, 1, '0');
if(doUpdate){
/* Create a temp file */
char tempFile[64];
strcpy(tempFile, "/tmp/swu-postinst-fs.XXXXXX");
int fd = mkstemp(tempFile);
write(fd, buffer, 4);
/* Write temp file to mtd0, then delete temp file */
snprintf(buffer, 127, "flashcp %s %s", tempFile, devSettings);
system(buffer);
unlink(tempFile); /* automatically close and delete when done */
}
return 0;
}
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int setBuffer(char *buffer, int pos, int value){
if(buffer[pos] == value) return 0;
buffer[pos] = value;
return 1;
}
int main(void) {
char *devSettings = getenv("DEVICE_SETTINGS");
char buffer[128];
/* Get the current boot settings */
FILE *f = fopen(devSettings, "r");
fread(buffer, 1, 4, f); /* read 4 bytes (4 * 1) from f */
fclose(f);
int doUpdate = 0;
/* Set the boot partition to the opposite of the current partition */
if(buffer[2] == '0') doUpdate += setBuffer(buffer, 0, '1');
else doUpdate += setBuffer(buffer, 0, '0');
if(doUpdate){
/* Create a temp file */
char tempFile[64];
strcpy(tempFile, "/tmp/swu-postinst-k.XXXXXX");
int fd = mkstemp(tempFile);
write(fd, buffer, 4);
/* Write temp file to mtd0, then delete temp file */
snprintf(buffer, 127, "flashcp %s %s", tempFile, devSettings);
system(buffer);
unlink(tempFile); /* automatically close and delete when done */
}
return 0;
}
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
extern char **environ;
int main(void) {
char *devSettings = getenv("DEVICE_SETTINGS");
char *devFsMain = getenv("DEVICE_FILESYSTEM_MAIN");
char *devFsAlt = getenv("DEVICE_FILESYSTEM_ALT");
char *devKMain = getenv("DEVICE_KERNEL_MAIN");
char *devKAlt = getenv("DEVICE_KERNEL_ALT");
if(!devSettings) {
printf("No settings found");
return 1;
}
char buffer[5];
int doUpdate=0;
/* Get the current boot settings */
FILE *f = fopen(devSettings, "r");
fread(buffer, 1, 4, f); /* read 4 bytes (4 * 1) from f */
fclose(f);
/* Set the current boot partitions */
if(buffer[2] != buffer[0]){
buffer[2] = buffer[0];
doUpdate = 1;
}
if(buffer[3] != buffer[1]){
buffer[3] = buffer[1];
doUpdate = 1;
}
char cmd[128];
if(doUpdate){
printf("Updating device settings with new boot partitions\n");
/* Create a temp file */
char tempFile[64];
strcpy(tempFile, "/tmp/swu-prepost-boot.XXXXXX");
int fd = mkstemp(tempFile);
write(fd, buffer, 4);
/* Write temp file to mtd0, then delete temp file */
snprintf(cmd, 127, "flashcp %s %s", tempFile, devSettings);
system(cmd);
unlink(tempFile); /* automatically close and delete when done */
} else {
printf("Device settings unchanged\n");
}
if(buffer[3] == '0'){ /* The current filesystem */
snprintf(cmd, 127, "ln -sf %s /dev/dev-fs", devFsAlt);
system(cmd); /* Create a new link to alt fs partition */
} else {
snprintf(cmd, 127, "ln -sf %s /dev/dev-fs", devFsMain);
system(cmd); /* Create a new link to main fs partition */
}
if(buffer[2] == '0'){ /* The current filesystem */
snprintf(cmd, 127, "ln -sf %s /dev/dev-k", devKAlt);
system(cmd); /* Create a new link to alt kernel partition */
} else {
snprintf(cmd, 127, "ln -sf %s /dev/dev-k", devKMain);
system(cmd); /* Create a new link to main kernel partition */
}
return 0;
}
export SURICATTA_TENANT="default"
export SURICATTA_URL="https://ops.rigado.com"
export SURICATTA_ID="test-vista-"$(echo "$(cat /sys/fsl_otp/HW_OCOTP_GP36)" | cut -c 3-)
export DEVICE_SETTINGS="/dev/mtd0"
export DEVICE_KERNEL_MAIN="/dev/mtd1"
export DEVICE_KERNEL_ALT="/dev/mtd2"
export DEVICE_FILESYSTEM_MAIN="/dev/mmcblk1p2"
export DEVICE_FILESYSTEM_ALT="/dev/mmcblk1p3"
source /etc/gateway.conf
/usr/bin/swupdate-prepost-boot
......@@ -900,11 +900,13 @@ server_op_res_t server_install_update(void)
}
}
/*
if ((result = save_state((char *)STATE_KEY, STATE_INSTALLED)) !=
SERVER_OK) {
ERROR("Cannot persistently store update state.\n");
goto cleanup;
}
*/
if (server_send_deployment_reply(
action_id, json_data_chunk_max, json_data_chunk_count,
......@@ -914,6 +916,14 @@ server_op_res_t server_install_update(void)
ERROR("Error while reporting installation success to "
"server.\n");
}
if (server_send_deployment_reply(
action_id, 0, 0, reply_status_result_finished.success,
reply_status_execution.closed,
(const char *)"Skipped Update.") != SERVER_OK) {
ERROR("Error while reporting installation progress to "
"server.\n");
}
cleanup:
if (channel_data.json_reply != NULL &&
......
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