Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pcy
sspt
Commits
ed4a0a35
Commit
ed4a0a35
authored
Jul 23, 2017
by
PoroCYon
Browse files
added 'install'
parent
019f3ad6
Changes
9
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
ed4a0a35
...
...
@@ -3,25 +3,32 @@
*samselplatro*
-- A semidecent 'package manager' meant for installing and
updating the upstream version of a program. It does
***NOT**
*
try to be a
full-fledged package manager for systemwide use. It does
***NOT**
*
keep
track of dependencies.
track of dependencies, files owned by multiple packages, etc.
Packages are installed per-users, and there is currently no way to install
them globally (aside from using sspt to invoke the system package manager).
I made this because I thought
`ls | xargs "!f() { pushd $1 && git pull && make && make install && popd }; f"`
is only slightly too hacky.
`sspt`
is a slightly nicer way for doing this.
I suggest you don't use this on systems where you don't want broken
packages to happen.
## Dependencies
*
`coreutils`
*
`bash`
*
`strace`
### Optional
*
`git`
,
`hg`
,
`svn`
,
`cvs`
,
`bzr`
,
`mtn`
,
`darcs`
,
`curl`
/
`wget`
,
`rsync`
: for support for the respecitve VCS (or 'VCS') types.
`unar`
is required for
`curl`
/
`wget`
and
`rsync`
.
*
`npm`
,
`cargo`
,
`setuptools`
,
`idris`
,
`xbuild`
,
`stack`
,
`cabal`
,
`scons`
,
`gradle`
,
`sbt`
,
`bazel`
,
`meson`
,
`ninja`
,
`ant`
,
`maven`
,
`cmake`
,
`qmake`
,
`autoconf`
/
`autotools`
,
`make`
: for support for the
respective build system types.
*
`pacman`
/
`alpm`
,
`apk-tools`
,
`npm`
,
`cargo`
,
`setuptools`
,
`idris`
,
`xbuild`
,
`stack`
,
`cabal`
,
`scons`
,
`gradle`
,
`sbt`
,
`bazel`
,
`meson`
,
`ninja`
,
`ant`
,
`maven`
,
`cmake`
,
`qmake`
,
`autoconf`
/
`autotools`
,
`make`
: for support for the
respective build system types.
## Installation
...
...
@@ -29,7 +36,8 @@ is only slightly too hacky. `sspt` is a slightly nicer way for doing this.
./sspt-bootstrap
```
**NOTE: this currently does not work, as `install` isn't implemented yet.**
***NOTE**
*
: this currently does not work, as there is no
`.sspt`
file
yet for sspt itself...
## Usage
...
...
@@ -42,11 +50,13 @@ The default location of the configuration file is
these four environment variables:
*
`SSPT_DEST_DIR`
: The directory where packages should be installed in
(think Makefile
`PREFIX`
).
*
`SSPT_SUB_DIR`
: The directory where the subcommands reside.
(think Makefile
`PREFIX`
). This defaults to
`$HOME/.local`
*
`SSPT_SUB_DIR`
: The directory where the subcommands reside. This
defaults to
`$HOME/.local/libexec/sspt`
.
*
`SSPT_DB_DIR`
: The directory where the sspt database of pulled and
installed packages resides.
installed packages resides.
This defaults to
`$HOME/.local/share/sspt`
.
*
`SSPT_DL_DIR`
: The directory where sspt downloads the repositories to.
This defaults to
`$HOME/src/sspt`
The location of the config file can be specified using the
`-c`
flag.
...
...
@@ -98,19 +108,22 @@ This currently requires the package to be pulled.
sspt build sspt
```
NOTE: currently, it doesn't automatically configure the package.
NOTE: currently, it doesn't automatically configure the package. You
might want to run
`sspt configure sspt`
first.
### Installing a package
This currently requires the package to be pulled (And probably built
as well, when this is implemented).
'Installing' simply means executing 'make install' or its equivalent,
no fancy package management stuff is done, aside from keeping track of
which files have been installed. sspt does not check whether a file is
owned by multiple packages.
This currently requires the package to be pulled and compiled.
```
sspt install sspt
```
**NOTE: This is not yet implemented.**
You can use
`sspt pkgcmd install sspt`
to directly install the package,
but this doesn't take care of:
...
...
@@ -158,14 +171,17 @@ and `./testenv.sh` to execute other commands in it.
I'm open to making it more portable (by using less linuxisms and bashisms).
I'm open to adding support for more VCSes and build system types (and
--
*especially*
-- making that part more modular).
I'm
***NOT**
*
open to making it into a proper package manager à la
`pacman`
or
`xbps`
, let alone
`nix`
or
`guix`
.
I'm
***NOT**
*
open to adding dependency management.
I'm
***NOT**
*
open to adding dependency management
and other fancy stuff
.
I'm
***NOT**
*
open to rewriting it in
`<insert language here>`
because
shell scritps are slow/ugly/not even a real language/... sspt isn't meant
to be professional.
shell scritps are slow/ugly/not even a real language/...
.
sspt isn't meant
to be professional
, or look like something 'real'
.
## License
...
...
local/bin/sspt
View file @
ed4a0a35
#!/usr/bin/env bash
THISSCRIPT
=
$(
realpath
$0
)
RUNDIR
=
$(
dirname
$
THISSCRIPT
)
export
SSPT_
THISSCRIPT
=
$(
realpath
"
$0
"
)
export
SSPT_
RUNDIR
=
$(
dirname
"
$SSPT_
THISSCRIPT
"
)
ALL_ARGS
=(
"
$@
"
)
ARG_COUNT
=
$#
...
...
@@ -22,6 +22,9 @@ exit_cleanup() {
unset
SSPT_BIN_DB_FILE
unset
SSPT_BIN_DB_DIR
unset
SSPT_THISSCRIPT
unset
SSPT_RUNDIR
exit
$@
}
...
...
@@ -30,7 +33,7 @@ escape_string() {
}
export
-f
escape_string
temp_filename
()
{
echo
"/tmp/ss
b
t-
$(
cat
/dev/urandom |
head
-c
4 |
base
64
)
"
echo
"/tmp/ss
p
t-
$(
cat
/dev/urandom |
head
-c
4 |
base
32
)
"
}
export
-f
temp_filename
file_exists_glob
()
{
...
...
@@ -48,7 +51,7 @@ print_version() {
}
print_help
()
{
print_version
#
print_version
(>
&2
cat
<<
EOF
sspt - manage upstream repositories
Usage:
$0
[-h|-?|--help]
...
...
local/libexec/sspt/sspt-autogen
View file @
ed4a0a35
...
...
@@ -154,7 +154,44 @@ autogen_buildsys() {
RELI_DIR
=
"../"
fi
if
[
-f
"package.json"
]
;
then
if
[
-f
"PKGBUILD"
]
;
then
cat
>>
"
$SSPT_FILE
"
<<
EOF
sspt_config() {
makepkg -o
}
sspt_build() {
makepkg -e
}
sspt_install() {
makepkg -e -o -i
}
sspt_clean() {
makepkg -c -e -o
}
sspt_clean_config() {
true
}
EOF
elif
[
-f
"APKBUILD"
]
;
then
cat
>>
"
$SSPT_FILE
"
<<
EOF
sspt_config() {
abuild prepare
}
sspt_build() {
abuild build
}
sspt_install() {
abuild package -i
}
sspt_clean() {
abuild clean
}
sspt_clean_config() {
abuild clean
abuild cleancache
}
EOF
elif
[
-f
"package.json"
]
;
then
cat
>>
"
$SSPT_FILE
"
<<
EOF
sspt_config() {
(>&2 echo "NOTE: npm doesn't honor
\$
SSPT_DEST_DIR")
...
...
@@ -209,25 +246,6 @@ sspt_clean() {
sspt_clean_config() {
"
$REL_DIR
/setup.py" clean -a
}
EOF
elif
file_exists_glob
*
.ipkg
;
then
local
IPKG_FILE
=
$(
ls
*
.ipkg |
head
-1
)
# ensure it's only 1 file
cat
>>
"
$SSPT_FILE
"
<<
EOF
sspt_config() {
(>&2 echo "NOTE: idris doesn't honor
\$
SSPT_DEST_DIR")
}
sspt_build() {
idris --build "
$REL_DIR
/
$IPKG_FILE
"
}
sspt_install() {
idris --install "
$REL_DIR
/
$IPKG_FILE
" && idris --installdoc "
$REL_DIR
/
$IPKG_FILE
"
}
sspt_clean() {
idris --clean "
$REL_DIR
/
$IPKG_FILE
"
}
sspt_clean_config() {
true
}
EOF
elif
file_exists_glob
*
.sln
;
then
local
SLN_FILE
=
$(
ls
*
.sln |
head
-1
)
...
...
@@ -518,6 +536,25 @@ sspt_clean() {
sspt_clean_config() {
true
}
EOF
elif
file_exists_glob
*
.ipkg
;
then
local
IPKG_FILE
=
$(
ls
*
.ipkg |
head
-1
)
# ensure it's only 1 file
cat
>>
"
$SSPT_FILE
"
<<
EOF
sspt_config() {
(>&2 echo "NOTE: idris doesn't honor
\$
SSPT_DEST_DIR")
}
sspt_build() {
idris --build "
$REL_DIR
/
$IPKG_FILE
"
}
sspt_install() {
idris --install "
$REL_DIR
/
$IPKG_FILE
" && idris --installdoc "
$REL_DIR
/
$IPKG_FILE
"
}
sspt_clean() {
idris --clean "
$REL_DIR
/
$IPKG_FILE
"
}
sspt_clean_config() {
true
}
EOF
elif
!
[
-z
"
$CHANGED_DIR
"
]
;
then
# try top directory instead
...
...
local/libexec/sspt/sspt-bin-db
View file @
ed4a0a35
...
...
@@ -28,7 +28,7 @@ main() {
;;
exists
)
if
[
$#
-lt
2
]
;
then
print_help
;
exit
1
;
fi
egrep
-q
-e
"^
$ESCAPED_PKG
"
<
"
$SSPT_BIN_DB_FILE
"
egrep
-q
-e
"^
$ESCAPED_PKG
$
"
<
"
$SSPT_BIN_DB_FILE
"
return
$?
;;
reg|register
)
...
...
@@ -36,16 +36,15 @@ main() {
if
!
[
-f
"
$3
"
]
;
then
print_help
;
exit
1
;
fi
# check whether package exists
egrep
-q
-e
"^
$ESCAPED_PKG
"
<
"
$SSPT_BIN_DB_FILE
"
egrep
-q
-e
"^
$ESCAPED_PKG
$
"
<
"
$SSPT_BIN_DB_FILE
"
if
[
$?
-ne
0
]
;
then
# doesn't exist
echo
"
$2
"
>>
"
$SSPT_BIN_DB_FILE
"
cp
"
$3
"
"
$SSPT_BIN_DB_DIR
/
$ESCAPED_PKG
"
else
# update path
(>
&2
echo
"WARNING: This package is already registered, updating its path..."
)
local
TMPFILE
=
"
$(
temp_filename
)
"
egrep
-v
-e
"^
$ESCAPED_PKG
"
<
"
$SSPT_BIN_DB_FILE
"
>
"
$TMPFILE
"
egrep
-v
-e
"^
$ESCAPED_PKG
$
"
<
"
$SSPT_BIN_DB_FILE
"
>
"
$TMPFILE
"
echo
"
$2
"
>>
"
$TMPFILE
"
mv
"
$TMPFILE
"
"
$SSPT_BIN_DB_FILE
"
cp
"
$3
"
"
$SSPT_BIN_DB_DIR
/
$ESCAPED_PKG
"
...
...
@@ -54,13 +53,13 @@ main() {
unreg|unregister
)
if
[
$#
-lt
2
]
;
then
print_help
;
exit
1
;
fi
egrep
-q
-e
"^
$ESCAPED_PKG
"
<
"
$SSPT_BIN_DB_FILE
"
egrep
-q
-e
"^
$ESCAPED_PKG
$
"
<
"
$SSPT_BIN_DB_FILE
"
if
[
$?
-eq
0
]
;
then
# exists
local
TMPFILE
=
"
$(
temp_filename
)
"
egrep
-v
-e
"^
$ESCAPED_PKG
"
<
"
$SSPT_BIN_DB_FILE
"
>
"
$TMPFILE
"
egrep
-v
-e
"^
$ESCAPED_PKG
$
"
<
"
$SSPT_BIN_DB_FILE
"
>
"
$TMPFILE
"
mv
"
$TMPFILE
"
"
$SSPT_BIN_DB_FILE
"
rm
"
$SSPT_BIN_DB_DIR
/
$ESCAPED_PKG
"
rm
-f
"
$SSPT_BIN_DB_DIR
/
$ESCAPED_PKG
"
else
(>
&2
echo
"Package doesn't exist."
)
fi
...
...
local/libexec/sspt/sspt-install
0 → 100755
View file @
ed4a0a35
#!/usr/bin/env bash
print_help
()
{
(>
&2
cat
<<
EOF
Install a package's binary files.
Usage:
$0
[-h|-?|--help]
Print this help text and exit.
-
$0
<package-name>
Install the binary files of this package.
EOF
)
}
main
()
{
case
$1
in
-h
|
-?|--help
)
print_help
;;
*
)
# TODO: other stuff
exec_subcommand strace
"
$1
"
;;
esac
}
if
[
$?
-eq
0
]
;
then
print_help
exit
fi
main
$@
local/libexec/sspt/sspt-purge
View file @
ed4a0a35
...
...
@@ -12,12 +12,7 @@ EOF
}
main
()
{
local
ESCAPED_PKG
=
`
escape_string
$2
`
if
[
-z
"
$2
"
]
;
then
print_help
exit
fi
local
ESCAPED_PKG
=
`
escape_string
$1
`
case
$1
in
-h
|
-?|--help
)
...
...
local/libexec/sspt/sspt-strace
0 → 100755
View file @
ed4a0a35
#!/usr/bin/env bash
print_help
()
{
(>
&2
cat
<<
EOF
Use strace to record which files are installed by a 'make install'
command (or something similar).
Usage:
$0
[-h|-?-|--help]
Print this help text and exit.
-
$0
<package name>
Runs strace on
\`
pkgcmd install <package name>
\`
.
NOTE: this subcommand is supposed to be used only by ssbt internally.
Proceed with caution.
NOTE: THIS SUBCOMMAND IS A HUGE HACK. STAY AWAY FROM IT AS FAR AS POSSIBLE.
EOF
# ^ is right. close this file now.
)
}
OUTFILE
=
""
# TODO: ktrace/kdump support (and whatever freebsd/... use)
run_strace
()
{
# not using -e trace=%file because I don't care about eg. the stat syscalls
local
SYSCALLS
=
"open,openat,creat,link,linkat,mkdir,mkdirat,rename,renameat,renameat2,rmdir,symlink,symlinkat"
# ,unlink,unlinkat
local
STRACE_OUT
=
"
$(
temp_filename
)
"
local
GREP_OUT
=
"
$(
temp_filename
)
"
# v only interested in paths, not any other kind of string
strace
-f
-a
80
-s
0
-qq
-o
"
$STRACE_OUT
"
-e
trace
=
"
$SYSCALLS
"
\
bash
-c
"'
$SSPT_THISSCRIPT
' pkgcmd install '
$1
'"
# 1. select only files that are written to
# 2,3. but also add stuff that doesn't use these flags
# 4. filter out uninteresting places
# 5. filter out local stuff & db operations
# 6. throw away PID & retval (it'd be much cleaner if it wouldn't
# pretty-print errors)
<
"
$STRACE_OUT
"
grep
-e
O_RDWR
-e
O_WRONLY
\
-e
creat
-e
link
-e
linkat
-e
mkdir
-e
mkdirat
-e
rename
\
-e
renameat2
-e
renameat2
-e
rmdir
-e
symlink
-e
symlinkat
\
| egrep
-v
-e
"
\(\"\/
dev
\/
"
-e
"
\(\"\/
tmp
\/
"
-e
"
\(\"
[^
\/
]"
-e
"
\(\"\/
home
\"
"
\
|
grep
-v
-e
"
$SSPT_DL_DIR
"
-e
"
$SSPT_DB_DIR
"
\
|
sed
-E
-e
's/^[0-9]* *//'
-e
's/\) *=.*/\)/'
\
>
"
$GREP_OUT
"
# I told you, this is total madness
rm
"
$STRACE_OUT
"
while
read
-r
line
;
do
local
syscall
=
$(
echo
"
$line
"
|
sed
-E
-e
's/\(.*$//'
)
local
alargs_
=
$(
echo
"
$line
"
|
sed
-E
-e
's/^.*?\(//'
-e
's/\)$//'
)
IFS
=
', '
read
-ra
allargs
<<<
"
$alargs_
"
unset
IFS
local
outfile
=
""
case
"
$syscall
"
in
open|creat|mkdir|rmdir|symlink
)
outfile
=
"
${
allargs
[0]
}
"
;;
openat|link|mkdirat|rename
)
outfile
=
"
${
allargs
[1]
}
"
;;
symlinkat
)
outfile
=
"
${
allargs
[2]
}
"
;;
linkat|renameat|renameat2
)
outfile
=
"
${
allargs
[3]
}
"
;;
*
)
(>
&2
echo
"Unexpeted strace output '
$line
'!"
)
unset
OUTFILE
exit
1
;;
esac
echo
"
$outfile
"
>>
"
$STRACE_OUT
"
# reuse the file
done
<
"
$GREP_OUT
"
rm
"
$GREP_OUT
"
OUTFILE
=
"
$STRACE_OUT
"
}
main
()
{
case
$1
in
-h
|
-?|--help
)
print_help
exit
;;
*
)
exec_subcommand src-db exists
"
$1
"
if
[
$?
-ne
0
]
;
then
(>
&2
echo
"This package doesn't exist."
)
unset
OUTFILE
exit
1
fi
run_strace
$@
exec_subcommand bin-db reg
"
$1
"
"
$OUTFILE
"
rm
"
$OUTFILE
"
;;
esac
}
if
[
$#
-eq
0
]
;
then
print_help
unset
OUTFILE
exit
fi
main
$@
unset
OUTFILE
local/libexec/sspt/sspt-uninstall
View file @
ed4a0a35
...
...
@@ -2,23 +2,35 @@
print_help
()
{
(>
&2
cat
<<
EOF
Delete a package's installed binaries
and its source code
.
Delete a package's installed binaries.
Usage:
$0
[-h|-?|--help]
Print this help text and exit.
-
$0
<package-name>
Purge
the package.
Uninstall
the package.
EOF
)
}
main
()
{
local
ESCAPED_PKG
=
`
escape_string
$2
`
remove_empty_dir_rec
()
{
# ensure it stops somehwere - who knows / might be empty (somehow)
if
[
"
$1
"
==
"/"
]
;
then
return
fi
if
[
-z
"
$2
"
]
;
then
print_help
exit
echo
"trying
$1
"
if
!
file_exists_glob
"
$1
/"
*
;
then
echo
"removing
$1
"
rm
-rf
"
$1
"
else
return
fi
remove_empty_dir_rec
"
$(
dirname
"
$1
"
)
"
}
main
()
{
local
ESCAPED_PKG
=
`
escape_string
$1
`
case
$1
in
-h
|
-?|--help
)
print_help
...
...
@@ -31,7 +43,17 @@ main() {
fi
# 1. delete all files
cat
"
$SSPT_BIN_DB_DIR
/
$ESCAPED_PKG
"
| xargs
rm
while
read
-r
line
;
do
# unescape
local
lin_
=
$(
echo
"
$line
"
|
sed
-E
's/\\(.)/\1/g'
)
lin_
=
"
${
lin_
%\
"}"
lin_=
"
${
lin_
#\
"}"
rm -rf
"
$lin_
"
# if dir is empty, remove it
remove_empty_dir_rec
"
$(
dirname
"
$lin_
"
)
"
done <
"
$SSPT_BIN_DB_DIR
/
$ESCAPED_PKG
"
# 2. remove from the db
exec_subcommand bin-db unreg
"
$1
"
...
...
todo
View file @
ed4a0a35
* install!!!
* PKGBUILD/APKBUILD/xbps support
* aliases (sspt rm foo)
* bulk operations (pull pkg0 pkg1 pkg2 ...)
* auto-execution of other subcmds
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment