Commit d6dcf680 authored by pcy's avatar pcy
Browse files

fix some bugs

parent 59ca9e26
...@@ -197,6 +197,7 @@ main() { ...@@ -197,6 +197,7 @@ main() {
fi fi
parse_arg "${NEW_ARGS[@]}" parse_arg "${NEW_ARGS[@]}"
exit_cleanup $?
fi fi
} }
......
...@@ -293,6 +293,7 @@ sspt_clean_config() { ...@@ -293,6 +293,7 @@ sspt_clean_config() {
EOF EOF
elif [ -f "package.json" ]; then elif [ -f "package.json" ]; then
cat >> "$SSPT_FILE" <<EOF cat >> "$SSPT_FILE" <<EOF
export SSPT_TRACK_FILES="no"
sspt_config() { sspt_config() {
>&2 echo "NOTE: npm doesn't honor \$SSPT_DEST_DIR" >&2 echo "NOTE: npm doesn't honor \$SSPT_DEST_DIR"
} }
...@@ -311,6 +312,7 @@ sspt_clean_config() { ...@@ -311,6 +312,7 @@ sspt_clean_config() {
EOF EOF
elif [ -f "Cargo.toml" ]; then elif [ -f "Cargo.toml" ]; then
cat >> "$SSPT_FILE" <<EOF cat >> "$SSPT_FILE" <<EOF
export SSPT_TRACK_FILES="no"
sspt_config() { sspt_config() {
>&2 echo "You may want to edit the .sspt file to enable or disable some features." >&2 echo "You may want to edit the .sspt file to enable or disable some features."
} }
......
...@@ -13,7 +13,7 @@ Usage: sspt bin-db -h|-?|--help ...@@ -13,7 +13,7 @@ Usage: sspt bin-db -h|-?|--help
Use \`sspt add\` to actually install the package. Use \`sspt add\` to actually install the package.
- sspt bin-db unreg(ister) <package-name> - sspt bin-db unreg(ister) <package-name>
Remove the package from the list of registered packages. Remove the package from the list of registered packages.
NOTE: this subcommand is supposed to be used only by ssbt internally. NOTE: this subcommand is supposed to be used only by sspt internally.
Proceed with caution. Proceed with caution.
EOF EOF
) )
......
...@@ -31,10 +31,11 @@ main() { ...@@ -31,10 +31,11 @@ main() {
fi fi
if [ "$DO_CONFIG" = "y" ]; then if [ "$DO_CONFIG" = "y" ]; then
exec_subcommand pkgcmd config "$1" exec_subcommand pkgcmd config "$1" || exit 1
fi fi
exec_subcommand pkgcmd build "$1" exec_subcommand pkgcmd build "$1"
exit $?
;; ;;
esac esac
} }
......
...@@ -22,6 +22,7 @@ main() { ...@@ -22,6 +22,7 @@ main() {
exit 1 exit 1
fi fi
exec_subcommand pkgcmd clean "$1" exec_subcommand pkgcmd clean "$1"
exit $?
;; ;;
esac esac
} }
......
...@@ -22,6 +22,7 @@ main() { ...@@ -22,6 +22,7 @@ main() {
exit 1 exit 1
fi fi
exec_subcommand pkgcmd clean_config "$1" exec_subcommand pkgcmd clean_config "$1"
exit $?
;; ;;
esac esac
} }
......
...@@ -23,6 +23,7 @@ main() { ...@@ -23,6 +23,7 @@ main() {
exit 1 exit 1
fi fi
exec_subcommand pkgcmd config "$1" exec_subcommand pkgcmd config "$1"
exit $?
;; ;;
esac esac
} }
......
...@@ -31,6 +31,7 @@ main() { ...@@ -31,6 +31,7 @@ main() {
command -v "nvim" >/dev/null 2>&1 && "nvim" "$PACKAGE_DIR/.sspt" && return command -v "nvim" >/dev/null 2>&1 && "nvim" "$PACKAGE_DIR/.sspt" && return
command -v "vim" >/dev/null 2>&1 && "vim" "$PACKAGE_DIR/.sspt" && return command -v "vim" >/dev/null 2>&1 && "vim" "$PACKAGE_DIR/.sspt" && return
command -v "vi" >/dev/null 2>&1 && "vi" "$PACKAGE_DIR/.sspt" && return command -v "vi" >/dev/null 2>&1 && "vi" "$PACKAGE_DIR/.sspt" && return
exit 1
;; ;;
esac esac
} }
......
...@@ -53,19 +53,19 @@ main() { ...@@ -53,19 +53,19 @@ main() {
fi fi
if [ "$DO_CONF" = "y" ]; then if [ "$DO_CONF" = "y" ]; then
exec_subcommand pkgcmd config "$1" exec_subcommand pkgcmd config "$1" || exit 1
fi fi
if [ "$DO_BUILD" = "y" ]; then if [ "$DO_BUILD" = "y" ]; then
exec_subcommand pkgcmd build "$1" exec_subcommand pkgcmd build "$1" || exit 1
fi fi
exec_subcommand strace "$1" exec_subcommand strace "$1" || exit 1
if [ "$DO_CLEAN" = "y" ]; then if [ "$DO_CLEAN" = "y" ]; then
exec_subcommand pkgcmd clean "$1" exec_subcommand pkgcmd clean "$1" || exit 1
fi fi
if [ "$DO_CCFG" = "y" ]; then if [ "$DO_CCFG" = "y" ]; then
exec_subcommand pkgcmd clean_config "$1" exec_subcommand pkgcmd clean_config "$1" || exit 1
fi fi
;; ;;
esac esac
......
...@@ -31,14 +31,14 @@ main() { ...@@ -31,14 +31,14 @@ main() {
# 1. unreg in the bin db # 1. unreg in the bin db
if exec_subcommand bin-db exists "$1"; then if exec_subcommand bin-db exists "$1"; then
exec_subcommand bin-db unreg "$1" exec_subcommand bin-db unreg "$1" || exit 1
else else
(>&2 echo "Package '$1' isn't installed.") (>&2 echo "Package '$1' isn't installed.")
exit 1 exit 1
fi fi
# 2. unregister # 2. unregister
exec_subcommand src-db unreg "$1" exec_subcommand src-db unreg "$1" || exit 1
# 3. nuke # 3. nuke
rm -rf "${SSPT_DL_DIR:?}/$ESCAPED_PKG" rm -rf "${SSPT_DL_DIR:?}/$ESCAPED_PKG"
......
...@@ -7,7 +7,7 @@ Usage: sspt pkgcmd [-h|-?|--help] ...@@ -7,7 +7,7 @@ Usage: sspt pkgcmd [-h|-?|--help]
Print this help text and exit. Print this help text and exit.
- sspt pkgcmd <command> <package-name> - sspt pkgcmd <command> <package-name>
Run <command> on the specified package. Run <command> on the specified package.
NOTE: this subcommand is supposed to be used only by ssbt internally. NOTE: this subcommand is supposed to be used only by sspt internally.
Proceed with caution. Proceed with caution.
EOF EOF
) )
......
...@@ -35,7 +35,7 @@ pull_with_vcs() { ...@@ -35,7 +35,7 @@ pull_with_vcs() {
if exec_subcommand src-db exists "$PKG_NAME"; then if exec_subcommand src-db exists "$PKG_NAME"; then
(>&2 echo "Package '$PKG_NAME' is already pulled, updating remote repository...") (>&2 echo "Package '$PKG_NAME' is already pulled, updating remote repository...")
exec_subcommand pkgcmd pull "$PKG_NAME" exec_subcommand pkgcmd pull "$PKG_NAME"
return return $?
fi fi
case "$1" in case "$1" in
...@@ -60,7 +60,7 @@ pull_with_vcs() { ...@@ -60,7 +60,7 @@ pull_with_vcs() {
"darcs") "darcs")
darcs clone "$2" "$SSPT_DL_DIR/$PKG_NAME" darcs clone "$2" "$SSPT_DL_DIR/$PKG_NAME"
;; ;;
"http") "http"|"https")
if command -v "wget" >/dev/null 2>&1; then if command -v "wget" >/dev/null 2>&1; then
wget "$2" -q -O "/tmp/$PKG_NAME" wget "$2" -q -O "/tmp/$PKG_NAME"
elif command -v "curl" >/dev/null 2>&1; then elif command -v "curl" >/dev/null 2>&1; then
...@@ -168,7 +168,7 @@ main() { ...@@ -168,7 +168,7 @@ main() {
esac esac
# need to register it before we can autogen the .sspt file # need to register it before we can autogen the .sspt file
exec_subcommand src-db reg "$PKG_NAME" dummy_revision exec_subcommand src-db reg "$PKG_NAME" dummy_revision || exit 1
if [ "$DO_AUTOGEN" = "auto" ] && ! [ -f "${SSPT_DL_DIR:?}/$PKG_NAME/.sspt" ]; then if [ "$DO_AUTOGEN" = "auto" ] && ! [ -f "${SSPT_DL_DIR:?}/$PKG_NAME/.sspt" ]; then
DO_AUTOGEN='y' DO_AUTOGEN='y'
...@@ -187,15 +187,15 @@ main() { ...@@ -187,15 +187,15 @@ main() {
# now set the version of the package in the DB # now set the version of the package in the DB
# (this is only possible because the .sspt file is generated) # (this is only possible because the .sspt file is generated)
exec_subcommand src-db reg "$PKG_NAME" "$(exec_subcommand pkgcmd version "$PKG_NAME")" exec_subcommand src-db reg "$PKG_NAME" "$(exec_subcommand pkgcmd version "$PKG_NAME")" || exit 1
if [ "$DO_BUILD" = "y" ]; then if [ "$DO_BUILD" = "y" ]; then
exec_subcommand pkgcmd config "$PKG_NAME" exec_subcommand pkgcmd config "$PKG_NAME" && \
exec_subcommand pkgcmd build "$PKG_NAME" exec_subcommand pkgcmd build "$PKG_NAME" || exit 1
fi fi
if [ "$DO_INSTALL" = "y" ]; then if [ "$DO_INSTALL" = "y" ]; then
exec_subcommand strace "$PKG_NAME" exec_subcommand strace "$PKG_NAME" || exit 1
fi fi
} }
......
...@@ -26,11 +26,11 @@ main() { ...@@ -26,11 +26,11 @@ main() {
# 1. uninstall (does a bin-db unreg) # 1. uninstall (does a bin-db unreg)
if exec_subcommand bin-db exists "$1"; then if exec_subcommand bin-db exists "$1"; then
exec_subcommand pkgcmd uninstall "$1" exec_subcommand pkgcmd uninstall "$1" || exit 1
fi fi
# 2. unregister # 2. unregister
exec_subcommand src-db unreg "$1" exec_subcommand src-db unreg "$1" || exit 1
# 3. nuke # 3. nuke
rm -rf "${SSPT_DL_DIR:?}/$ESCAPED_PKG" rm -rf "${SSPT_DL_DIR:?}/$ESCAPED_PKG"
......
...@@ -13,7 +13,7 @@ Usage: sspt src-db -h|-?|--help ...@@ -13,7 +13,7 @@ Usage: sspt src-db -h|-?|--help
Use \`sspt pull\` to actually download the package. Use \`sspt pull\` to actually download the package.
- sspt src-db unreg(ister) <package-name> - sspt src-db unreg(ister) <package-name>
Remove the package from the list of registered packages. Remove the package from the list of registered packages.
NOTE: this subcommand is supposed to be used only by ssbt internally. NOTE: this subcommand is supposed to be used only by sspt internally.
Proceed with caution. Proceed with caution.
EOF EOF
) )
......
...@@ -8,7 +8,7 @@ Usage: sspt strace [-h|-?-|--help] ...@@ -8,7 +8,7 @@ Usage: sspt strace [-h|-?-|--help]
Print this help text and exit. Print this help text and exit.
- sspt strace <package name> - sspt strace <package name>
Runs strace on \`pkgcmd install <package name>\`. Runs strace on \`pkgcmd install <package name>\`.
NOTE: this subcommand is supposed to be used only by ssbt internally. NOTE: this subcommand is supposed to be used only by sspt internally.
Proceed with caution. Proceed with caution.
NOTE: THIS SUBCOMMAND IS A HUGE HACK. STAY AWAY FROM IT AS FAR AS POSSIBLE. NOTE: THIS SUBCOMMAND IS A HUGE HACK. STAY AWAY FROM IT AS FAR AS POSSIBLE.
EOF EOF
...@@ -37,8 +37,8 @@ run_strace() { ...@@ -37,8 +37,8 @@ run_strace() {
< "$STRACE_OUT" grep -e O_RDWR -e O_WRONLY \ < "$STRACE_OUT" grep -e O_RDWR -e O_WRONLY \
-e creat -e link -e linkat -e mkdir -e mkdirat -e rename \ -e creat -e link -e linkat -e mkdir -e mkdirat -e rename \
-e renameat2 -e renameat2 -e rmdir -e symlink -e symlinkat \ -e renameat2 -e renameat2 -e rmdir -e symlink -e symlinkat \
| grep -E -v -e "\(\"\/dev\/" -e "\(\"\/tmp\/" -e "\(\"[^\/]" -e "\(\"\/home\"" \ | grep -Ev -e '\(\"\/dev\/' -e '"\(\"\/tmp\/' -e '"\(\"[^\/]' -e '"\(\"\/home\"' \
| grep -v -e "$SSPT_DL_DIR" -e "$SSPT_DB_DIR" \ | grep -Fv -e "$SSPT_DL_DIR" -e "$SSPT_DB_DIR" \
| sed -E -e 's/^[0-9]* *//' -e 's/\) *=.*/\)/' \ | sed -E -e 's/^[0-9]* *//' -e 's/\) *=.*/\)/' \
> "$GREP_OUT" # I told you, this is total madness > "$GREP_OUT" # I told you, this is total madness
...@@ -94,17 +94,17 @@ main() { ...@@ -94,17 +94,17 @@ main() {
(. "$SSPT_DL_DIR/$(escape_string "$1")/.sspt"; \ (. "$SSPT_DL_DIR/$(escape_string "$1")/.sspt"; \
[ "$SSPT_TRACK_FILES" = "no" ] && exit 1 || exit 0) [ "$SSPT_TRACK_FILES" = "no" ] && exit 1 || exit 0)
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
run_strace "$@" run_strace "$@" || exit 1
else else
echo "NOTE: installing package '$1' whose installed files" \ echo "NOTE: installing package '$1' whose installed files" \
" will not be tracked by sspt. This will make \`sspt" \ " will not be tracked by sspt. This will make \`sspt" \
" uninstall\` meaningless for this package." " uninstall\` meaningless for this package."
exec_subcommand pkgcmd install "$1" exec_subcommand pkgcmd install "$1" || exit -1
OUTFILE="$(temp_filename)" OUTFILE="$(temp_filename)"
touch "$OUTFILE" touch "$OUTFILE"
fi fi
exec_subcommand bin-db reg "$1" "$OUTFILE" exec_subcommand bin-db reg "$1" "$OUTFILE" || exit -1
rm "$OUTFILE" rm "$OUTFILE"
;; ;;
esac esac
......
...@@ -64,7 +64,7 @@ main() { ...@@ -64,7 +64,7 @@ main() {
done < "${SSPT_BIN_DB_DIR:?}/$ESCAPED_PKG" done < "${SSPT_BIN_DB_DIR:?}/$ESCAPED_PKG"
# 2. remove from the db # 2. remove from the db
exec_subcommand bin-db unreg "$1" exec_subcommand bin-db unreg "$1" || exit 1
;; ;;
esac esac
} }
......
...@@ -22,11 +22,11 @@ read_pkg_version() { ...@@ -22,11 +22,11 @@ read_pkg_version() {
update_package() { update_package() {
local PKG="$1" local PKG="$1"
local BEFORE="$(read_pkg_version "$1")" local BEFORE="$(read_pkg_version "$1")"
exec_subcommand pkgcmd pull "$PKG" exec_subcommand pkgcmd pull "$PKG" || exit 1
local AFTER="$(exec_subcommand pkgcmd version "$PKG")" local AFTER="$(exec_subcommand pkgcmd version "$PKG")"
if [ "$BEFORE" != "$AFTER" ]; then if [ "$BEFORE" != "$AFTER" ]; then
exec_subcommand src-db reg "$PKG" "$AFTER" exec_subcommand src-db reg "$PKG" "$AFTER" || exit 1
return 1 return 1
fi fi
...@@ -34,9 +34,9 @@ update_package() { ...@@ -34,9 +34,9 @@ update_package() {
return 0 return 0
} }
upgrade_package() { upgrade_package() {
exec_subcommand pkgcmd config "$1" exec_subcommand pkgcmd config "$1" && \
exec_subcommand pkgcmd build "$1" exec_subcommand pkgcmd build "$1" && \
exec_subcommand strace "$1" exec_subcommand strace "$1" || exit 1
} }
upgrade_pkgs() { upgrade_pkgs() {
# TODO: speed this up, maybe by parallellising this? # TODO: speed this up, maybe by parallellising this?
......
...@@ -18,8 +18,11 @@ edit_the_conf() { ...@@ -18,8 +18,11 @@ edit_the_conf() {
fi fi
} }
local/bin/sspt --mk-default-config if [ -z "$NOINSTALLCONF" ]; then
edit_the_conf local/bin/sspt --mk-default-config
edit_the_conf
fi
. "$cfgfile" . "$cfgfile"
export SSPT_BOOTSTRAP_BASE="$(dirname "$0")" export SSPT_BOOTSTRAP_BASE="$(dirname "$0")"
local/bin/sspt -c config/sspt.bootstrap.conf pull "https://gitlab.com/PoroCYon/sspt" local/bin/sspt -c config/sspt.bootstrap.conf pull "https://gitlab.com/PoroCYon/sspt"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment