remove pkg(1): we regret the error
This commit is contained in:
parent
ff2e8f308d
commit
0853e2cc3b
8 changed files with 0 additions and 323 deletions
122
sys/man/1/pkg
122
sys/man/1/pkg
|
@ -1,122 +0,0 @@
|
|||
.TH PKG 1
|
||||
.SH NAME
|
||||
create, install, list, local, remove, unpkg \- trivial package management
|
||||
.SH SYNOPSIS
|
||||
.B pkg/create
|
||||
.I name
|
||||
.br
|
||||
.B pkg/install
|
||||
.I name
|
||||
.br
|
||||
.B pkg/list
|
||||
.br
|
||||
.B pkg/local
|
||||
.br
|
||||
.B pkg/remove
|
||||
.I name
|
||||
.br
|
||||
.B pkg/unpkg
|
||||
.SH DESCRIPTION
|
||||
.I Pkg
|
||||
is a simple package management system primarily written in
|
||||
.IR rc (1).
|
||||
It can be used to create, install, and remove software packages
|
||||
from an arbitrary package repository, indicated by the environment
|
||||
variable
|
||||
.I $pkgpath.
|
||||
If
|
||||
.I $pkgpath
|
||||
is not set, the system defaults to a hardcoded repository of approved
|
||||
packages.
|
||||
.TP
|
||||
.I Pkg/create
|
||||
Create builds a new package
|
||||
.IR name ,
|
||||
whose source is found in directory
|
||||
.IR name ,
|
||||
then packs it into a
|
||||
.I bzip2 (see
|
||||
.IR gzip (1))
|
||||
compressed
|
||||
.IR tar (1)
|
||||
archive suitable for upload to a package
|
||||
repository. The source directory should be provided as a full path.
|
||||
.TP
|
||||
.I Pkg/install
|
||||
Install the package
|
||||
.I name
|
||||
from the current repository, unpacking the executables in
|
||||
.B /$cputype/bin/
|
||||
or
|
||||
.B /rc/bin/
|
||||
and the source in
|
||||
.B /sys/src/pkg/.
|
||||
.TP
|
||||
.I Pkg/list
|
||||
List packages available from the current repository.
|
||||
.TP
|
||||
.I Pkg/local
|
||||
List locally installed packages.
|
||||
.TP
|
||||
.I Pkg/remove
|
||||
Remove the package
|
||||
.I name
|
||||
from the local system.
|
||||
.TP
|
||||
.I Pkg/unpkg
|
||||
A modified
|
||||
.IR tar (1)
|
||||
used by
|
||||
.B pkg/install
|
||||
to generate checksums for every unpacked file.
|
||||
.SH EXAMPLES
|
||||
.LP
|
||||
Create the package
|
||||
.B irc7-2012.06.22:
|
||||
.sp 1
|
||||
.EX
|
||||
% pkg/create /sys/src/pkg/irc7-2012.06.22
|
||||
.EE
|
||||
|
||||
.LP
|
||||
Install the
|
||||
.B mpm
|
||||
troff macros:
|
||||
.sp 1
|
||||
.EX
|
||||
% pkg/install mpm-2011.05.14
|
||||
.EE
|
||||
.SH FILES
|
||||
.TF
|
||||
.TP
|
||||
.B /sys/lib/pkg/*
|
||||
hash files of packages installed locally.
|
||||
.TP
|
||||
.B /sys/src/pkg/*
|
||||
source files of packages installed locally.
|
||||
.SH SOURCE
|
||||
.B /sys/src/cmd/pkg/create
|
||||
.br
|
||||
.B /sys/src/cmd/pkg/install
|
||||
.br
|
||||
.B /sys/src/cmd/pkg/list
|
||||
.br
|
||||
.B /sys/src/cmd/pkg/local
|
||||
.br
|
||||
.B /sys/src/cmd/pkg/remove
|
||||
.br
|
||||
.B /sys/src/cmd/pkg/unpkg.c
|
||||
.SH REPOSITORIES
|
||||
.B http://9front.org/pkg/386
|
||||
.br
|
||||
.B https://offblast.org/pkg/386
|
||||
.br
|
||||
.B https://offblast.org/pkg/amd64
|
||||
.br
|
||||
.B http://plan9.bell-labs.com/sources/contrib/staal1978/pkg
|
||||
.SH SEE ALSO
|
||||
.IR gzip (1) ,
|
||||
.IR tar (1)
|
||||
.SH HISTORY
|
||||
.I Pkg
|
||||
first appeared in 9front (May, 2011).
|
|
@ -1,23 +0,0 @@
|
|||
#!/bin/rc -e
|
||||
|
||||
i=`{basename $1}
|
||||
d=$1
|
||||
echo Creating $i
|
||||
C=`{pwd}
|
||||
@{
|
||||
rfork en
|
||||
mkdir -p /tmp/$i/files/sys/src/pkg/$i
|
||||
dircp $d /tmp/$i/files/sys/src/pkg/$i
|
||||
cd $d
|
||||
mk
|
||||
divergefs -p /tmp/$i /
|
||||
mk install
|
||||
mk clean
|
||||
unmount /
|
||||
}
|
||||
cd /tmp/$i/files
|
||||
rm -r env
|
||||
tar cv * | bzip2 -9 > $C/$i.tbz
|
||||
cd /tmp
|
||||
rm -r $i
|
||||
echo Created $C/$i.tbz
|
|
@ -1,19 +0,0 @@
|
|||
#!/bin/rc
|
||||
|
||||
if(~ $#pkgpath 0)
|
||||
pkgpath=http://9front.org/pkg/$cputype
|
||||
|
||||
cd /
|
||||
mkdir -p /sys/lib/pkg
|
||||
if (test -s /sys/lib/pkg/$1) {
|
||||
echo $1 already installed
|
||||
exit
|
||||
}
|
||||
echo Installing $1
|
||||
if(~ $pkgpath ftp* http*)
|
||||
cmd=hget
|
||||
if not
|
||||
cmd=cat
|
||||
if(! $cmd $pkgpath/$1.tbz | bunzip2 | pkg/unpkg >/sys/lib/pkg/$1)
|
||||
if(! test -s /sys/lib/pkg/$1)
|
||||
rm -f /sys/lib/pkg/$1
|
|
@ -1,9 +0,0 @@
|
|||
#!/bin/rc
|
||||
|
||||
if(~ $#pkgpath 0)
|
||||
pkgpath=http://9front.org/pkg/$cputype
|
||||
|
||||
if(~ $pkgpath ftp* http*)
|
||||
hget $pkgpath | htmlfmt | grep '\.tbz' | sed -e 's/\.tbz.*$//g' | awk '{print $NF}'
|
||||
if not
|
||||
ls -p $pkgpath/*.tbz | sed 's/\.tbz.*$//g'
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/rc
|
||||
|
||||
ls -p /sys/lib/pkg
|
|
@ -1,20 +0,0 @@
|
|||
</$objtype/mkfile
|
||||
|
||||
all: $O.unpkg
|
||||
echo
|
||||
|
||||
$O.unpkg: unpkg.c
|
||||
$CC unpkg.c
|
||||
$LD -o $O.unpkg unpkg.$O
|
||||
|
||||
install:V: $O.unpkg
|
||||
mkdir -p /$objtype/bin/pkg
|
||||
cp $O.unpkg /$objtype/bin/pkg/unpkg
|
||||
cp create install list local remove /$objtype/bin/pkg
|
||||
|
||||
clean:
|
||||
rm -f $O.unpkg *.$O
|
||||
|
||||
nuke: clean
|
||||
rm -f /$objtype/bin/pkg/*
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#!/bin/rc -e
|
||||
|
||||
cd /
|
||||
if(test -s /sys/lib/pkg/$1) {
|
||||
fs=(`{cat /sys/lib/pkg/$1 | awk '{print $1}'})
|
||||
ss=(`{cat /sys/lib/pkg/$1 | awk '{print $2}'})
|
||||
for(i in `{seq $#fs}) {
|
||||
s=`{sha1sum $fs($i) | awk '{print $1}' | tr a-z A-Z}
|
||||
if(test $s '=' $ss($i)) {
|
||||
echo D $fs($i)
|
||||
rm $fs($i)
|
||||
}
|
||||
if not {
|
||||
echo M $fs($i) NOT DELETING
|
||||
}
|
||||
}
|
||||
rm -rf /sys/src/pkg/$1
|
||||
rm /sys/lib/pkg/$1
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
#include <u.h>
|
||||
#include <libc.h>
|
||||
#include <mp.h>
|
||||
#include <libsec.h>
|
||||
|
||||
struct th {
|
||||
char *name;
|
||||
ulong perm;
|
||||
ulong size;
|
||||
char type;
|
||||
char *user, *group;
|
||||
};
|
||||
|
||||
static char *sndup(char* s, ulong n) {
|
||||
char *d, *p;
|
||||
p = memchr(s, 0, n);
|
||||
if(p)
|
||||
n = p-s;
|
||||
d = malloc(n+1);
|
||||
memcpy(d,s,n);
|
||||
d[n] = 0;
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
int readheader(struct th* th) {
|
||||
int i;
|
||||
char b[512];
|
||||
|
||||
if(readn(0, b, 512) != 512) return -1;
|
||||
|
||||
// Check for end of archive
|
||||
for(i=0; i<512; i++) {
|
||||
if(b[i]!=0) goto rhok;
|
||||
}
|
||||
if(readn(0, b, 512) != 512) return -1;
|
||||
for(i=0; i<512; i++) {
|
||||
if(b[i]!=0) return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
rhok:
|
||||
th->name = cleanname(sndup(b, 100));
|
||||
th->perm = strtoul(b+100, nil, 8);
|
||||
th->size = strtoul(b+124, nil, 8);
|
||||
th->type = b[156];
|
||||
th->user = sndup(b+265, 32);
|
||||
th->group= sndup(b+297, 32);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void main(int argc, char *argv[]) {
|
||||
ARGBEGIN {
|
||||
} ARGEND;
|
||||
for(;;) {
|
||||
struct th th;
|
||||
ulong off;
|
||||
uchar b[512];
|
||||
char err[ERRMAX];
|
||||
DigestState *s;
|
||||
int r, wfd;
|
||||
|
||||
r = readheader(&th);
|
||||
if(r == 0)
|
||||
exits(nil);
|
||||
if(r < 0)
|
||||
sysfatal("unexpected eof");
|
||||
|
||||
switch(th.type) {
|
||||
case '5':
|
||||
if((wfd = create(th.name, OREAD, DMDIR|th.perm)) >= 0)
|
||||
close(wfd);
|
||||
break;
|
||||
case '0': case 0:
|
||||
fprint(2, "A %s\n", th.name);
|
||||
if((wfd = create(th.name, OWRITE|OEXCL, th.perm)) < 0)
|
||||
sysfatal("%r", th.name);
|
||||
s = nil;
|
||||
for(off=0; off<th.size; off+=512) {
|
||||
if(readn(0, b, 512) == 512){
|
||||
if((r = th.size-off) > 512)
|
||||
r = 512;
|
||||
if(write(wfd, b, r) == r){
|
||||
s = sha1(b, r, nil, s);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
errstr(err, sizeof(err));
|
||||
remove(th.name);
|
||||
errstr(err, sizeof(err));
|
||||
sysfatal("%s: %r", th.name);
|
||||
}
|
||||
|
||||
uchar digest[20], hdigest[41];
|
||||
sha1(nil, 0, digest, s);
|
||||
enc16((char*)hdigest, 41, digest, 20);
|
||||
print("%s\t%s\n", th.name, hdigest);
|
||||
close(wfd);
|
||||
break;
|
||||
default:
|
||||
sysfatal("Unknown file type '%c'", th.type);
|
||||
}
|
||||
|
||||
free(th.name);
|
||||
free(th.user);
|
||||
free(th.group);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue