mirror of
https://github.com/clearlinux/swupd-server.git
synced 2026-10-04 16:08:29 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d4df7e035 | ||
|
|
4df4bf14c3 | ||
|
|
6affbd1ecb | ||
|
|
77a0bcd9f9 | ||
|
|
bf19e48917 | ||
|
|
d45304c8b7 | ||
|
|
2b4e9eb3c9 | ||
|
|
b6bd8bf73b | ||
|
|
94240130be | ||
|
|
ae299e2126 | ||
|
|
64e65bca92 | ||
|
|
e78ef77e06 | ||
|
|
a329cc93a9 | ||
|
|
bd002877c1 | ||
|
|
cb2706fb72 | ||
|
|
383ab112db | ||
|
|
af7767a768 | ||
|
|
b954d924f4 | ||
|
|
e0049de3dc | ||
|
|
2a9af990d6 | ||
|
|
90c976fdaf | ||
|
|
3b43313c9e | ||
|
|
3d8b81fbcd | ||
|
|
9b05b06a9b | ||
|
|
1cd3cdb96f | ||
|
|
9c920d65e8 | ||
|
|
825dc6c75f | ||
|
|
4fb32c570f | ||
|
|
79e8a12b75 | ||
|
|
9b8b1d5359 | ||
|
|
df7b2adc9d | ||
|
|
0dcad76694 | ||
|
|
24ef47f40c | ||
|
|
0a41a7e2d5 | ||
|
|
51c0bf2007 | ||
|
|
f27d0cf03a | ||
|
|
08fb540678 | ||
|
|
2355295023 | ||
|
|
1aed8c3d4d |
+5
-4
@@ -19,16 +19,17 @@ stamp-h1
|
|||||||
DEADJOE
|
DEADJOE
|
||||||
swupd_create_update
|
swupd_create_update
|
||||||
swupd_make_pack
|
swupd_make_pack
|
||||||
swupd-update-server.log*
|
|
||||||
swupd_make_fullfiles
|
swupd_make_fullfiles
|
||||||
swupd-server-*.tar.gz
|
swupd-server-*.tar.gz
|
||||||
swupd-server.log.*
|
|
||||||
cscope.*
|
cscope.*
|
||||||
*.kdev4
|
*.kdev4
|
||||||
coverage/
|
coverage/
|
||||||
src/*.gcno
|
src/*.gcno
|
||||||
src/*.gcda
|
src/*.gcda
|
||||||
tap-driver.sh
|
tap-driver.sh
|
||||||
test/functional/*.log
|
test/functional/*/*.log
|
||||||
test/functional/*.trs
|
test/functional/*/*.trs
|
||||||
|
test/functional/*/logs/
|
||||||
|
test/functional/*/web-dir/
|
||||||
|
swupd-*.log
|
||||||
test-suite.log
|
test-suite.log
|
||||||
|
|||||||
+12
-9
@@ -15,6 +15,7 @@ swupd_create_update_SOURCES = \
|
|||||||
src/analyze_fs.c \
|
src/analyze_fs.c \
|
||||||
src/chroot.c \
|
src/chroot.c \
|
||||||
src/config.c \
|
src/config.c \
|
||||||
|
src/create_update.c \
|
||||||
src/delta.c \
|
src/delta.c \
|
||||||
src/fullfiles.c \
|
src/fullfiles.c \
|
||||||
src/globals.c \
|
src/globals.c \
|
||||||
@@ -22,7 +23,6 @@ swupd_create_update_SOURCES = \
|
|||||||
src/helpers.c \
|
src/helpers.c \
|
||||||
src/heuristics.c \
|
src/heuristics.c \
|
||||||
src/log.c \
|
src/log.c \
|
||||||
src/main.c \
|
|
||||||
src/manifest.c \
|
src/manifest.c \
|
||||||
src/pack.c \
|
src/pack.c \
|
||||||
src/rename.c \
|
src/rename.c \
|
||||||
@@ -96,24 +96,27 @@ noinst_HEADERS = \
|
|||||||
include/swupd.h \
|
include/swupd.h \
|
||||||
include/xattrs.h
|
include/xattrs.h
|
||||||
|
|
||||||
TEST_EXTENSIONS = .sh
|
TEST_EXTENSIONS = .bats
|
||||||
|
|
||||||
if ENABLE_TESTS
|
if ENABLE_TESTS
|
||||||
tap_driver = env AM_TAP_AWK='$(AWK)' $(SHELL) \
|
tap_driver = env AM_TAP_AWK='$(AWK)' $(SHELL) \
|
||||||
$(top_srcdir)/tap-driver.sh
|
$(top_srcdir)/tap-driver.sh
|
||||||
|
|
||||||
LOG_DRIVER = $(tap_driver)
|
LOG_DRIVER = $(tap_driver)
|
||||||
SH_LOG_DRIVER = $(tap_driver)
|
BATS_LOG_DRIVER = $(tap_driver)
|
||||||
|
|
||||||
TESTS = $(dist_check_SCRIPTS)
|
TESTS = $(dist_check_SCRIPTS)
|
||||||
|
|
||||||
dist_check_SCRIPTS = \
|
dist_check_SCRIPTS = \
|
||||||
test/functional/basic.bats \
|
test/functional/basic/test.bats \
|
||||||
test/functional/update.bats \
|
test/functional/delete-no-version-bump/test.bats \
|
||||||
test/functional/fullfiles.bats \
|
test/functional/include-version-bump/test.bats \
|
||||||
test/functional/pack.bats \
|
test/functional/update/test.bats \
|
||||||
test/functional/full-run.bats \
|
test/functional/fullfiles/test.bats \
|
||||||
test/functional/full-run-delta.bats
|
test/functional/pack/test.bats \
|
||||||
|
test/functional/full-run/test.bats \
|
||||||
|
test/functional/full-run-delta/test.bats \
|
||||||
|
test/functional/file-name-blacklisted/test.bats
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if COVERAGE
|
if COVERAGE
|
||||||
|
|||||||
+1
-5
@@ -23,11 +23,9 @@ export LEAF_CERT="leaf.cert.pem"
|
|||||||
export CA_CHAIN_CERT="ca-chain.cert.pem"
|
export CA_CHAIN_CERT="ca-chain.cert.pem"
|
||||||
export PASSPHRASE="${SWUPD_CERTS_DIR}/passphrase"
|
export PASSPHRASE="${SWUPD_CERTS_DIR}/passphrase"
|
||||||
|
|
||||||
${SWUPDREPO}/swupd_create_update --osversion ${VER} --statedir ${UPDATEDIR}
|
${SWUPDREPO}/swupd_create_update --osversion ${VER} --statedir ${UPDATEDIR} --format 3
|
||||||
${SWUPDREPO}/swupd_make_fullfiles --statedir ${UPDATEDIR} ${VER}
|
${SWUPDREPO}/swupd_make_fullfiles --statedir ${UPDATEDIR} ${VER}
|
||||||
|
|
||||||
pushd ${SWUPDREPO}
|
|
||||||
|
|
||||||
# create zero packs
|
# create zero packs
|
||||||
MOM=${UPDATEDIR}/www/${VER}/Manifest.MoM
|
MOM=${UPDATEDIR}/www/${VER}/Manifest.MoM
|
||||||
if [ ! -e ${MOM} ]; then
|
if [ ! -e ${MOM} ]; then
|
||||||
@@ -51,8 +49,6 @@ done
|
|||||||
NUM_PACKS=2
|
NUM_PACKS=2
|
||||||
${SWUPDREPO}/pack_maker.sh ${VER} ${NUM_PACKS}
|
${SWUPDREPO}/pack_maker.sh ${VER} ${NUM_PACKS}
|
||||||
|
|
||||||
popd
|
|
||||||
|
|
||||||
# expose the new build to staging / testing
|
# expose the new build to staging / testing
|
||||||
echo ${VER} > ${UPDATEDIR}/image/latest.version
|
echo ${VER} > ${UPDATEDIR}/image/latest.version
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ([2.66])
|
AC_PREREQ([2.66])
|
||||||
AC_INIT(swupd-server, 3.1.0, timothy.c.pepper@linux.intel.com)
|
AC_INIT(swupd-server, 3.2.3, timothy.c.pepper@linux.intel.com)
|
||||||
AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
|
AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
|||||||
+10
-5
@@ -13,7 +13,6 @@
|
|||||||
// SWUPD_NUM_PACKS is also "PREV_CHECK" in releas tool swupd_bb.py (change both)
|
// SWUPD_NUM_PACKS is also "PREV_CHECK" in releas tool swupd_bb.py (change both)
|
||||||
#define SWUPD_NUM_PACKS 4
|
#define SWUPD_NUM_PACKS 4
|
||||||
#define SWUPD_NUM_MANIFEST_DELTAS 25
|
#define SWUPD_NUM_MANIFEST_DELTAS 25
|
||||||
#define SWUPD_DEFAULT_FORMAT 3
|
|
||||||
|
|
||||||
#define SWUPD_SERVER_STATE_DIR "/var/lib/update"
|
#define SWUPD_SERVER_STATE_DIR "/var/lib/update"
|
||||||
|
|
||||||
@@ -61,6 +60,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct manifest {
|
struct manifest {
|
||||||
|
unsigned long long int format;
|
||||||
int version;
|
int version;
|
||||||
int prevversion;
|
int prevversion;
|
||||||
char *component;
|
char *component;
|
||||||
@@ -70,6 +70,8 @@ struct manifest {
|
|||||||
GList *manifests; /* as struct file */
|
GList *manifests; /* as struct file */
|
||||||
|
|
||||||
GList *submanifests; /* as struct manifest */
|
GList *submanifests; /* as struct manifest */
|
||||||
|
|
||||||
|
GList *includes; /* struct manifests for all bundles included into this one */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct file;
|
struct file;
|
||||||
@@ -134,7 +136,7 @@ struct packdata {
|
|||||||
extern int current_version;
|
extern int current_version;
|
||||||
extern int newversion;
|
extern int newversion;
|
||||||
extern int minversion;
|
extern int minversion;
|
||||||
extern char *format_string;
|
extern unsigned long long int format;
|
||||||
extern bool enable_signing;
|
extern bool enable_signing;
|
||||||
|
|
||||||
extern char *state_dir;
|
extern char *state_dir;
|
||||||
@@ -144,7 +146,7 @@ extern char *staging_dir;
|
|||||||
|
|
||||||
extern bool init_globals(void);
|
extern bool init_globals(void);
|
||||||
extern void free_globals(void);
|
extern void free_globals(void);
|
||||||
extern bool set_format_string(char *);
|
extern bool set_format(char *);
|
||||||
extern void check_root(void);
|
extern void check_root(void);
|
||||||
extern bool set_state_dir(char *);
|
extern bool set_state_dir(char *);
|
||||||
extern bool init_state_globals(void);
|
extern bool init_state_globals(void);
|
||||||
@@ -173,10 +175,13 @@ extern void free_manifest(struct manifest *manifest);
|
|||||||
extern struct manifest *alloc_manifest(int version, char *module);
|
extern struct manifest *alloc_manifest(int version, char *module);
|
||||||
extern int match_manifests(struct manifest *m1, struct manifest *m2);
|
extern int match_manifests(struct manifest *m1, struct manifest *m2);
|
||||||
extern void sort_manifest_by_version(struct manifest *manifest);
|
extern void sort_manifest_by_version(struct manifest *manifest);
|
||||||
|
extern bool manifest_includes(struct manifest *manifest, char *component);
|
||||||
|
extern bool changed_includes(struct manifest *old, struct manifest *new);
|
||||||
extern int prune_manifest(struct manifest *manifest);
|
extern int prune_manifest(struct manifest *manifest);
|
||||||
|
extern int remove_old_deleted_files(struct manifest *m1, struct manifest *m2);
|
||||||
extern void create_manifest_delta(int oldversion, int newversion, char *module);
|
extern void create_manifest_delta(int oldversion, int newversion, char *module);
|
||||||
extern void create_manifest_deltas(struct manifest *manifest, GList *last_versions_list);
|
extern void create_manifest_deltas(struct manifest *manifest, GList *last_versions_list);
|
||||||
extern void subtract_manifests(struct manifest *m1, struct manifest *m2);
|
extern void subtract_manifests_frontend(struct manifest *m1, struct manifest *m2);
|
||||||
extern void nest_manifest(struct manifest *parent, struct manifest *sub);
|
extern void nest_manifest(struct manifest *parent, struct manifest *sub);
|
||||||
extern void nest_manifest_file(struct manifest *parent, struct file *file);
|
extern void nest_manifest_file(struct manifest *parent, struct file *file);
|
||||||
extern int manifest_subversion(struct manifest *parent, char *group);
|
extern int manifest_subversion(struct manifest *parent, char *group);
|
||||||
@@ -222,7 +227,7 @@ extern void populate_file_struct(struct file *file, char *filename);
|
|||||||
extern void download_exta_base_content(void);
|
extern void download_exta_base_content(void);
|
||||||
|
|
||||||
extern char *get_elapsed_time(struct timeval *t1, struct timeval *t2);
|
extern char *get_elapsed_time(struct timeval *t1, struct timeval *t2);
|
||||||
extern void init_log(int version);
|
extern void init_log(const char *prefix, const char *bundle, int start, int end);
|
||||||
extern void init_log_stdout(void);
|
extern void init_log_stdout(void);
|
||||||
extern void close_log(int version, int exit_status);
|
extern void close_log(int version, int exit_status);
|
||||||
extern void __log_message(struct file *file, char *msg, char *filename, int linenr, const char *fmt, ...);
|
extern void __log_message(struct file *file, char *msg, char *filename, int linenr, const char *fmt, ...);
|
||||||
|
|||||||
+74
-15
@@ -23,19 +23,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <openssl/hmac.h>
|
|
||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
|
#include <openssl/hmac.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
#include "xattrs.h"
|
#include "xattrs.h"
|
||||||
@@ -286,18 +286,15 @@ static bool illegal_characters(char *filename)
|
|||||||
// these breaks the tar transform sed-like expression,
|
// these breaks the tar transform sed-like expression,
|
||||||
// hopefully can remove this check after moving to libtar
|
// hopefully can remove this check after moving to libtar
|
||||||
if (strncmp(filename, "+", 1) == 0) {
|
if (strncmp(filename, "+", 1) == 0) {
|
||||||
printf("WARNING: Filename %s begins with '+'! ...skipping.\n", filename);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (strstr(filename, "+package+") != NULL) {
|
if (strstr(filename, "+package+") != NULL) {
|
||||||
printf("WARNING: Filename %s contains \"+package+\"! ...skipping.\n", filename);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < BAD_CHAR_COUNT; i++) {
|
for (i = 0; i < BAD_CHAR_COUNT; i++) {
|
||||||
c = bad_chars[i];
|
c = bad_chars[i];
|
||||||
if (strchr(filename, c) != NULL) {
|
if (strchr(filename, c) != NULL) {
|
||||||
printf("WARNING: Filename %s includes illegal character '%c'! ...skipping.\n", filename, c);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -323,6 +320,7 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix,
|
|||||||
|
|
||||||
while (dir) {
|
while (dir) {
|
||||||
struct file *file;
|
struct file *file;
|
||||||
|
char *sub_filename;
|
||||||
char *fullname;
|
char *fullname;
|
||||||
|
|
||||||
entry = readdir(dir);
|
entry = readdir(dir);
|
||||||
@@ -331,8 +329,15 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((strcmp(entry->d_name, ".") == 0) ||
|
if ((strcmp(entry->d_name, ".") == 0) ||
|
||||||
(strcmp(entry->d_name, "..") == 0) ||
|
(strcmp(entry->d_name, "..") == 0)) {
|
||||||
(illegal_characters(entry->d_name))) {
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
string_or_die(&sub_filename, "%s/%s", subpath, entry->d_name);
|
||||||
|
|
||||||
|
if (illegal_characters(entry->d_name)) {
|
||||||
|
printf("WARNING: Filename %s includes illegal character(s) ...skipping.\n", sub_filename);
|
||||||
|
free(sub_filename);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +347,7 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix,
|
|||||||
}
|
}
|
||||||
|
|
||||||
file->last_change = manifest->version;
|
file->last_change = manifest->version;
|
||||||
string_or_die(&file->filename, "%s/%s", subpath, entry->d_name);
|
file->filename = sub_filename;
|
||||||
|
|
||||||
string_or_die(&fullname, "%s/%s", fullpath, entry->d_name);
|
string_or_die(&fullname, "%s/%s", fullpath, entry->d_name);
|
||||||
populate_file_struct(file, fullname);
|
populate_file_struct(file, fullname);
|
||||||
@@ -402,6 +407,58 @@ struct manifest *full_manifest_from_directory(int version)
|
|||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Read includes from $manifest-includes file */
|
||||||
|
GList *get_sub_manifest_includes(char *component, int version)
|
||||||
|
{
|
||||||
|
FILE *infile;
|
||||||
|
GList *includes = NULL;
|
||||||
|
char *c;
|
||||||
|
char *conf;
|
||||||
|
char *filename;
|
||||||
|
char *included;
|
||||||
|
char line[8192];
|
||||||
|
|
||||||
|
conf = config_output_dir();
|
||||||
|
if (conf == NULL) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
string_or_die(&filename, "%s/%i/noship/%s-includes", conf, version, component);
|
||||||
|
free(conf);
|
||||||
|
|
||||||
|
LOG(NULL, "Reading includes", "%s", filename);
|
||||||
|
infile = fopen(filename, "rb");
|
||||||
|
|
||||||
|
if (infile == NULL) {
|
||||||
|
if (errno != ENOENT) {
|
||||||
|
LOG(NULL, "Cannot read includes", "%s (%s)\n", filename, strerror(errno));
|
||||||
|
}
|
||||||
|
free(filename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
line[0] = 0;
|
||||||
|
while (strcmp(line, "\n") != 0) {
|
||||||
|
line[0] = 0;
|
||||||
|
if (fgets(line, 8191, infile) == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
c = strchr(line, '\n');
|
||||||
|
if (c) {
|
||||||
|
*c = 0;
|
||||||
|
}
|
||||||
|
if (strlen(line) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
included = strdup(line);
|
||||||
|
includes = g_list_prepend(includes, included);
|
||||||
|
}
|
||||||
|
fclose(infile);
|
||||||
|
includes = g_list_sort(includes, (GCompareFunc)strcmp);
|
||||||
|
|
||||||
|
return includes;
|
||||||
|
}
|
||||||
|
|
||||||
struct manifest *sub_manifest_from_directory(char *component, int version)
|
struct manifest *sub_manifest_from_directory(char *component, int version)
|
||||||
{
|
{
|
||||||
struct manifest *manifest;
|
struct manifest *manifest;
|
||||||
@@ -419,6 +476,8 @@ struct manifest *sub_manifest_from_directory(char *component, int version)
|
|||||||
|
|
||||||
manifest->files = g_list_sort(manifest->files, file_sort_filename);
|
manifest->files = g_list_sort(manifest->files, file_sort_filename);
|
||||||
|
|
||||||
|
manifest->includes = get_sub_manifest_includes(component, version);
|
||||||
|
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-25
@@ -21,15 +21,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <assert.h>
|
||||||
|
#include <glib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <glib.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
@@ -66,25 +65,5 @@ void chroot_create_full(int newversion)
|
|||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
free(command);
|
free(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and since some dumb files have things like install timestamps in
|
|
||||||
* them, we pull files from full back to bundles so each instance
|
|
||||||
* of the "same" file is truly identical across bundles. It may
|
|
||||||
* make sense at some point to add more logic here for conflict
|
|
||||||
* detection and resolution, including work to insure renames are
|
|
||||||
* consistent across groups. */
|
|
||||||
while (1) {
|
|
||||||
group = next_group();
|
|
||||||
if (!group) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG(NULL, "Recopy bundle chroot out of full", "%s", group);
|
|
||||||
string_or_die(&command, "rsync -aAX --existing %s %s/%i/%s",
|
|
||||||
full_dir, image_dir, newversion, group);
|
|
||||||
ret = system(command);
|
|
||||||
assert(ret == 0);
|
|
||||||
free(command);
|
|
||||||
}
|
|
||||||
free(full_dir);
|
free(full_dir);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -20,11 +20,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <glib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
|
|||||||
@@ -25,17 +25,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <glib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <getopt.h>
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ static void print_help(const char *name)
|
|||||||
printf("Application Options:\n");
|
printf("Application Options:\n");
|
||||||
printf(" -o, --osversion The OS version for which to create an update\n");
|
printf(" -o, --osversion The OS version for which to create an update\n");
|
||||||
printf(" -m, --minversion Optional minimum file version to write into manifests per file\n");
|
printf(" -m, --minversion Optional minimum file version to write into manifests per file\n");
|
||||||
printf(" -F, --format Optional format string [ default:=%d ]\n", SWUPD_DEFAULT_FORMAT);
|
printf(" -F, --format Format number for the update\n");
|
||||||
printf(" -g, --getformat Print current format string and exit\n");
|
printf(" -g, --getformat Print current format string and exit\n");
|
||||||
printf(" -S, --statedir Optional directory to use for state [ default:=%s ]\n", SWUPD_SERVER_STATE_DIR);
|
printf(" -S, --statedir Optional directory to use for state [ default:=%s ]\n", SWUPD_SERVER_STATE_DIR);
|
||||||
printf(" -s, --signcontent Enables cryptographic signing of update content\n");
|
printf(" -s, --signcontent Enables cryptographic signing of update content\n");
|
||||||
@@ -105,7 +105,7 @@ static bool parse_options(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
if (!optarg || !set_format_string(optarg)) {
|
if (!optarg || !set_format(optarg)) {
|
||||||
printf("Invalid --format argument\n\n");
|
printf("Invalid --format argument\n\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -117,10 +117,10 @@ static bool parse_options(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
if (format_string == NULL) {
|
if (format == 0) {
|
||||||
printf("%d\n", SWUPD_DEFAULT_FORMAT);
|
printf("No format specified\n");
|
||||||
} else {
|
} else {
|
||||||
printf("%s\n", format_string);
|
printf("%llu\n", format);
|
||||||
free_globals();
|
free_globals();
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
@@ -223,8 +223,11 @@ int main(int argc, char **argv)
|
|||||||
struct manifest *old_full = NULL;
|
struct manifest *old_full = NULL;
|
||||||
struct manifest *new_full = NULL;
|
struct manifest *new_full = NULL;
|
||||||
|
|
||||||
|
GHashTable *new_manifests = g_hash_table_new(g_str_hash, g_str_equal);
|
||||||
|
GHashTable *old_manifests = g_hash_table_new(g_str_hash, g_str_equal);
|
||||||
GList *manifests_last_versions_list = NULL;
|
GList *manifests_last_versions_list = NULL;
|
||||||
int newfiles = 0;
|
int newfiles = 0;
|
||||||
|
int old_deleted = 0;
|
||||||
|
|
||||||
struct timeval current_time;
|
struct timeval current_time;
|
||||||
struct timeval previous_time;
|
struct timeval previous_time;
|
||||||
@@ -274,7 +277,7 @@ int main(int argc, char **argv)
|
|||||||
populate_dirs(newversion);
|
populate_dirs(newversion);
|
||||||
|
|
||||||
printf("Next version is %i \n", newversion);
|
printf("Next version is %i \n", newversion);
|
||||||
init_log(newversion);
|
init_log("swupd-create-update", "", current_version, newversion);
|
||||||
|
|
||||||
gettimeofday(&previous_time, NULL);
|
gettimeofday(&previous_time, NULL);
|
||||||
|
|
||||||
@@ -293,6 +296,13 @@ int main(int argc, char **argv)
|
|||||||
apply_heuristics(old_full);
|
apply_heuristics(old_full);
|
||||||
apply_heuristics(new_full);
|
apply_heuristics(new_full);
|
||||||
match_manifests(old_full, new_full);
|
match_manifests(old_full, new_full);
|
||||||
|
|
||||||
|
old_deleted = remove_old_deleted_files(old_full, new_full);
|
||||||
|
if (old_deleted > 0) {
|
||||||
|
LOG(NULL, "", "Old deleted files (%d) removed from full manifest", old_deleted);
|
||||||
|
printf("Old deleted files (%d) removed from full manifest\n", old_deleted);
|
||||||
|
}
|
||||||
|
|
||||||
apply_heuristics(new_full);
|
apply_heuristics(new_full);
|
||||||
#warning disabled rename detection for some simplicity
|
#warning disabled rename detection for some simplicity
|
||||||
// rename_detection(new_full);
|
// rename_detection(new_full);
|
||||||
@@ -332,6 +342,7 @@ int main(int argc, char **argv)
|
|||||||
/* Detect renamed files specifically for each pack */
|
/* Detect renamed files specifically for each pack */
|
||||||
// rename_detection(...);
|
// rename_detection(...);
|
||||||
|
|
||||||
|
old_deleted = remove_old_deleted_files(old_core, new_core);
|
||||||
sort_manifest_by_version(new_core);
|
sort_manifest_by_version(new_core);
|
||||||
newfiles = prune_manifest(new_core);
|
newfiles = prune_manifest(new_core);
|
||||||
if (newfiles <= 0) {
|
if (newfiles <= 0) {
|
||||||
@@ -339,8 +350,8 @@ int main(int argc, char **argv)
|
|||||||
printf("Core component has not changed (after pruning), exiting\n");
|
printf("Core component has not changed (after pruning), exiting\n");
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
LOG(NULL, "", "Core component has changes (%d), writing out new manifest", newfiles);
|
LOG(NULL, "", "Core component has changes (%d new, %d deleted), writing out new manifest", newfiles, old_deleted);
|
||||||
printf("Core component has changes (%d), writing out new manifest\n", newfiles);
|
printf("Core component has changes (%d new, %d deleted), writing out new manifest\n", newfiles, old_deleted);
|
||||||
if (write_manifest(new_core) != 0) {
|
if (write_manifest(new_core) != 0) {
|
||||||
LOG(NULL, "", "Core component manifest write failed");
|
LOG(NULL, "", "Core component manifest write failed");
|
||||||
printf("Core component manifest write failed\n");
|
printf("Core component manifest write failed\n");
|
||||||
@@ -353,6 +364,43 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Phase 3: the functional bundles */
|
/* Phase 3: the functional bundles */
|
||||||
printf("Entering phase 3: The bundles\n");
|
printf("Entering phase 3: The bundles\n");
|
||||||
|
while (1) {
|
||||||
|
char *group = next_group();
|
||||||
|
|
||||||
|
if (!group) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)g_hash_table_insert(new_manifests, group, sub_manifest_from_directory(group, newversion));
|
||||||
|
(void)g_hash_table_insert(old_manifests, group, manifest_from_file(manifest_subversion(old_MoM, group), group));
|
||||||
|
}
|
||||||
|
while (1) {
|
||||||
|
GList *manifest_includes = NULL;
|
||||||
|
GList *name_includes;
|
||||||
|
char *group = next_group();
|
||||||
|
struct manifest *manifest;
|
||||||
|
|
||||||
|
if (!group) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
manifest = g_hash_table_lookup(new_manifests, group);
|
||||||
|
name_includes = manifest->includes;
|
||||||
|
while (name_includes) {
|
||||||
|
char *name = name_includes->data;
|
||||||
|
name_includes = g_list_next(name_includes);
|
||||||
|
manifest_includes = g_list_prepend(manifest_includes, g_hash_table_lookup(new_manifests, name));
|
||||||
|
}
|
||||||
|
manifest->includes = manifest_includes;
|
||||||
|
manifest_includes = NULL;
|
||||||
|
manifest = g_hash_table_lookup(old_manifests, group);
|
||||||
|
name_includes = manifest->includes;
|
||||||
|
while (name_includes) {
|
||||||
|
char *name = name_includes->data;
|
||||||
|
name_includes = g_list_next(name_includes);
|
||||||
|
manifest_includes = g_list_prepend(manifest_includes, g_hash_table_lookup(old_manifests, name));
|
||||||
|
}
|
||||||
|
manifest->includes = manifest_includes;
|
||||||
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
char *group = next_group();
|
char *group = next_group();
|
||||||
struct manifest *oldm;
|
struct manifest *oldm;
|
||||||
@@ -369,19 +417,27 @@ int main(int argc, char **argv)
|
|||||||
printf("Processing bundle %s\n", group);
|
printf("Processing bundle %s\n", group);
|
||||||
|
|
||||||
/* Step 4: Make a manifest for this functonal group */
|
/* Step 4: Make a manifest for this functonal group */
|
||||||
oldm = manifest_from_file(manifest_subversion(old_MoM, group), group);
|
oldm = g_hash_table_lookup(old_manifests, group);
|
||||||
newm = sub_manifest_from_directory(group, newversion);
|
newm = g_hash_table_lookup(new_manifests, group);
|
||||||
add_component_hashes_to_manifest(newm, new_full);
|
add_component_hashes_to_manifest(newm, new_full);
|
||||||
apply_heuristics(oldm);
|
apply_heuristics(oldm);
|
||||||
apply_heuristics(newm);
|
apply_heuristics(newm);
|
||||||
newm->prevversion = oldm->version;
|
newm->prevversion = oldm->version;
|
||||||
|
|
||||||
|
/* add os-core as an included manifest */
|
||||||
|
if (!manifest_includes(oldm, "os-core")) {
|
||||||
|
oldm->includes = g_list_prepend(oldm->includes, old_core);
|
||||||
|
}
|
||||||
|
if (!manifest_includes(newm, "os-core")) {
|
||||||
|
newm->includes = g_list_prepend(newm->includes, new_core);
|
||||||
|
}
|
||||||
|
|
||||||
/* Step 5: Subtract the core files from the manifest */
|
/* Step 5: Subtract the core files from the manifest */
|
||||||
subtract_manifests(oldm, old_core);
|
subtract_manifests_frontend(oldm, oldm);
|
||||||
subtract_manifests(newm, new_core);
|
subtract_manifests_frontend(newm, newm);
|
||||||
|
|
||||||
/* Step 6: Compare manifest to the previous version... */
|
/* Step 6: Compare manifest to the previous version... */
|
||||||
if (match_manifests(oldm, newm) == 0) {
|
if (match_manifests(oldm, newm) == 0 && !changed_includes(oldm, newm)) {
|
||||||
LOG(NULL, "", "%s components have not changed, no new manifest", group);
|
LOG(NULL, "", "%s components have not changed, no new manifest", group);
|
||||||
printf("%s components have not changed, no new manifest\n", group);
|
printf("%s components have not changed, no new manifest\n", group);
|
||||||
/* Step 6a: if nothing changed, stay at the old version */
|
/* Step 6a: if nothing changed, stay at the old version */
|
||||||
@@ -390,12 +446,13 @@ int main(int argc, char **argv)
|
|||||||
apply_heuristics(newm);
|
apply_heuristics(newm);
|
||||||
#warning missing rename_detection here
|
#warning missing rename_detection here
|
||||||
/* Step 6b: otherwise, write out the manifest */
|
/* Step 6b: otherwise, write out the manifest */
|
||||||
|
old_deleted = remove_old_deleted_files(oldm, newm);
|
||||||
sort_manifest_by_version(newm);
|
sort_manifest_by_version(newm);
|
||||||
type_change_detection(newm);
|
type_change_detection(newm);
|
||||||
newfiles = prune_manifest(newm);
|
newfiles = prune_manifest(newm);
|
||||||
if (newfiles > 0) {
|
if (newfiles > 0 || old_deleted > 0 || changed_includes(oldm, newm)) {
|
||||||
LOG(NULL, "", "%s component has changes (%d), writing out new manifest", group, newfiles);
|
LOG(NULL, "", "%s component has changes (%d new, %d deleted), writing out new manifest", group, newfiles, old_deleted);
|
||||||
printf("%s component has changes (%d), writing out new manifest\n", group, newfiles);
|
printf("%s component has changes (%d new, %d deleted), writing out new manifest\n", group, newfiles, old_deleted);
|
||||||
if (write_manifest(newm) != 0) {
|
if (write_manifest(newm) != 0) {
|
||||||
LOG(NULL, "", "%s component manifest write failed", group);
|
LOG(NULL, "", "%s component manifest write failed", group);
|
||||||
printf("%s component manifest write failed\n", group);
|
printf("%s component manifest write failed\n", group);
|
||||||
+6
-8
@@ -21,18 +21,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <assert.h>
|
||||||
|
#include <bsdiff.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <glib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <bsdiff.h>
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
#include "xattrs.h"
|
#include "xattrs.h"
|
||||||
|
|||||||
+9
-10
@@ -22,18 +22,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <stdint.h>
|
#include <sys/types.h>
|
||||||
#include <errno.h>
|
#include <unistd.h>
|
||||||
#include <libgen.h>
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
@@ -92,8 +91,7 @@ static void create_fullfile(struct file *file)
|
|||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
string_or_die(&tarcommand, TAR_COMMAND " -C %s " TAR_PERM_ATTR_ARGS " -cf - --exclude='%s/?*' './%s' 2> /dev/null | "
|
string_or_die(&tarcommand, TAR_COMMAND " -C %s " TAR_PERM_ATTR_ARGS " -cf - --exclude='%s/?*' './%s' 2> /dev/null | " TAR_COMMAND " -C %s " TAR_PERM_ATTR_ARGS " -xf - 2> /dev/null",
|
||||||
TAR_COMMAND " -C %s " TAR_PERM_ATTR_ARGS " -xf - 2> /dev/null",
|
|
||||||
dir, base, base, rename_tmpdir);
|
dir, base, base, rename_tmpdir);
|
||||||
if (system(tarcommand) != 0) {
|
if (system(tarcommand) != 0) {
|
||||||
LOG(NULL, "Failed to run command:", "%s", tarcommand);
|
LOG(NULL, "Failed to run command:", "%s", tarcommand);
|
||||||
@@ -125,6 +123,7 @@ static void create_fullfile(struct file *file)
|
|||||||
if (rmdir(rename_tmpdir)) {
|
if (rmdir(rename_tmpdir)) {
|
||||||
LOG(NULL, "rmdir failed for %s", rename_tmpdir);
|
LOG(NULL, "rmdir failed for %s", rename_tmpdir);
|
||||||
}
|
}
|
||||||
|
free(rename_tmpdir);
|
||||||
|
|
||||||
free(tmp1);
|
free(tmp1);
|
||||||
free(tmp2);
|
free(tmp2);
|
||||||
|
|||||||
+13
-16
@@ -21,19 +21,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
int newversion = -1;
|
int newversion = -1;
|
||||||
int minversion = 0;
|
int minversion = 0;
|
||||||
char *format_string = NULL;
|
unsigned long long int format = 0;
|
||||||
bool enable_signing = false;
|
bool enable_signing = false;
|
||||||
|
|
||||||
char *state_dir = NULL;
|
char *state_dir = NULL;
|
||||||
@@ -41,20 +41,17 @@ char *packstage_dir = NULL;
|
|||||||
char *image_dir = NULL;
|
char *image_dir = NULL;
|
||||||
char *staging_dir = NULL;
|
char *staging_dir = NULL;
|
||||||
|
|
||||||
bool set_format_string(char *userinput)
|
bool set_format(char *userinput)
|
||||||
{
|
{
|
||||||
int version;
|
unsigned long long int user_format;
|
||||||
|
|
||||||
// expect a positive integer
|
// format string shall be a positive integer
|
||||||
errno = 0;
|
errno = 0;
|
||||||
version = strtoull(userinput, NULL, 10);
|
user_format = strtoull(userinput, NULL, 10);
|
||||||
if ((errno < 0) || (version <= 0)) {
|
if ((errno < 0) || (user_format == 0)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (format_string) {
|
format = user_format;
|
||||||
free(format_string);
|
|
||||||
}
|
|
||||||
string_or_die(&format_string, "%d", version);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -81,8 +78,9 @@ bool set_state_dir(char *dir)
|
|||||||
|
|
||||||
bool init_globals(void)
|
bool init_globals(void)
|
||||||
{
|
{
|
||||||
if (format_string == NULL) {
|
if (format == 0) {
|
||||||
string_or_die(&format_string, "%d", SWUPD_DEFAULT_FORMAT);
|
printf("Error: Missing format parameter. Please specify a format with -F.\n");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!init_state_globals()) {
|
if (!init_state_globals()) {
|
||||||
@@ -101,7 +99,6 @@ bool init_globals(void)
|
|||||||
|
|
||||||
void free_globals(void)
|
void free_globals(void)
|
||||||
{
|
{
|
||||||
free(format_string);
|
|
||||||
free(state_dir);
|
free(state_dir);
|
||||||
free(packstage_dir);
|
free(packstage_dir);
|
||||||
free(image_dir);
|
free(image_dir);
|
||||||
|
|||||||
+2
-2
@@ -23,11 +23,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <glib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
|
|||||||
+6
-7
@@ -21,19 +21,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <glib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <fcntl.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -21,13 +21,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <assert.h>
|
||||||
|
#include <glib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
|
|||||||
@@ -22,15 +22,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <assert.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
@@ -38,11 +37,12 @@ static FILE *logfile;
|
|||||||
|
|
||||||
static struct timeval start_time;
|
static struct timeval start_time;
|
||||||
|
|
||||||
void init_log(int version)
|
void init_log(const char *prefix, const char *bundle, int start, int end)
|
||||||
{
|
{
|
||||||
char filename[4096];
|
char *filename;
|
||||||
sprintf(filename, "swupd-server.log.%i", version);
|
string_or_die(&filename, "%s%s-from-%i-to-%i.log", prefix, bundle, start, end);
|
||||||
logfile = fopen(filename, "w");
|
logfile = fopen(filename, "w");
|
||||||
|
free(filename);
|
||||||
gettimeofday(&start_time, NULL);
|
gettimeofday(&start_time, NULL);
|
||||||
}
|
}
|
||||||
void init_log_stdout(void)
|
void init_log_stdout(void)
|
||||||
|
|||||||
@@ -21,13 +21,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <assert.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <getopt.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
@@ -113,6 +112,8 @@ int main(int argc, char **argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_log("swupd-make-fullfiles", "", 0, version);
|
||||||
|
|
||||||
manifest = manifest_from_file(version, "full");
|
manifest = manifest_from_file(version, "full");
|
||||||
create_fullfiles(manifest);
|
create_fullfiles(manifest);
|
||||||
|
|
||||||
|
|||||||
+10
-14
@@ -21,20 +21,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <assert.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <glib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <dirent.h>
|
#include <sys/types.h>
|
||||||
#include <getopt.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include <getopt.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
@@ -116,10 +114,6 @@ int main(int argc, char **argv)
|
|||||||
banner();
|
banner();
|
||||||
check_root();
|
check_root();
|
||||||
|
|
||||||
/* FIXME: should use "end_version" not "0" and a unique filename
|
|
||||||
init_log(0);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Initilize the crypto signature module */
|
/* Initilize the crypto signature module */
|
||||||
if (!signature_initialize()) {
|
if (!signature_initialize()) {
|
||||||
printf("Can't initialize the crypto signature module!\n");
|
printf("Can't initialize the crypto signature module!\n");
|
||||||
@@ -141,6 +135,8 @@ int main(int argc, char **argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_log("swupd-make-pack-", module, start_version, end_version);
|
||||||
|
|
||||||
printf("Making pack-%s %i to %li\n", module, start_version, end_version);
|
printf("Making pack-%s %i to %li\n", module, start_version, end_version);
|
||||||
|
|
||||||
pack = calloc(1, sizeof(struct packdata));
|
pack = calloc(1, sizeof(struct packdata));
|
||||||
|
|||||||
+243
-33
@@ -23,19 +23,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <assert.h>
|
||||||
|
#include <bsdiff.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <libgen.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <libgen.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <bsdiff.h>
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
#include "xattrs.h"
|
#include "xattrs.h"
|
||||||
@@ -101,6 +99,7 @@ struct manifest *alloc_manifest(int version, char *component)
|
|||||||
|
|
||||||
manifest->version = version;
|
manifest->version = version;
|
||||||
manifest->component = strdup(component);
|
manifest->component = strdup(component);
|
||||||
|
manifest->format = format;
|
||||||
|
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
@@ -108,11 +107,13 @@ struct manifest *alloc_manifest(int version, char *component)
|
|||||||
struct manifest *manifest_from_file(int version, char *component)
|
struct manifest *manifest_from_file(int version, char *component)
|
||||||
{
|
{
|
||||||
FILE *infile;
|
FILE *infile;
|
||||||
|
GList *includes = NULL;
|
||||||
char line[8192], *c, *c2;
|
char line[8192], *c, *c2;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
struct manifest *manifest;
|
struct manifest *manifest;
|
||||||
char *filename, *conf;
|
char *filename, *conf;
|
||||||
int previous = 0;
|
int previous = 0;
|
||||||
|
unsigned long long int format_number;
|
||||||
|
|
||||||
conf = config_output_dir();
|
conf = config_output_dir();
|
||||||
if (conf == NULL) {
|
if (conf == NULL) {
|
||||||
@@ -144,7 +145,9 @@ struct manifest *manifest_from_file(int version, char *component)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
c = &line[9];
|
c = &line[9];
|
||||||
if (strtoull(c, NULL, 10) == 0) {
|
format_number = strtoull(c, NULL, 10);
|
||||||
|
if ((errno < 0) || (format_number == 0)) {
|
||||||
|
//format string shall be a positive integer
|
||||||
printf("Unknown file format version in MANIFEST line: %s\n", c);
|
printf("Unknown file format version in MANIFEST line: %s\n", c);
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -178,10 +181,18 @@ struct manifest *manifest_from_file(int version, char *component)
|
|||||||
if (strncmp(line, "previous:", 9) == 0) {
|
if (strncmp(line, "previous:", 9) == 0) {
|
||||||
previous = strtoull(c, NULL, 10);
|
previous = strtoull(c, NULL, 10);
|
||||||
}
|
}
|
||||||
|
if (strncmp(line, "includes:", 9) == 0) {
|
||||||
|
includes = g_list_prepend(includes, strdup(c));
|
||||||
|
if (!includes->data) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest = alloc_manifest(version, component);
|
manifest = alloc_manifest(version, component);
|
||||||
|
manifest->format = format_number;
|
||||||
manifest->prevversion = previous;
|
manifest->prevversion = previous;
|
||||||
|
manifest->includes = includes;
|
||||||
|
|
||||||
/* empty line */
|
/* empty line */
|
||||||
while (!feof(infile)) {
|
while (!feof(infile)) {
|
||||||
@@ -509,29 +520,57 @@ int match_manifests(struct manifest *m1, struct manifest *m2)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* removes all files from m2 from m1 */
|
static GList *get_unique_includes(struct manifest *manifest)
|
||||||
|
{
|
||||||
|
GHashTable *unique_includes = g_hash_table_new(g_str_hash, g_str_equal);
|
||||||
|
GHashTableIter iter;
|
||||||
|
GList *includes = NULL;
|
||||||
|
GList *l1, *l2;
|
||||||
|
gpointer k, v;
|
||||||
|
|
||||||
|
l1 = g_list_first(manifest->includes);
|
||||||
|
while (l1) {
|
||||||
|
struct manifest *m = l1->data;
|
||||||
|
l1 = g_list_next(l1);
|
||||||
|
(void)g_hash_table_replace(unique_includes, m->component, m);
|
||||||
|
l2 = get_unique_includes(m);
|
||||||
|
while (l2) {
|
||||||
|
struct manifest *m = l2->data;
|
||||||
|
l2 = g_list_next(l2);
|
||||||
|
(void)g_hash_table_replace(unique_includes, m->component, m);
|
||||||
|
}
|
||||||
|
g_list_free(l2);
|
||||||
|
}
|
||||||
|
g_hash_table_iter_init(&iter, unique_includes);
|
||||||
|
while (g_hash_table_iter_next(&iter, &k, &v)) {
|
||||||
|
includes = g_list_prepend(includes, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
return includes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* removes all files from m2 from m1
|
||||||
|
* This will recurse over all included manifests to also
|
||||||
|
* subtract those from the m1 manifest.
|
||||||
|
*
|
||||||
|
* As a special convenient semantics,
|
||||||
|
* subtract_manifests(M, M)
|
||||||
|
* will subtract all included manifests from M,
|
||||||
|
* but will not subtract M from M itself.
|
||||||
|
*/
|
||||||
void subtract_manifests(struct manifest *m1, struct manifest *m2)
|
void subtract_manifests(struct manifest *m1, struct manifest *m2)
|
||||||
{
|
{
|
||||||
GList *list1, *list2;
|
GList *list1, *list2;
|
||||||
struct file *file1, *file2;
|
struct file *file1, *file2;
|
||||||
|
|
||||||
if (!m1) {
|
|
||||||
printf("Subtracting manifests failed: No m1 manifest!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m2) {
|
|
||||||
printf("Subtracting manifests failed: No m2 manifest!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m1->files = g_list_sort(m1->files, file_sort_filename);
|
m1->files = g_list_sort(m1->files, file_sort_filename);
|
||||||
m2->files = g_list_sort(m2->files, file_sort_filename);
|
m2->files = g_list_sort(m2->files, file_sort_filename);
|
||||||
|
|
||||||
list1 = g_list_first(m1->files);
|
list1 = g_list_first(m1->files);
|
||||||
list2 = g_list_first(m2->files);
|
list2 = g_list_first(m2->files);
|
||||||
|
|
||||||
while (list1 && list2) {
|
while (list1 && list2 && m1 != m2) {
|
||||||
int ret;
|
int ret;
|
||||||
file1 = list1->data;
|
file1 = list1->data;
|
||||||
file2 = list2->data;
|
file2 = list2->data;
|
||||||
@@ -546,15 +585,37 @@ void subtract_manifests(struct manifest *m1, struct manifest *m2)
|
|||||||
if (file1->is_deleted == file2->is_deleted && file1->is_file == file2->is_file) {
|
if (file1->is_deleted == file2->is_deleted && file1->is_file == file2->is_file) {
|
||||||
m1->files = g_list_delete_link(m1->files, todel);
|
m1->files = g_list_delete_link(m1->files, todel);
|
||||||
m1->count--;
|
m1->count--;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
} else if (ret < 0) {
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
list1 = g_list_next(list1);
|
list1 = g_list_next(list1);
|
||||||
continue;
|
} else {
|
||||||
|
list2 = g_list_next(list2);
|
||||||
}
|
}
|
||||||
list2 = g_list_next(list2);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void subtract_manifests_frontend(struct manifest *m1, struct manifest *m2)
|
||||||
|
{
|
||||||
|
GList *includes;
|
||||||
|
struct manifest *m;
|
||||||
|
|
||||||
|
if (!m1) {
|
||||||
|
printf("Subtracting manifests failed: No m1 manifest!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m2) {
|
||||||
|
printf("Subtracting manifests failed: No m2 manifest!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
subtract_manifests(m1, m2);
|
||||||
|
|
||||||
|
includes = get_unique_includes(m2);
|
||||||
|
while (includes) {
|
||||||
|
m = includes->data;
|
||||||
|
includes = g_list_next(includes);
|
||||||
|
subtract_manifests(m1, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,6 +721,7 @@ exit:
|
|||||||
/* Returns 0 == success, -1 == failure */
|
/* Returns 0 == success, -1 == failure */
|
||||||
static int write_manifest_plain(struct manifest *manifest)
|
static int write_manifest_plain(struct manifest *manifest)
|
||||||
{
|
{
|
||||||
|
GList *includes;
|
||||||
GList *list;
|
GList *list;
|
||||||
struct file *file;
|
struct file *file;
|
||||||
FILE *out = NULL;
|
FILE *out = NULL;
|
||||||
@@ -667,6 +729,9 @@ static int write_manifest_plain(struct manifest *manifest)
|
|||||||
char *conf = config_output_dir();
|
char *conf = config_output_dir();
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
char *submanifest_filename = NULL;
|
char *submanifest_filename = NULL;
|
||||||
|
char *manifest_tempdir = NULL;
|
||||||
|
char *tarcommand = NULL;
|
||||||
|
char *tempmanifest = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (conf == NULL) {
|
if (conf == NULL) {
|
||||||
@@ -690,13 +755,19 @@ static int write_manifest_plain(struct manifest *manifest)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(out, "MANIFEST\t%s\n", format_string);
|
fprintf(out, "MANIFEST\t%llu\n", format);
|
||||||
fprintf(out, "version:\t%i\n", manifest->version);
|
fprintf(out, "version:\t%i\n", manifest->version);
|
||||||
fprintf(out, "previous:\t%i\n", manifest->prevversion);
|
fprintf(out, "previous:\t%i\n", manifest->prevversion);
|
||||||
fprintf(out, "filecount:\t%i\n", manifest->count);
|
fprintf(out, "filecount:\t%i\n", manifest->count);
|
||||||
fprintf(out, "timestamp:\t%i\n", (int)time(NULL));
|
fprintf(out, "timestamp:\t%i\n", (int)time(NULL));
|
||||||
compute_content_size(manifest);
|
compute_content_size(manifest);
|
||||||
fprintf(out, "contentsize:\t%llu\n", (long long unsigned int)manifest->contentsize);
|
fprintf(out, "contentsize:\t%llu\n", (long long unsigned int)manifest->contentsize);
|
||||||
|
includes = manifest->includes;
|
||||||
|
while (includes) {
|
||||||
|
struct manifest *sub = includes->data;
|
||||||
|
includes = g_list_next(includes);
|
||||||
|
fprintf(out, "includes:\t%s\n", sub->component);
|
||||||
|
}
|
||||||
fprintf(out, "\n");
|
fprintf(out, "\n");
|
||||||
|
|
||||||
list = g_list_first(manifest->files);
|
list = g_list_first(manifest->files);
|
||||||
@@ -708,24 +779,54 @@ static int write_manifest_plain(struct manifest *manifest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
list = g_list_first(manifest->manifests);
|
list = g_list_first(manifest->manifests);
|
||||||
|
string_or_die(&manifest_tempdir, "%s/XXXXXX", state_dir);
|
||||||
|
if (!mkdtemp(manifest_tempdir)) {
|
||||||
|
LOG(NULL, "Failed to create temporary directory %s for untarring Manifests", manifest_tempdir);
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
while (list) {
|
while (list) {
|
||||||
file = list->data;
|
file = list->data;
|
||||||
list = g_list_next(list);
|
list = g_list_next(list);
|
||||||
|
|
||||||
string_or_die(&submanifest_filename, "%s/%i/Manifest.%s", conf, file->last_change, file->filename);
|
string_or_die(&submanifest_filename, "%s/%i/Manifest.%s", conf, file->last_change, file->filename);
|
||||||
populate_file_struct(file, submanifest_filename);
|
populate_file_struct(file, submanifest_filename);
|
||||||
ret = compute_hash(file, submanifest_filename);
|
|
||||||
|
if (file->is_deleted) {
|
||||||
|
goto write_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Untar the Manifest.BUNDLE.tar and calculate the hash on that,
|
||||||
|
* otherwise we may get incorrect hashes due to owner permissions on
|
||||||
|
* the files. */
|
||||||
|
string_or_die(&tarcommand, TAR_COMMAND " -C %s " TAR_PERM_ATTR_ARGS " -xf %s.tar 2> /dev/null",
|
||||||
|
manifest_tempdir, submanifest_filename);
|
||||||
|
if (system(tarcommand) != 0) {
|
||||||
|
LOG(NULL, "Failed to run command:", "%s", tarcommand);
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
free(tarcommand);
|
||||||
|
string_or_die(&tempmanifest, "%s/Manifest.%s", manifest_tempdir, file->filename);
|
||||||
|
populate_file_struct(file, tempmanifest);
|
||||||
|
ret = compute_hash(file, tempmanifest);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("Hash computation failed\n");
|
printf("Hash computation failed\n");
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
unlink(tempmanifest);
|
||||||
|
free(tempmanifest);
|
||||||
|
write_entry:
|
||||||
fprintf(out, "%s\t%s\t%i\t%s\n", file_type_to_string(file), file->hash, file->last_change, file->filename);
|
fprintf(out, "%s\t%s\t%i\t%s\n", file_type_to_string(file), file->hash, file->last_change, file->filename);
|
||||||
free(submanifest_filename);
|
free(submanifest_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
exit:
|
exit:
|
||||||
|
if (rmdir(manifest_tempdir) != 0) {
|
||||||
|
LOG(NULL, "rmdir failed for %s: %s", manifest_tempdir, strerror(errno));
|
||||||
|
}
|
||||||
|
free(manifest_tempdir);
|
||||||
|
|
||||||
if (out) {
|
if (out) {
|
||||||
fclose(out);
|
fclose(out);
|
||||||
}
|
}
|
||||||
@@ -750,12 +851,12 @@ static int write_manifest_tar(struct manifest *manifest)
|
|||||||
/* and put the signature of the plain manifest into the archive, too */
|
/* and put the signature of the plain manifest into the archive, too */
|
||||||
if (enable_signing) {
|
if (enable_signing) {
|
||||||
string_or_die(&tarcmd, TAR_COMMAND " --directory=%s/%i " TAR_PERM_ATTR_ARGS " -Jcf "
|
string_or_die(&tarcmd, TAR_COMMAND " --directory=%s/%i " TAR_PERM_ATTR_ARGS " -Jcf "
|
||||||
"%s/%i/Manifest.%s.tar Manifest.%s Manifest.%s.signed",
|
"%s/%i/Manifest.%s.tar Manifest.%s Manifest.%s.signed",
|
||||||
conf, manifest->version, conf, manifest->version, manifest->component,
|
conf, manifest->version, conf, manifest->version, manifest->component,
|
||||||
manifest->component, manifest->component);
|
manifest->component, manifest->component);
|
||||||
} else {
|
} else {
|
||||||
string_or_die(&tarcmd, TAR_COMMAND " --directory=%s/%i " TAR_PERM_ATTR_ARGS " -Jcf "
|
string_or_die(&tarcmd, TAR_COMMAND " --directory=%s/%i " TAR_PERM_ATTR_ARGS " -Jcf "
|
||||||
"%s/%i/Manifest.%s.tar Manifest.%s",
|
"%s/%i/Manifest.%s.tar Manifest.%s",
|
||||||
conf, manifest->version, conf, manifest->version, manifest->component,
|
conf, manifest->version, conf, manifest->version, manifest->component,
|
||||||
manifest->component);
|
manifest->component);
|
||||||
}
|
}
|
||||||
@@ -814,6 +915,115 @@ void sort_manifest_by_version(struct manifest *manifest)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool manifest_includes(struct manifest *manifest, char *component)
|
||||||
|
{
|
||||||
|
GList *includes = g_list_first(manifest->includes);
|
||||||
|
|
||||||
|
while (includes) {
|
||||||
|
if (strcmp(((struct manifest *)includes->data)->component,
|
||||||
|
component) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
includes = g_list_next(includes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This requires the manifest to have the includes sorted.
|
||||||
|
* The manifests will be sorted when constructed from
|
||||||
|
* get_sub_manifest_includes (and then replacing the manifest
|
||||||
|
* strings with actual manifest structs in the same order as
|
||||||
|
* is done in the main.c's main()).
|
||||||
|
*/
|
||||||
|
bool changed_includes(struct manifest *old, struct manifest *new)
|
||||||
|
{
|
||||||
|
GList *includes_old = g_list_first(old->includes);
|
||||||
|
GList *includes_new = g_list_first(new->includes);
|
||||||
|
|
||||||
|
if (g_list_length(includes_old) != g_list_length(includes_new)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (includes_old && includes_new) {
|
||||||
|
char *bundle_old = ((struct manifest *)includes_old->data)->component;
|
||||||
|
char *bundle_new = ((struct manifest *)includes_new->data)->component;
|
||||||
|
if (strcmp(bundle_old, bundle_new) != 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
includes_old = g_list_next(includes_old);
|
||||||
|
includes_new = g_list_next(includes_new);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For a format bump, it's convenient to remove deleted files from manifests
|
||||||
|
* that last changed prior to the format bump, since they are no longer
|
||||||
|
* considered for deletion as part of an update.
|
||||||
|
*
|
||||||
|
* Note: this function should be called after match_manifests().
|
||||||
|
*/
|
||||||
|
int remove_old_deleted_files(struct manifest *m1, struct manifest *m2)
|
||||||
|
{
|
||||||
|
GList *list1, *list2;
|
||||||
|
struct file *file1, *file2;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
if (!m1) {
|
||||||
|
printf("No old manifest!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m2) {
|
||||||
|
printf("No new manifest!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is the common case, so bail early, reporting no deletions */
|
||||||
|
if (m1->format == m2->format) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* At this point, the manifest formats mismatch, and it's assumed that
|
||||||
|
* m1 is the old manifest, and m2 is the new.
|
||||||
|
*/
|
||||||
|
|
||||||
|
m1->files = g_list_sort(m1->files, file_sort_filename);
|
||||||
|
m2->files = g_list_sort(m2->files, file_sort_filename);
|
||||||
|
|
||||||
|
list1 = g_list_first(m1->files);
|
||||||
|
list2 = g_list_first(m2->files);
|
||||||
|
|
||||||
|
while (list1 && list2) {
|
||||||
|
int ret;
|
||||||
|
file1 = list1->data;
|
||||||
|
file2 = list2->data;
|
||||||
|
|
||||||
|
ret = strcmp(file1->filename, file2->filename);
|
||||||
|
if (ret == 0) {
|
||||||
|
if (file1->is_deleted && file2->is_deleted) {
|
||||||
|
GList *to_delete = list2;
|
||||||
|
list1 = g_list_next(list1);
|
||||||
|
list2 = g_list_next(list2);
|
||||||
|
m2->files = g_list_delete_link(m2->files, to_delete);
|
||||||
|
m2->count--;
|
||||||
|
count++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list1 = g_list_next(list1);
|
||||||
|
list2 = g_list_next(list2);
|
||||||
|
} else if (ret < 0) {
|
||||||
|
list1 = g_list_next(list1);
|
||||||
|
} else {
|
||||||
|
list2 = g_list_next(list2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
/* Conditionally remove some things from a manifest.
|
/* Conditionally remove some things from a manifest.
|
||||||
* Returns > 0 when the pruned manifest has new files.
|
* Returns > 0 when the pruned manifest has new files.
|
||||||
* Returns 0 when the pruned manifest no longer has new files.
|
* Returns 0 when the pruned manifest no longer has new files.
|
||||||
@@ -1004,7 +1214,7 @@ static void maximize_version_manifests(struct manifest *m1, struct manifest *m2)
|
|||||||
|
|
||||||
ret = strcmp(file1->filename, file2->filename);
|
ret = strcmp(file1->filename, file2->filename);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
if (file1->last_change > file2->last_change) {
|
if (!file1->is_deleted && file1->last_change > file2->last_change) {
|
||||||
LOG(file1, "Update", "Moving %s to version %i", file1->filename, file1->last_change);
|
LOG(file1, "Update", "Moving %s to version %i", file1->filename, file1->last_change);
|
||||||
file2->last_change = file1->last_change;
|
file2->last_change = file1->last_change;
|
||||||
}
|
}
|
||||||
|
|||||||
+63
-23
@@ -24,18 +24,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <assert.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <glib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <dirent.h>
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
@@ -118,8 +117,7 @@ static void explode_pack_stage(int from_version, int to_version, char *module)
|
|||||||
* the resulting pack is slightly smaller, and in addition, we're saving CPU
|
* the resulting pack is slightly smaller, and in addition, we're saving CPU
|
||||||
* time on the client...
|
* time on the client...
|
||||||
*/
|
*/
|
||||||
string_or_die(&tar, TAR_COMMAND " --directory=%s/%s/%i_to_%i/staged " TAR_WARN_ARGS " "
|
string_or_die(&tar, TAR_COMMAND " --directory=%s/%s/%i_to_%i/staged " TAR_WARN_ARGS " " TAR_PERM_ATTR_ARGS " -xf %s",
|
||||||
TAR_PERM_ATTR_ARGS " -xf %s",
|
|
||||||
packstage_dir, module, from_version, to_version, path);
|
packstage_dir, module, from_version, to_version, path);
|
||||||
ret = system(tar);
|
ret = system(tar);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
@@ -168,21 +166,44 @@ static void make_pack_full_files(struct packdata *pack)
|
|||||||
item = g_list_next(item);
|
item = g_list_next(item);
|
||||||
if ((!file->peer || file->peer->is_deleted) && !file->is_deleted && !file->rename_peer) {
|
if ((!file->peer || file->peer->is_deleted) && !file->is_deleted && !file->rename_peer) {
|
||||||
char *from, *to;
|
char *from, *to;
|
||||||
|
char *fullfrom, *fullto;
|
||||||
|
|
||||||
/* hardlink each file that is in <end> but not in <X> */
|
/* hardlink each file that is in <end> but not in <X> */
|
||||||
|
string_or_die(&fullfrom, "%s/%i/full/%s", image_dir, file->last_change, file->filename);
|
||||||
|
string_or_die(&fullto, "%s/%s/%i_to_%i/staged/%s", packstage_dir,
|
||||||
|
pack->module, pack->from, pack->to, file->hash);
|
||||||
string_or_die(&from, "%s/%i/files/%s.tar", staging_dir, file->last_change, file->hash);
|
string_or_die(&from, "%s/%i/files/%s.tar", staging_dir, file->last_change, file->hash);
|
||||||
string_or_die(&to, "%s/%s/%i_to_%i/staged/%s.tar", packstage_dir,
|
string_or_die(&to, "%s/%s/%i_to_%i/staged/%s.tar", packstage_dir,
|
||||||
pack->module, pack->from, pack->to, file->hash);
|
pack->module, pack->from, pack->to, file->hash);
|
||||||
ret = link(from, to);
|
|
||||||
if (ret) {
|
ret = -1;
|
||||||
if (errno != EEXIST) {
|
errno = 0;
|
||||||
LOG(NULL, "Failure to link", "%s to %s (%s) %i", from, to, strerror(errno), errno);
|
|
||||||
|
/* Prefer to hardlink uncompressed files (excluding
|
||||||
|
* directories) first, and fall back to the compressed
|
||||||
|
* versions if the hardlink fails.
|
||||||
|
*/
|
||||||
|
if (!file->is_dir) {
|
||||||
|
ret = link(fullfrom, fullto);
|
||||||
|
if (ret && errno != EEXIST) {
|
||||||
|
LOG(NULL, "Failure to link for fullfile pack", "%s to %s (%s) %i", fullfrom, fullto, strerror(errno), errno);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
if (ret) {
|
||||||
|
ret = link(from, to);
|
||||||
|
if (ret && errno != EEXIST) {
|
||||||
|
LOG(NULL, "Failure to link for fullfile pack", "%s to %s (%s) %i", from, to, strerror(errno), errno);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
pack->fullcount++;
|
pack->fullcount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(from);
|
free(from);
|
||||||
free(to);
|
free(to);
|
||||||
|
free(fullfrom);
|
||||||
|
free(fullto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,7 +342,7 @@ static int make_final_pack(struct packdata *pack)
|
|||||||
item = g_list_first(pack->end_manifest->files);
|
item = g_list_first(pack->end_manifest->files);
|
||||||
|
|
||||||
while (item) {
|
while (item) {
|
||||||
char *from, *to, *tarfrom, *tarto;
|
char *from, *to, *tarfrom, *tarto, *fullfrom, *fullto;
|
||||||
struct stat stat_delta, stat_tar;
|
struct stat stat_delta, stat_tar;
|
||||||
|
|
||||||
file = item->data;
|
file = item->data;
|
||||||
@@ -344,6 +365,9 @@ static int make_final_pack(struct packdata *pack)
|
|||||||
file->last_change, file->hash);
|
file->last_change, file->hash);
|
||||||
string_or_die(&tarto, "%s/%s/%i_to_%i/staged/%s.tar", packstage_dir,
|
string_or_die(&tarto, "%s/%s/%i_to_%i/staged/%s.tar", packstage_dir,
|
||||||
pack->module, pack->from, pack->to, file->hash);
|
pack->module, pack->from, pack->to, file->hash);
|
||||||
|
string_or_die(&fullfrom, "%s/%i/full/%s", image_dir, file->last_change, file->filename);
|
||||||
|
string_or_die(&fullto, "%s/%s/%i_to_%i/staged/%s", packstage_dir,
|
||||||
|
pack->module, pack->from, pack->to, file->hash);
|
||||||
|
|
||||||
ret = stat(from, &stat_delta);
|
ret = stat(from, &stat_delta);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@@ -375,13 +399,28 @@ static int make_final_pack(struct packdata *pack)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* include full file in pack */
|
ret = -1;
|
||||||
ret = link(tarfrom, tarto);
|
errno = 0;
|
||||||
if (ret) {
|
|
||||||
if (errno != EEXIST) {
|
/* Prefer to hardlink uncompressed files (excluding
|
||||||
LOG(NULL, "Failure to link", "%s to %s (%s) %i\n", tarfrom, tarto, strerror(errno), errno);
|
* directories) first, and fall back to the compressed
|
||||||
|
* versions if the hardlink fails.
|
||||||
|
*/
|
||||||
|
if (!file->is_dir) {
|
||||||
|
ret = link(fullfrom, fullto);
|
||||||
|
if (ret && errno != EEXIST) {
|
||||||
|
LOG(NULL, "Failure to link for final pack", "%s to %s (%s) %i\n", fullfrom, fullto, strerror(errno), errno);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
ret = link(tarfrom, tarto);
|
||||||
|
if (ret && errno != EEXIST) {
|
||||||
|
LOG(NULL, "Failure to link for final pack", "%s to %s (%s) %i\n", tarfrom, tarto, strerror(errno), errno);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
pack->fullcount++;
|
pack->fullcount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -390,6 +429,8 @@ static int make_final_pack(struct packdata *pack)
|
|||||||
free(to);
|
free(to);
|
||||||
free(tarfrom);
|
free(tarfrom);
|
||||||
free(tarto);
|
free(tarto);
|
||||||
|
free(fullfrom);
|
||||||
|
free(fullto);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pack->fullcount > 0) {
|
if (pack->fullcount > 0) {
|
||||||
@@ -411,7 +452,6 @@ static int make_final_pack(struct packdata *pack)
|
|||||||
create_manifest_delta(pack->from, pack->to, pack->module);
|
create_manifest_delta(pack->from, pack->to, pack->module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string_or_die(&to, "%s/%s/%i_to_%i/Manifest-%s-delta-from-%i", packstage_dir,
|
string_or_die(&to, "%s/%s/%i_to_%i/Manifest-%s-delta-from-%i", packstage_dir,
|
||||||
pack->module, pack->from, pack->to, pack->module, pack->from);
|
pack->module, pack->from, pack->to, pack->module, pack->from);
|
||||||
|
|
||||||
@@ -452,7 +492,7 @@ static int make_final_pack(struct packdata *pack)
|
|||||||
/* tar the staging directory up */
|
/* tar the staging directory up */
|
||||||
LOG(NULL, "starting tar for pack", "%s: %i to %i", pack->module, pack->from, pack->to);
|
LOG(NULL, "starting tar for pack", "%s: %i to %i", pack->module, pack->from, pack->to);
|
||||||
string_or_die(&tar, TAR_COMMAND " " TAR_PERM_ATTR_ARGS " --directory=%s/%s/%i_to_%i/ "
|
string_or_die(&tar, TAR_COMMAND " " TAR_PERM_ATTR_ARGS " --directory=%s/%s/%i_to_%i/ "
|
||||||
"--numeric-owner -Jcf %s/%i/pack-%s-from-%i.tar delta staged",
|
"--numeric-owner -Jcf %s/%i/pack-%s-from-%i.tar delta staged",
|
||||||
packstage_dir, pack->module, pack->from, pack->to, staging_dir, pack->to,
|
packstage_dir, pack->module, pack->from, pack->to, staging_dir, pack->to,
|
||||||
pack->module, pack->from);
|
pack->module, pack->from);
|
||||||
ret = system(tar);
|
ret = system(tar);
|
||||||
|
|||||||
+6
-6
@@ -22,16 +22,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -29,7 +30,6 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <err.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -22,13 +22,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <assert.h>
|
||||||
|
#include <glib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
|
|||||||
+7
-8
@@ -23,17 +23,16 @@
|
|||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
|
|
||||||
@@ -140,7 +139,7 @@ void write_cookiecrumbs_to_download_area(int version)
|
|||||||
}
|
}
|
||||||
free(cmd);
|
free(cmd);
|
||||||
|
|
||||||
string_or_die(&cmd, "echo %s > %s/%i/format", format_string, conf, version);
|
string_or_die(&cmd, "echo %llu > %s/%i/format", format, conf, version);
|
||||||
if (system(cmd) != 0) {
|
if (system(cmd) != 0) {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -20,15 +20,15 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <sys/xattr.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/xattr.h>
|
||||||
|
|
||||||
#include "swupd.h"
|
#include "swupd.h"
|
||||||
#include "xattrs.h"
|
#include "xattrs.h"
|
||||||
|
|||||||
@@ -1,23 +1,25 @@
|
|||||||
#!/usr/bin/env bats
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load "../swupdlib"
|
||||||
|
|
||||||
@test "create_update help output" {
|
@test "create_update help output" {
|
||||||
run $srcdir/swupd_create_update --help
|
run $CREATE_UPDATE --help
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
run $srcdir/swupd_create_update -h
|
run $CREATE_UPDATE -h
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "make_fullfiles help output" {
|
@test "make_fullfiles help output" {
|
||||||
run $srcdir/swupd_make_fullfiles --help
|
run $MAKE_FULLFILES --help
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
run $srcdir/swupd_make_fullfiles -h
|
run $MAKE_FULLFILES -h
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "make_pack help output" {
|
@test "make_pack help output" {
|
||||||
run $srcdir/swupd_make_pack --help
|
run $MAKE_PACK --help
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
run $srcdir/swupd_make_pack -h
|
run $MAKE_PACK -h
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
# common functions
|
||||||
|
load "../swupdlib"
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
clean_test_dir
|
||||||
|
init_test_dir
|
||||||
|
|
||||||
|
init_server_ini
|
||||||
|
set_latest_ver 0
|
||||||
|
init_groups_ini os-core test-bundle1 test-bundle2
|
||||||
|
|
||||||
|
set_os_release 10 os-core
|
||||||
|
set_os_release 10 test-bundle1
|
||||||
|
set_os_release 10 test-bundle2
|
||||||
|
track_bundle 10 os-core
|
||||||
|
track_bundle 10 test-bundle1
|
||||||
|
track_bundle 10 test-bundle2
|
||||||
|
|
||||||
|
set_os_release 20 os-core
|
||||||
|
set_os_release 20 test-bundle1
|
||||||
|
set_os_release 20 test-bundle2
|
||||||
|
track_bundle 20 os-core
|
||||||
|
track_bundle 20 test-bundle1
|
||||||
|
track_bundle 20 test-bundle2
|
||||||
|
|
||||||
|
gen_file_plain 10 test-bundle1 foo
|
||||||
|
gen_file_plain 10 test-bundle2 foo
|
||||||
|
|
||||||
|
gen_file_plain 20 test-bundle1 foo
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "delete no version bump update creation" {
|
||||||
|
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
|
||||||
|
sudo $MAKE_FULLFILES --statedir $DIR 10
|
||||||
|
|
||||||
|
set_latest_ver 10
|
||||||
|
|
||||||
|
sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 3
|
||||||
|
sudo $MAKE_FULLFILES --statedir $DIR 20
|
||||||
|
|
||||||
|
[ 1 -eq $(grep '10 /foo' $DIR/www/10/Manifest.full | wc -l) ]
|
||||||
|
[ 1 -eq $(grep '10 /foo' $DIR/www/20/Manifest.full | wc -l) ]
|
||||||
|
[ 0 -eq $(grep '20 /foo' $DIR/www/20/Manifest.full | wc -l) ]
|
||||||
|
}
|
||||||
|
|
||||||
|
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
# common functions
|
||||||
|
load "../swupdlib"
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
clean_test_dir
|
||||||
|
init_test_dir
|
||||||
|
|
||||||
|
init_server_ini
|
||||||
|
set_latest_ver 0
|
||||||
|
init_groups_ini os-core
|
||||||
|
|
||||||
|
set_os_release 10 os-core
|
||||||
|
track_bundle 10 os-core
|
||||||
|
|
||||||
|
gen_file_plain 10 os-core "semicolon;"
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_illegal_char() {
|
||||||
|
local output="$1"
|
||||||
|
local str=$(echo "Filename $2 includes illegal character(s)")
|
||||||
|
[[ "$output" =~ "$str" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_valid_char() {
|
||||||
|
local output="$1"
|
||||||
|
local str=$(echo "Filename $2 includes illegal character(s)")
|
||||||
|
[[ ! "$output" =~ "$str" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "file names with blacklisted characters" {
|
||||||
|
run sudo sh -c "$CREATE_UPDATE --osversion 10 --statedir $DIR --format 3"
|
||||||
|
|
||||||
|
echo "$output"
|
||||||
|
assert_illegal_char "$output" "/semicolon;"
|
||||||
|
assert_valid_char "$output" "/usr"
|
||||||
|
}
|
||||||
|
|
||||||
|
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
#!/usr/bin/env bats
|
|
||||||
|
|
||||||
# common functions
|
|
||||||
load swupdlib
|
|
||||||
|
|
||||||
setup() {
|
|
||||||
DIR=$(init_web_dir "$srcdir/web-dir")
|
|
||||||
export DIR
|
|
||||||
|
|
||||||
init_server_ini
|
|
||||||
set_latest_ver 0
|
|
||||||
init_groups_ini os-core test-bundle
|
|
||||||
|
|
||||||
set_os_release 10 os-core
|
|
||||||
track_bundle 10 os-core
|
|
||||||
track_bundle 10 test-bundle
|
|
||||||
set_os_release 20 os-core
|
|
||||||
track_bundle 20 os-core
|
|
||||||
track_bundle 20 test-bundle
|
|
||||||
|
|
||||||
gen_file_to_delta 10 4096 20 4 test-bundle
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "full run update creation with delta packs" {
|
|
||||||
# build the first version
|
|
||||||
sudo $srcdir/swupd_create_update --osversion 10 --statedir $DIR
|
|
||||||
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 10
|
|
||||||
sudo $srcdir/swupd_make_pack --statedir $DIR 0 10 os-core
|
|
||||||
sudo $srcdir/swupd_make_pack --statedir $DIR 0 10 test-bundle
|
|
||||||
|
|
||||||
set_latest_ver 10
|
|
||||||
|
|
||||||
# then the second version...
|
|
||||||
sudo $srcdir/swupd_create_update --osversion 20 --statedir $DIR
|
|
||||||
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 20
|
|
||||||
sudo $srcdir/swupd_make_pack --statedir $DIR 0 20 os-core
|
|
||||||
sudo $srcdir/swupd_make_pack --statedir $DIR 0 20 test-bundle
|
|
||||||
|
|
||||||
# and with delta packs this time
|
|
||||||
sudo $srcdir/swupd_make_pack --statedir $DIR 10 20 os-core
|
|
||||||
sudo $srcdir/swupd_make_pack --statedir $DIR 10 20 test-bundle
|
|
||||||
|
|
||||||
# zero packs should exist (non-zero size) for both versions
|
|
||||||
[ -s $DIR/www/10/pack-os-core-from-0.tar ]
|
|
||||||
[ -s $DIR/www/10/pack-test-bundle-from-0.tar ]
|
|
||||||
[ -s $DIR/www/20/pack-os-core-from-0.tar ]
|
|
||||||
[ -s $DIR/www/20/pack-test-bundle-from-0.tar ]
|
|
||||||
|
|
||||||
# and delta packs should exist (non-zero size) for the latest version
|
|
||||||
[ -s $DIR/www/20/pack-os-core-from-10.tar ]
|
|
||||||
[ -s $DIR/www/20/pack-test-bundle-from-10.tar ]
|
|
||||||
}
|
|
||||||
|
|
||||||
teardown() {
|
|
||||||
sudo rm -rf $DIR
|
|
||||||
}
|
|
||||||
|
|
||||||
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
|
||||||
Executable
+84
@@ -0,0 +1,84 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
# common functions
|
||||||
|
load "../swupdlib"
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
clean_test_dir
|
||||||
|
init_test_dir
|
||||||
|
|
||||||
|
init_server_ini
|
||||||
|
set_latest_ver 0
|
||||||
|
init_groups_ini os-core test-bundle included included-two included-nested
|
||||||
|
|
||||||
|
set_os_release 10 os-core
|
||||||
|
track_bundle 10 os-core
|
||||||
|
track_bundle 10 test-bundle
|
||||||
|
set_os_release 20 os-core
|
||||||
|
track_bundle 20 os-core
|
||||||
|
track_bundle 20 test-bundle
|
||||||
|
track_bundle 20 included
|
||||||
|
track_bundle 20 included-two
|
||||||
|
track_bundle 20 included-nested
|
||||||
|
|
||||||
|
gen_file_to_delta 10 4096 20 4 test-bundle
|
||||||
|
|
||||||
|
gen_file_plain 10 test-bundle foo
|
||||||
|
gen_file_plain 10 test-bundle foobarbaz
|
||||||
|
gen_file_plain 20 test-bundle foo
|
||||||
|
gen_file_plain 20 included foo
|
||||||
|
gen_file_plain 20 included-two foo
|
||||||
|
gen_file_plain 20 included-two foobar
|
||||||
|
gen_file_plain 20 included-nested foobarbaz
|
||||||
|
|
||||||
|
gen_includes_file test-bundle 20 included included-two
|
||||||
|
gen_includes_file included 20 included-nested
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "full run update creation with delta packs" {
|
||||||
|
# build the first version
|
||||||
|
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
|
||||||
|
sudo $MAKE_FULLFILES --statedir $DIR 10
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 10 os-core
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 10 test-bundle
|
||||||
|
|
||||||
|
set_latest_ver 10
|
||||||
|
|
||||||
|
# then the second version...
|
||||||
|
sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 3
|
||||||
|
sudo $MAKE_FULLFILES --statedir $DIR 20
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 20 os-core
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 20 test-bundle
|
||||||
|
|
||||||
|
# and with delta packs this time
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 10 20 os-core
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 10 20 test-bundle
|
||||||
|
|
||||||
|
# zero packs should exist (non-zero size) for both versions
|
||||||
|
[ -s $DIR/www/10/pack-os-core-from-0.tar ]
|
||||||
|
[ -s $DIR/www/10/pack-test-bundle-from-0.tar ]
|
||||||
|
[ -s $DIR/www/20/pack-os-core-from-0.tar ]
|
||||||
|
[ -s $DIR/www/20/pack-test-bundle-from-0.tar ]
|
||||||
|
|
||||||
|
# and delta packs should exist (non-zero size) for the latest version
|
||||||
|
[ -s $DIR/www/20/pack-os-core-from-10.tar ]
|
||||||
|
[ -s $DIR/www/20/pack-test-bundle-from-10.tar ]
|
||||||
|
|
||||||
|
[[ 1 -eq $(grep '^includes: os-core$' $DIR/www/10/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/foo$' $DIR/www/10/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/foobarbaz$' $DIR/www/10/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 0 -eq $(grep '/foobar$' $DIR/www/20/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '^includes: os-core$' $DIR/www/20/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '^includes: included$' $DIR/www/20/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '^includes: included-two$' $DIR/www/20/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '^.d.. 0000000000000000000000000000000000000000000000000000000000000000 20 /foo$' $DIR/www/20/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '^.d.. 0000000000000000000000000000000000000000000000000000000000000000 20 /foobarbaz$' $DIR/www/20/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/foo$' $DIR/www/20/Manifest.included | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/foo$' $DIR/www/20/Manifest.included-two | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/foobar$' $DIR/www/20/Manifest.included-two | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/foobarbaz$' $DIR/www/20/Manifest.included-nested | wc -l) ]]
|
||||||
|
[[ 6 -eq $(tar -tf $DIR/www/10/pack-test-bundle-from-0.tar | wc -l) ]]
|
||||||
|
[[ 4 -eq $(tar -tf $DIR/www/20/pack-test-bundle-from-0.tar | wc -l) ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
#!/usr/bin/env bats
|
|
||||||
|
|
||||||
# common functions
|
|
||||||
load swupdlib
|
|
||||||
|
|
||||||
setup() {
|
|
||||||
DIR=$(init_web_dir "$srcdir/web-dir")
|
|
||||||
export DIR
|
|
||||||
|
|
||||||
init_server_ini
|
|
||||||
set_latest_ver 0
|
|
||||||
init_groups_ini os-core test-bundle
|
|
||||||
|
|
||||||
set_os_release 10 os-core
|
|
||||||
set_os_release 10 test-bundle
|
|
||||||
track_bundle 10 os-core
|
|
||||||
track_bundle 10 test-bundle
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "full run update creation" {
|
|
||||||
sudo $srcdir/swupd_create_update --osversion 10 --statedir $DIR
|
|
||||||
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 10
|
|
||||||
sudo $srcdir/swupd_make_pack --statedir $DIR 0 10 os-core
|
|
||||||
sudo $srcdir/swupd_make_pack --statedir $DIR 0 10 test-bundle
|
|
||||||
|
|
||||||
# zero packs should exist (non-zero size) for the build
|
|
||||||
[ -s $DIR/www/10/pack-os-core-from-0.tar ]
|
|
||||||
[ -s $DIR/www/10/pack-test-bundle-from-0.tar ]
|
|
||||||
}
|
|
||||||
|
|
||||||
teardown() {
|
|
||||||
sudo rm -rf $DIR
|
|
||||||
}
|
|
||||||
|
|
||||||
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
|
||||||
Executable
+45
@@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
# common functions
|
||||||
|
load "../swupdlib"
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
clean_test_dir
|
||||||
|
init_test_dir
|
||||||
|
|
||||||
|
init_server_ini
|
||||||
|
set_latest_ver 0
|
||||||
|
init_groups_ini os-core test-bundle
|
||||||
|
|
||||||
|
set_os_release 10 os-core
|
||||||
|
set_os_release 10 test-bundle
|
||||||
|
track_bundle 10 os-core
|
||||||
|
track_bundle 10 test-bundle
|
||||||
|
|
||||||
|
gen_file_plain 10 test-bundle foo
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "full run update creation" {
|
||||||
|
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
|
||||||
|
sudo $MAKE_FULLFILES --statedir $DIR 10
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 10 os-core
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 10 test-bundle
|
||||||
|
|
||||||
|
# zero packs should exist (non-zero size) for the build
|
||||||
|
[ -s $DIR/www/10/pack-os-core-from-0.tar ]
|
||||||
|
[ -s $DIR/www/10/pack-test-bundle-from-0.tar ]
|
||||||
|
|
||||||
|
[[ 1 -eq $(grep '^includes: os-core$' $DIR/www/10/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/usr/share/clear/bundles/test-bundle$' $DIR/www/10/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/foo$' $DIR/www/10/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/usr/share/clear/bundles/os-core$' $DIR/www/10/Manifest.os-core | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/usr$' $DIR/www/10/Manifest.os-core | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/usr/lib$' $DIR/www/10/Manifest.os-core | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/usr/share$' $DIR/www/10/Manifest.os-core | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/usr/share/clear$' $DIR/www/10/Manifest.os-core | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/usr/share/clear/bundles$' $DIR/www/10/Manifest.os-core | wc -l) ]]
|
||||||
|
[[ 4 -eq $(tar -tf $DIR/www/10/pack-test-bundle-from-0.tar | wc -l) ]]
|
||||||
|
[[ 9 -eq $(tar -tf $DIR/www/10/pack-os-core-from-0.tar | wc -l) ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||||
@@ -1,18 +1,20 @@
|
|||||||
#!/usr/bin/env bats
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load "../swupdlib"
|
||||||
|
|
||||||
@test "make_fullfiles required arg" {
|
@test "make_fullfiles required arg" {
|
||||||
run $srcdir/swupd_make_fullfiles
|
run $MAKE_FULLFILES
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "make_fullfiles too many arguments" {
|
@test "make_fullfiles too many arguments" {
|
||||||
# exactly one argument must be passed
|
# exactly one argument must be passed
|
||||||
run $srcdir/swupd_make_fullfiles foo bar
|
run $MAKE_FULLFILES foo bar
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "make_fullfiles root priv check" {
|
@test "make_fullfiles root priv check" {
|
||||||
run $srcdir/swupd_make_fullfiles foo
|
run $MAKE_FULLFILES foo
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
[[ "$output" =~ "not being run as root.. exiting" ]]
|
[[ "$output" =~ "not being run as root.. exiting" ]]
|
||||||
}
|
}
|
||||||
+99
@@ -0,0 +1,99 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
# common functions
|
||||||
|
load "../swupdlib"
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
clean_test_dir
|
||||||
|
init_test_dir
|
||||||
|
|
||||||
|
init_server_ini
|
||||||
|
set_latest_ver 0
|
||||||
|
init_groups_ini os-core test-bundle included included-two included-nested
|
||||||
|
|
||||||
|
set_os_release 10 os-core
|
||||||
|
track_bundle 10 os-core
|
||||||
|
track_bundle 10 test-bundle
|
||||||
|
|
||||||
|
set_os_release 20 os-core
|
||||||
|
track_bundle 20 os-core
|
||||||
|
track_bundle 20 test-bundle
|
||||||
|
track_bundle 20 included
|
||||||
|
track_bundle 20 included-two
|
||||||
|
|
||||||
|
set_os_release 30 os-core
|
||||||
|
track_bundle 30 os-core
|
||||||
|
track_bundle 30 test-bundle
|
||||||
|
track_bundle 30 included
|
||||||
|
track_bundle 30 included-two
|
||||||
|
track_bundle 30 included-nested
|
||||||
|
|
||||||
|
gen_file_plain 10 test-bundle foo
|
||||||
|
gen_file_plain 20 test-bundle foo
|
||||||
|
gen_file_plain 20 included bar
|
||||||
|
gen_file_plain 20 included-two baz
|
||||||
|
gen_file_plain 30 test-bundle foo
|
||||||
|
gen_file_plain 30 included bar
|
||||||
|
gen_file_plain 30 included-two baz
|
||||||
|
gen_file_plain 30 included-nested foobarbaz
|
||||||
|
|
||||||
|
gen_includes_file test-bundle 20 included included-two
|
||||||
|
gen_includes_file test-bundle 30 included included-two
|
||||||
|
gen_includes_file included 30 included-nested
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "full run update creation with delta packs" {
|
||||||
|
# build the first version
|
||||||
|
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
|
||||||
|
sudo $MAKE_FULLFILES --statedir $DIR 10
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 10 os-core
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 10 test-bundle
|
||||||
|
|
||||||
|
set_latest_ver 10
|
||||||
|
|
||||||
|
# then the second version...
|
||||||
|
sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 3
|
||||||
|
sudo $MAKE_FULLFILES --statedir $DIR 20
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 20 os-core
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 20 test-bundle
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 20 included
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 20 included-two
|
||||||
|
|
||||||
|
set_latest_ver 20
|
||||||
|
|
||||||
|
# then the third version...
|
||||||
|
sudo $CREATE_UPDATE --osversion 30 --statedir $DIR --format 3
|
||||||
|
sudo $MAKE_FULLFILES --statedir $DIR 30
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 30 os-core
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 30 test-bundle
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 30 included
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 30 included-two
|
||||||
|
sudo $MAKE_PACK --statedir $DIR 0 30 included-nested
|
||||||
|
|
||||||
|
# zero packs should exist (non-zero size) for both versions
|
||||||
|
[ -s $DIR/www/10/pack-os-core-from-0.tar ]
|
||||||
|
[ -s $DIR/www/10/pack-test-bundle-from-0.tar ]
|
||||||
|
[ -s $DIR/www/20/pack-os-core-from-0.tar ]
|
||||||
|
[ -s $DIR/www/20/pack-test-bundle-from-0.tar ]
|
||||||
|
[ -s $DIR/www/20/pack-included-from-0.tar ]
|
||||||
|
[ -s $DIR/www/20/pack-included-two-from-0.tar ]
|
||||||
|
[ -s $DIR/www/30/pack-os-core-from-0.tar ]
|
||||||
|
[ -s $DIR/www/30/pack-test-bundle-from-0.tar ]
|
||||||
|
[ -s $DIR/www/30/pack-included-from-0.tar ]
|
||||||
|
[ -s $DIR/www/30/pack-included-two-from-0.tar ]
|
||||||
|
[ -s $DIR/www/30/pack-included-nested-from-0.tar ]
|
||||||
|
|
||||||
|
[[ 1 -eq $(grep '^includes: os-core$' $DIR/www/10/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/foo$' $DIR/www/10/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '^includes: os-core$' $DIR/www/20/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '^includes: included$' $DIR/www/20/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '^includes: included-two$' $DIR/www/20/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/bar$' $DIR/www/20/Manifest.included | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/baz$' $DIR/www/20/Manifest.included-two | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '^includes: included-nested$' $DIR/www/30/Manifest.included | wc -l) ]]
|
||||||
|
[[ 1 -eq $(grep '/foobarbaz$' $DIR/www/30/Manifest.included-nested | wc -l) ]]
|
||||||
|
[[ 0 -eq $(ls $DIR/www/30/Manifest.test-bundle | wc -l) ]]
|
||||||
|
[[ 0 -eq $(ls $DIR/www/30/Manifest.included-two | wc -l) ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||||
@@ -1,24 +1,26 @@
|
|||||||
#!/usr/bin/env bats
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load "../swupdlib"
|
||||||
|
|
||||||
@test "make_pack required arg" {
|
@test "make_pack required arg" {
|
||||||
run $srcdir/swupd_make_pack
|
run $MAKE_PACK
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "make_pack too few arguments" {
|
@test "make_pack too few arguments" {
|
||||||
run $srcdir/swupd_make_pack foo
|
run $MAKE_PACK foo
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
run $srcdir/swupd_make_pack foo bar
|
run $MAKE_PACK foo bar
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "make_pack too many arguments" {
|
@test "make_pack too many arguments" {
|
||||||
run $srcdir/swupd_make_pack foo bar foo bar
|
run $MAKE_PACK foo bar foo bar
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "make_pack root priv check" {
|
@test "make_pack root priv check" {
|
||||||
run $srcdir/swupd_make_pack foo bar foo
|
run $MAKE_PACK foo bar foo
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
[[ "$output" =~ "not being run as root.. exiting" ]]
|
[[ "$output" =~ "not being run as root.. exiting" ]]
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,28 @@
|
|||||||
# NOTE: source this file from a *.bats file
|
# NOTE: source this file from a *.bats file
|
||||||
|
|
||||||
init_web_dir() {
|
# The location of the swupd_* binaries
|
||||||
# absolute path is a hard requirement right now
|
export SRCDIR="$BATS_TEST_DIRNAME/../../../"
|
||||||
local dir=$(realpath $1)
|
|
||||||
mkdir -p $dir/{image,www}
|
export CREATE_UPDATE="$SRCDIR/swupd_create_update"
|
||||||
echo $dir
|
export MAKE_FULLFILES="$SRCDIR/swupd_make_fullfiles"
|
||||||
|
export MAKE_PACK="$SRCDIR/swupd_make_pack"
|
||||||
|
|
||||||
|
export DIR="$BATS_TEST_DIRNAME/web-dir"
|
||||||
|
|
||||||
|
init_test_dir() {
|
||||||
|
local testdir="$BATS_TEST_DIRNAME"
|
||||||
|
mkdir -p "$testdir"/logs
|
||||||
|
mkdir -p $DIR/{image,www}
|
||||||
|
# run swupd_* inside the directory to dump the logs
|
||||||
|
cd "$testdir"/logs
|
||||||
|
}
|
||||||
|
|
||||||
|
clean_test_dir() {
|
||||||
|
sudo rm -rf $DIR "$BATS_TEST_DIRNAME"/logs
|
||||||
}
|
}
|
||||||
|
|
||||||
init_server_ini() {
|
init_server_ini() {
|
||||||
cp $srcdir/server.ini $DIR
|
cp $SRCDIR/server.ini $DIR
|
||||||
sed -i "s|/var/lib/update|$DIR|" $DIR/server.ini
|
sed -i "s|/var/lib/update|$DIR|" $DIR/server.ini
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,6 +53,18 @@ track_bundle() {
|
|||||||
touch $DIR/image/$ver/$bundle/usr/share/clear/bundles/$bundle
|
touch $DIR/image/$ver/$bundle/usr/share/clear/bundles/$bundle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gen_includes_file() {
|
||||||
|
local bundle=$1
|
||||||
|
local ver=$2
|
||||||
|
local includes="${@:3}"
|
||||||
|
mkdir -p $DIR/www/$ver/noship
|
||||||
|
for b in $includes; do
|
||||||
|
cat >> $DIR/www/$ver/noship/"$bundle"-includes << EOF
|
||||||
|
$b
|
||||||
|
EOF
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
gen_file_to_delta() {
|
gen_file_to_delta() {
|
||||||
local origver=$1
|
local origver=$1
|
||||||
local origsize=$2
|
local origsize=$2
|
||||||
@@ -58,4 +84,24 @@ gen_file_to_delta() {
|
|||||||
rm $TMP
|
rm $TMP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gen_file_plain() {
|
||||||
|
local ver=$1
|
||||||
|
local bundle=$2
|
||||||
|
local name="$3"
|
||||||
|
|
||||||
|
# Add plain text file into a bundle
|
||||||
|
mkdir -p $DIR/image/$ver/$bundle
|
||||||
|
echo "$name" > $DIR/image/$ver/$bundle/"$name"
|
||||||
|
}
|
||||||
|
|
||||||
|
gen_file_plain_change() {
|
||||||
|
local ver=$1
|
||||||
|
local bundle=$2
|
||||||
|
local name="$3"
|
||||||
|
|
||||||
|
# Add plain text file into a bundle
|
||||||
|
mkdir -p $DIR/image/$ver/$bundle
|
||||||
|
echo "$ver $name" > $DIR/image/$ver/$bundle/"$name"
|
||||||
|
}
|
||||||
|
|
||||||
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||||
|
|||||||
@@ -1,13 +1,21 @@
|
|||||||
#!/usr/bin/env bats
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
@test "create_update required arg" {
|
load "../swupdlib"
|
||||||
run $srcdir/swupd_create_update
|
|
||||||
|
@test "create_update required format" {
|
||||||
|
run $CREATE_UPDATE
|
||||||
|
[ "$status" -eq 1 ]
|
||||||
|
[[ "$output" =~ "Missing format parameter" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "create_update required version" {
|
||||||
|
run $CREATE_UPDATE -F 3
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
[[ "$output" =~ "Missing version parameter:" ]]
|
[[ "$output" =~ "Missing version parameter:" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "create_update root priv check" {
|
@test "create_update root priv check" {
|
||||||
run $srcdir/swupd_create_update -o 10
|
run $CREATE_UPDATE -F 3 -o 10
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
[[ "$output" =~ "not being run as root.. exiting" ]]
|
[[ "$output" =~ "not being run as root.. exiting" ]]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user