X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwgtpkg-install.c;h=c7de1f824263e1f4834b2cbdf35b531ef239c570;hb=7ea1070ee471141f58e9e4c03df5c95bbcef907d;hp=9c148c77a465a766380d5350a8f981669b678a07;hpb=6008a3ec4d1c0ed5df338b7c5f0775585ab51cfb;p=src%2Fapp-framework-main.git diff --git a/src/wgtpkg-install.c b/src/wgtpkg-install.c index 9c148c7..c7de1f8 100644 --- a/src/wgtpkg-install.c +++ b/src/wgtpkg-install.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2019 IoT.bzh + Copyright (C) 2015-2020 IoT.bzh author: José Bollo @@ -53,7 +53,7 @@ static const char* exec_type_strings[] = { }; static const char key_afm_prefix[] = "X-AFM-"; -static const char key_afid[] = "-ID"; +static const char key_afid[] = "ID"; #define HTTP_PORT_BASE 30000 @@ -62,8 +62,8 @@ static const char key_afid[] = "-ID"; #define AFID_IS_VALID(afid) (AFID_MIN <= (afid) && (afid) <= AFID_MAX) #define AFID_COUNT (AFID_MAX - AFID_MIN + 1) #define AFID_ACNT ((AFID_COUNT + 31) >> 5) -#define AFID_ASFT(afid) (((afid) - AFID_MIN) & 31) -#define AFID_AIDX(afid) (((afid) - AFID_MIN) >> 5) +#define AFID_ASFT(afid) (((afid) - AFID_MIN) & 31) +#define AFID_AIDX(afid) (((afid) - AFID_MIN) >> 5) #define AFID_TEST(array,afid) ((((array)[AFID_AIDX(afid)]) >> AFID_ASFT(afid)) & 1) #define AFID_SET(array,afid) (((array)[AFID_AIDX(afid)]) |= (((uint32_t)1) << AFID_ASFT(afid))) @@ -186,6 +186,12 @@ static int get_new_afid() /* allocates the afid */ afid = first_free_afid(afids_array); + if (afid < 0 && errno == EADDRNOTAVAIL) { + /* no more ids, try to rescan */ + memset(afids_array, 0, AFID_ACNT * sizeof(uint32_t)); + if (update_afids(afids_array) >= 0) + afid = first_free_afid(afids_array); + } if (afid >= 0) AFID_SET(afids_array, afid); @@ -392,7 +398,11 @@ static int get_target_directory(char target[PATH_MAX], const char *root, const s { int rc; +#if DISTINCT_VERSIONS rc = snprintf(target, PATH_MAX, "%s/%s/%s", root, desc->id, desc->ver); +#else + rc = snprintf(target, PATH_MAX, "%s/%s", root, desc->id); +#endif if (rc < PATH_MAX) rc = 0; else { @@ -557,7 +567,7 @@ struct wgt_info *install_widget(const char *wgtfile, const char *root, int force struct wgt_info *ifo; const struct wgt_desc *desc; char installdir[PATH_MAX]; - int err; + int err, rc; struct unitconf uconf; NOTICE("-- INSTALLING widget %s to %s --", wgtfile, root); @@ -572,7 +582,12 @@ struct wgt_info *install_widget(const char *wgtfile, const char *root, int force if (zread(wgtfile, 0)) goto error2; - if (check_all_signatures(DEFAULT_ALLOW_NO_SIGNATURE)) +#if defined(ALLOW_NO_SIGNATURE) + rc = check_all_signatures(1); +#else + rc = check_all_signatures(0); +#endif + if (rc) goto error2; ifo = wgt_info_createat(workdirfd, NULL, 1, 1, 1);