tAdd PACK_SEPARATOR to change pack name format - pm - barely a pack manager
HTML git clone git://z3bra.org/pm
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 1b21dc8ab5636c08e05308d6c09827f875cea1d3
DIR parent 6145d57d9b2344b47c1b3033b0ac9a4c6328d722
HTML Author: z3bra <willyatmailoodotorg>
Date: Sat, 16 Jan 2016 16:40:08 +0100
Add PACK_SEPARATOR to change pack name format
On the process, the default separator is now '#', as ':' can
be problematic when using rsync(1) or scp(1) (and probably other
softwares/protocols)
One can now change the separator used by pm(1) simply by updating the
macro value in the source.
Diffstat:
M README | 52 ++++++++++++++++++++++---------
M pack.5 | 6 +++---
M pm.c | 5 +++--
3 files changed, 44 insertions(+), 19 deletions(-)
---
DIR diff --git a/README b/README
t@@ -11,7 +11,7 @@ A pack manager.
pm -d pack [pack..]
# update packs
- pm -u pack:0.1.tar.bz2 [pack..]
+ pm -u pack#0.1.tar.bz2 [pack..]
# list installed packs
pm -i
t@@ -28,19 +28,44 @@ your pack.
$ ROOT=/ns/pm/rootfs
$ META=$ROOT/metadata
$ export ROOT META
- $ pm -a ./pack:0.0.tar.bz2
+ $ pm -a ./pack#0.0.tar.bz2
$ tree $ROOT
/ns/pm/rootfs
- ├── bin
- │ └── pm
- ├── metadata
- │ └── pack
- │ ├── files
- │ └── version
- └── share
- └── man
- └── man1
- └── pm.1
+ |-- bin
+ | `-- pack
+ |-- metadata
+ | `-- pack
+ | |-- files
+ | `-- version
+ `-- share
+ `-- man
+ `-- man1
+ `-- pack.1
+
+The name of a pack should be constructed as follow:
+
+ ${NAME}${SEPARATOR}${VERSION}${EXTENSTION}
+
+NAME: name of the pack
+VERSION: version of the pack
+SEPARATOR: a unique char within the whole pack name
+EXTENSTION: whichever extenstion you want
+
+The format used by default is pack#version.tar.bz2
+As example, the following pack names are valid:
+
+* pack:0.0-1.tar.bz2
+* pack#0.0-1.pkg
+* pack,0.0-1:pack
+* pack_0.0-1.tar.bz2
+
+On the other side, the following are NOT valid:
+
+* pack-0.0-1.tar.bz2
+* pack.0.0-1.pkg
+* pack_name_0.0.tar.bz2
+* pack#0.0-1#tar.bz2
+
## goals
0. install
t@@ -65,4 +90,4 @@ your pack.
4.1 store installed files
## license
-This software is licensed under the ISC license, see the LICENSE file provided.
-\ No newline at end of file
+This software is licensed under the ISC license, see the LICENSE file provided.
DIR diff --git a/pack.5 b/pack.5
t@@ -12,7 +12,7 @@ to install softwares under a directory.
.Ss FILENAME
The pack name is used to extract informations about it content, and should
follow a strict naming scheme:
-.Pa <name>:<version>.tar.bz2
+.Pa <name>#<version>.tar.bz2
.Ss ARCHIVE FORMAT
A pack is a
.Em bzip2
t@@ -43,12 +43,12 @@ workflow to create packs would be the following:
make
make DESTDIR=/tmp/rootfs install
cd /tmp/rootfs
-tar -c $(ls) | bzip2 > /tmp/pm:0.0.tar.bz2
+tar -c $(ls) | bzip2 > /tmp/pm#0.0.tar.bz2
.Ed
.Pp
You can check the content of this pack with:
.Bd -literal -width Ds -offset indent
-bzip2 -cd < /tmp/pm:0.0.tar.bz2 | tar -t
+bzip2 -cd < /tmp/pm#0.0.tar.bz2 | tar -t
.Ed
.Sh SEE ALSO
.Xr pm 1 ,
DIR diff --git a/pm.c b/pm.c
t@@ -16,6 +16,7 @@
#define PACK_ROOT (getenv("ROOT")?getenv("ROOT"):"/ns/pm/rootfs")
#define PACK_DATA (getenv("META")?getenv("META"):"/ns/pm/rootfs/metadata")
#define PACK_BUFF_SIZE 8192
+#define PACK_SEPARATOR '#'
#define PACK_EXTENSION ".tar.bz2"
struct pack {
t@@ -567,14 +568,14 @@ pack_load(char *path)
pack->path = strdup(path);
snprintf(tmp, PATH_MAX, "%s", base_name(path));
- for (p = tmp; *p && *p != ':'; p++);
+ for (p = tmp; *p && *p != PACK_SEPARATOR; p++);
if (!*p) {
pack_free(pack);
return NULL;
}
*p = 0;
pack->name = strdup(tmp);
- *p = ':';
+ *p = PACK_SEPARATOR;
snprintf(tmp, PATH_MAX, "%s", p + 1);
for (p = tmp; *p && strcmp(p, PACK_EXTENSION); p++);