aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2020-03-24 14:51:59 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2020-03-25 17:16:05 -0400
commit838c8723e314782c255011536126b95e9d6a97f9 (patch)
treeaaef6390df688a75bd6af1f3b6b1d33c07ab9e30
parentae3eb38592cb40011fd026d3c7c64ebc022bedca (diff)
downloadspmc-838c8723e314782c255011536126b95e9d6a97f9.tar.gz
Add .circleci/config.yml
-rw-r--r--.circleci/config.yml41
-rwxr-xr-x.circleci/init.sh16
-rwxr-xr-x.circleci/install_reloc.sh8
-rwxr-xr-x.circleci/install_spm.sh5
-rwxr-xr-x.circleci/test_spm.sh13
-rw-r--r--include/manifest.h12
-rw-r--r--include/spm.h1
-rw-r--r--include/version_spec.h2
-rw-r--r--lib/config_global.c24
-rw-r--r--lib/manifest.c12
-rw-r--r--lib/version_spec.c4
11 files changed, 109 insertions, 29 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 0000000..270bd76
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,41 @@
+version: 2.1
+
+jobs:
+ build:
+ docker:
+ - image: centos:7
+
+ environment:
+ MALLOC_CHECK_: 1
+
+ working_directory: ~/build
+
+ steps:
+ - run:
+ name: "Prepare"
+ command: |
+ yum install -y epel-release
+ yum install -y git
+
+ - checkout
+
+ - run:
+ name: "Initialize"
+ command: |
+ .circleci/init.sh
+
+ - run:
+ name: "Install reloc"
+ command: |
+ .circleci/install_reloc.sh
+
+
+ - run:
+ name: "Install spm"
+ command: |
+ .circleci/install_spm.sh
+
+ - run:
+ name: "Run tests"
+ command: |
+ .circleci/test_spm.sh
diff --git a/.circleci/init.sh b/.circleci/init.sh
new file mode 100755
index 0000000..81c5091
--- /dev/null
+++ b/.circleci/init.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+yum install -y \
+ make \
+ patchelf \
+ binutils \
+ curl-devel \
+ openssl-devel \
+ file \
+ which \
+ rsync \
+ tar \
+ cmake3 \
+ gcc \
+ gcc-c++ \
+ gcc-gfortran \
+ glibc-devel
diff --git a/.circleci/install_reloc.sh b/.circleci/install_reloc.sh
new file mode 100755
index 0000000..35945f3
--- /dev/null
+++ b/.circleci/install_reloc.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+git clone https://github.com/jhunkeler/reloc
+mkdir -p reloc/build
+pushd reloc/build
+ cmake3 -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release ..
+ make install
+popd
+rm -rf reloc
diff --git a/.circleci/install_spm.sh b/.circleci/install_spm.sh
new file mode 100755
index 0000000..4aaea1c
--- /dev/null
+++ b/.circleci/install_spm.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+mkdir build
+cd build
+cmake3 -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Debug ..
+make install
diff --git a/.circleci/test_spm.sh b/.circleci/test_spm.sh
new file mode 100755
index 0000000..f70b60f
--- /dev/null
+++ b/.circleci/test_spm.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+set -e
+
+export SHELL=/bin/bash
+cd build
+
+set -x
+
+ctest3 -V
+
+spm --list
+
+spm --search zlib
diff --git a/include/manifest.h b/include/manifest.h
index 4d503aa..6724156 100644
--- a/include/manifest.h
+++ b/include/manifest.h
@@ -37,7 +37,7 @@ typedef struct {
} ManifestList;
int fetch(const char *url, const char *dest);
-int manifest_package_cmp(ManifestPackage *a, ManifestPackage *b);
+int manifest_package_cmp(const ManifestPackage *a, const ManifestPackage *b);
void manifest_package_separator_swap(char **name);
void manifest_package_separator_restore(char **name);
Manifest *manifest_from(const char *package_dir);
@@ -45,15 +45,15 @@ Manifest *manifest_read(char *file_or_url);
int manifest_write(Manifest *info, const char *dest);
void manifest_free(Manifest *info);
void manifest_package_free(ManifestPackage *info);
-ManifestPackage *manifest_search(Manifest *info, const char *package);
-ManifestPackage *find_by_strspec(Manifest *manifest, const char *_strspec);
-ManifestPackage *manifest_package_copy(ManifestPackage *manifest);
+ManifestPackage *manifest_search(const Manifest *info, const char *package);
+ManifestPackage *find_by_strspec(const Manifest *manifest, const char *_strspec);
+ManifestPackage *manifest_package_copy(const ManifestPackage *manifest);
ManifestList *manifestlist_init();
-Manifest *manifestlist_item(ManifestList *pManifestList, size_t index);
+Manifest *manifestlist_item(const ManifestList *pManifestList, size_t index);
void manifestlist_set(ManifestList *pManifestList, size_t index, Manifest *manifest);
ManifestPackage *manifestlist_search(ManifestList *pManifestList, const char *_package);
-size_t manifestlist_count(ManifestList *pManifestList);
+size_t manifestlist_count(const ManifestList *pManifestList);
void manifestlist_append(ManifestList *pManifestList, char* path);
void manifestlist_free(ManifestList *pManifestList);
#endif //SPM_MANIFEST_H
diff --git a/include/spm.h b/include/spm.h
index a0fc16e..895354f 100644
--- a/include/spm.h
+++ b/include/spm.h
@@ -19,7 +19,6 @@
#include <unistd.h>
#include <time.h>
#include <sys/stat.h>
-#include <wordexp.h>
#include <openssl/md5.h>
#include <openssl/sha.h>
diff --git a/include/version_spec.h b/include/version_spec.h
index 01c4e7d..69dc135 100644
--- a/include/version_spec.h
+++ b/include/version_spec.h
@@ -19,6 +19,6 @@ int64_t version_suffix_modifier_calc(char *str);
int version_suffix_alpha_calc(char *str);
int64_t version_from(const char *version_str);
int version_spec_from(const char *op);
-ManifestPackage **find_by_spec(Manifest *manifest, const char *name, const char *op, const char *version_str);
+ManifestPackage **find_by_spec(const Manifest *manifest, const char *name, const char *op, const char *version_str);
#endif //SPM_VERSION_SPEC_H
diff --git a/lib/config_global.c b/lib/config_global.c
index 16d97cf..f63566b 100644
--- a/lib/config_global.c
+++ b/lib/config_global.c
@@ -10,20 +10,16 @@
*/
char *get_user_conf_dir(void) {
char *result = NULL;
- wordexp_t wexp;
- wordexp("~/.spm", &wexp, 0);
- if (wexp.we_wordc != 0) {
- result = (char *)calloc(strlen(wexp.we_wordv[0]) + 1, sizeof(char));
- if (!result) {
- wordfree(&wexp);
- return NULL;
- }
- strncpy(result, wexp.we_wordv[0], strlen(wexp.we_wordv[0]));
- if (access(result, F_OK) != 0) {
- mkdirs(result, 0755);
- }
+
+ result = expandpath("~/.spm");
+ if (result == NULL) {
+ perror("get_user_conf_dir");
+ return NULL;
+ }
+
+ if (access(result, F_OK) != 0) {
+ mkdirs(result, 0755);
}
- wordfree(&wexp);
return result;
}
@@ -44,6 +40,7 @@ char *get_user_config_file(void) {
sprintf(template, "%s%c%s", ucd, DIRSEP, filename);
if (access(template, F_OK) != 0) {
// No configuration exists, so fail
+ free(ucd);
return NULL;
}
free(ucd);
@@ -109,6 +106,7 @@ char *get_package_manifest(void) {
if (manifest == NULL) {
perror("manifest generator");
fprintf(SYSERROR);
+ free(ucd);
return NULL;
}
manifest_write(manifest, PKG_DIR);
diff --git a/lib/manifest.c b/lib/manifest.c
index 1b2b600..72919ff 100644
--- a/lib/manifest.c
+++ b/lib/manifest.c
@@ -11,7 +11,7 @@
* @param b
* @return 0 = same, !0 = different
*/
-int manifest_package_cmp(ManifestPackage *a, ManifestPackage *b) {
+int manifest_package_cmp(const ManifestPackage *a, const ManifestPackage *b) {
int result = 0;
if (a == NULL || b == NULL) {
return -1;
@@ -517,7 +517,7 @@ Manifest *manifest_read(char *file_or_url) {
* @param _package package name
* @return found=`ManifestPackage`, not found=NULL
*/
-ManifestPackage *manifest_search(Manifest *info, const char *_package) {
+ManifestPackage *manifest_search(const Manifest *info, const char *_package) {
ManifestPackage *match = NULL;
char package[PATH_MAX];
@@ -535,7 +535,7 @@ ManifestPackage *manifest_search(Manifest *info, const char *_package) {
* @param manifest
* @return `ManifestPackage`
*/
-ManifestPackage *manifest_package_copy(ManifestPackage *manifest) {
+ManifestPackage *manifest_package_copy(const ManifestPackage *manifest) {
if (manifest == NULL) {
return NULL;
}
@@ -543,7 +543,7 @@ ManifestPackage *manifest_package_copy(ManifestPackage *manifest) {
ManifestPackage *result = calloc(1, sizeof(ManifestPackage));
memcpy(result, manifest, sizeof(ManifestPackage));
- if (manifest->requirements_records > 0) {
+ if (manifest->requirements_records > 0 && manifest->requirements != NULL) {
result->requirements = (char **)calloc(manifest->requirements_records, sizeof(char *));
for (size_t i = 0; i < manifest->requirements_records; i++) {
result->requirements[i] = strdup(manifest->requirements[i]);
@@ -615,7 +615,7 @@ ManifestPackage *manifestlist_search(ManifestList *pManifestList, const char *_p
* @param ManifestList
* @return
*/
-size_t manifestlist_count(ManifestList *pManifestList) {
+size_t manifestlist_count(const ManifestList *pManifestList) {
return pManifestList->num_inuse;
}
@@ -642,7 +642,7 @@ void manifestlist_set(ManifestList *pManifestList, size_t index, Manifest *value
* @param index
* @return string
*/
-Manifest *manifestlist_item(ManifestList *pManifestList, size_t index) {
+Manifest *manifestlist_item(const ManifestList *pManifestList, size_t index) {
if (index > manifestlist_count(pManifestList)) {
return NULL;
}
diff --git a/lib/version_spec.c b/lib/version_spec.c
index 06fcd1b..d7c8b2e 100644
--- a/lib/version_spec.c
+++ b/lib/version_spec.c
@@ -279,7 +279,7 @@ static int _find_by_spec_compare(const void *a, const void *b) {
* @param version_str
* @return
*/
-ManifestPackage **find_by_spec(Manifest *manifest, const char *name, const char *op, const char *version_str) {
+ManifestPackage **find_by_spec(const Manifest *manifest, const char *name, const char *op, const char *version_str) {
size_t record = 0;
ManifestPackage **list = (ManifestPackage **) calloc(manifest->records + 1, sizeof(ManifestPackage *));
if (!list) {
@@ -387,7 +387,7 @@ static char *get_operators(char **op, const char *_strspec) {
return pos;
}
-ManifestPackage *find_by_strspec(Manifest *manifest, const char *_strspec) {
+ManifestPackage *find_by_strspec(const Manifest *manifest, const char *_strspec) {
char *pos = NULL;
char s_op[NAME_MAX];
char s_name[NAME_MAX];