Commit c7545afa authored by pcy's avatar pcy
Browse files

stuff

parent 92615c41
......@@ -45,12 +45,12 @@ file_exists_glob() {
export -f file_exists_glob
print_version() {
(>&2 echo "sspt v0.0.0")
>&2 echo "sspt v0.0.0"
}
print_help() {
#print_version
(>&2 cat <<EOF
>&2 cat <<EOF
sspt - manage upstream repositories
Usage: sspt [-h|-?|--help]
Print this help text and exit.
......@@ -72,7 +72,6 @@ Usage: sspt [-h|-?|--help]
Execute a subcommand. Use \`sspt <subcommand> --help\' for more
information about a particular subcommand.
EOF
)
}
if [ $# -eq 0 ]; then
......@@ -90,7 +89,7 @@ fi
load_config() {
if ! [ -f "$SSPT_CONFIG_FILE" ]; then
(>&2 echo "Config file '$SSPT_CONFIG_FILE' does not exist!")
>&2 echo "Config file '$SSPT_CONFIG_FILE' does not exist!"
exit_cleanup 1
fi
......@@ -99,12 +98,12 @@ load_config() {
export -f load_config
exec_sub_rip() {
(>&2 echo "File '$1' does not exist, cannot execute subcommand '$2'.")
>&2 echo "File '$1' does not exist, cannot execute subcommand '$2'."
exit_cleanup 1
}
exec_subcommand () {
if [ -z "$SSPT_DEST_DIR" ] || [ -z "$SSPT_DB_DIR" ] || [ -z "$SSPT_SUB_DIR" ] || [ -z "$SSPT_DL_DIR" ]; then
(>&2 echo "\$SSPT_DEST_DIR or \$SSPT_DB_DIR or \$SSPT_SUB_DIR or \$SSPT_DL_DIR not defined.")
>&2 echo "\$SSPT_DEST_DIR or \$SSPT_DB_DIR or \$SSPT_SUB_DIR or \$SSPT_DL_DIR not defined."
exit_cleanup 1
fi
......@@ -125,7 +124,7 @@ exec_subcommand () {
command -v "$SUB_FILE" >/dev/null 2>&1 || exec_sub_rip "$SUB_FILE" "$1"
#(>&2 echo "execing $1 : ${ALL_ARGS[@]:1}")
#>&2 echo "execing $1 : ${ALL_ARGS[@]:1}"
"$SUB_FILE" "${ALL_ARGS[@]:1}"
return $?
}
......@@ -151,9 +150,9 @@ parse_arg() {
;;
"--list-subcommands"|"--list"|"-L")
load_config
while read -r sc; do
find "$SSPT_SUB_DIR/" -type f -name "sspt-*" | while read -r sc; do
basename "$sc"
done <<< "$(find "$SSPT_SUB_DIR/" -type f -name "sspt-*")"
done
;;
"--mk-default-config")
if ! [ -d "$CONFIG_PATH" ]; then
......
#!/usr/bin/env bash
print_help() {
(>&2 cat <<EOF
>&2 cat <<EOF
Autogenerate an .sspt file for a package.
Usage: sspt autogen [-h|-?|--help]
Print this help text and exit.
......@@ -13,11 +13,10 @@ Supported build systems: npm, cargo, setuptools, idris, xbuild, stack,
cabal, scons, gradle, sbt, bazel, meson, ninja, ant, mvn, cmake,
qmake, autoconf, makefile
EOF
)
}
autogen_git() {
cat >> ".sspt" <<EOF
cat <<EOF
sspt_pull() {
git pull
}
......@@ -30,7 +29,7 @@ sspt_prettyver() {
EOF
}
autogen_hg() {
cat >> ".sspt" <<EOF
cat <<EOF
sspt_pull() {
hg pull
}
......@@ -43,7 +42,7 @@ sspt_prettyver() {
EOF
}
autogen_svn() {
cat >> ".sspt" <<EOF
cat <<EOF
sspt_pull() {
svn up
}
......@@ -58,7 +57,7 @@ EOF
}
autogen_cvs() {
# CVS doesn't have 'global' commits...
cat >> ".sspt" <<EOF
cat <<EOF
sspt_pull() {
cvs update
}
......@@ -71,7 +70,7 @@ sspt_prettyver() {
EOF
}
autogen_bzr() {
cat >> ".sspt" <<EOF
cat <<EOF
sspt_pull() {
bzr update
}
......@@ -84,7 +83,7 @@ sspt_prettyver() {
EOF
}
autogen_mtn() {
cat >> ".sspt" <<EOF
cat <<EOF
sspt_pull() {
mtn pull
mtn update
......@@ -98,7 +97,7 @@ sspt_prettyver() {
EOF
}
autogen_darcs() {
cat >> ".sspt" <<EOF
cat <<EOF
sspt_pull() {
darcs pull
}
......@@ -126,10 +125,10 @@ autogen_vcs() {
elif [ -d "_darcs/" ]; then
autogen_darcs
else
(>&2 echo "NOTE: could not detect repository type of package" \
"'$1', add the .sspt file to make updating this pacakge possible.")
>&2 echo "NOTE: could not detect repository type of package" \
"'$1', add the .sspt file to make updating this pacakge possible."
# no upstream?
cat >> ".sspt" <<EOF
cat <<EOF
sspt_pull() {
true
}
......@@ -145,18 +144,16 @@ EOF
autogen_buildsys() {
local REL_DIR="."
local RELI_DIR="."
local SSPT_FILE=".sspt"
local CHANGED_DIR=""
if [ -z "$DONT_LOOK_INTO_BUILD" ] && [ -d "build" ]; then
pushd "build" >/dev/null
CHANGED_DIR=1
SSPT_FILE="../$SSPT_FILE"
REL_DIR="./build"
RELI_DIR="../"
fi
if [ -f "PKGBUILD" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
export SSPT_TRACK_FILES="no"
sspt_config() {
makepkg -o
......@@ -175,7 +172,7 @@ sspt_clean_config() {
}
EOF
elif [ -f "APKBUILD" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
export SSPT_TRACK_FILES="no"
sspt_config() {
abuild prepare
......@@ -195,7 +192,7 @@ sspt_clean_config() {
}
EOF
elif [ -f "CMakeLists.txt" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
mkdir -p "$REL_DIR/cmake-build"
pushd "$REL_DIR/cmake-build" >/dev/null
......@@ -216,7 +213,7 @@ sspt_clean_config() {
}
EOF
elif [ -f "./configure.ac" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
autoreconf -i
"$REL_DIR/configure" "--prefix=\$SSPT_DEST_DIR"
......@@ -235,7 +232,7 @@ sspt_clean_config() {
}
EOF
elif [ -f "./configure" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
"$REL_DIR/configure" "--prefix=\$SSPT_DEST_DIR"
}
......@@ -255,7 +252,7 @@ EOF
elif file_exists_glob ./*.pro; then
local PRO_FILE="$(find ./*.pro -maxdepth 1 -type f | head -1)"
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
qmake -makefile "$REL_DIR/$PRO_FILE"
}
......@@ -274,7 +271,7 @@ sspt_clean_config() {
EOF
elif file_exists_glob ./*akefile; then # support GNUmakefile etc.
local MAKEFILE=$(find ./*akefile -maxdepth 1 -type f | head -1)
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
true
}
......@@ -292,7 +289,7 @@ sspt_clean_config() {
}
EOF
elif [ -f "package.json" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
export SSPT_TRACK_FILES="no"
sspt_config() {
>&2 echo "NOTE: npm doesn't honor \$SSPT_DEST_DIR"
......@@ -311,7 +308,7 @@ sspt_clean_config() {
}
EOF
elif [ -f "Cargo.toml" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
export SSPT_TRACK_FILES="no"
sspt_config() {
>&2 echo "You may want to edit the .sspt file to enable or disable some features."
......@@ -330,7 +327,7 @@ sspt_clean_config() {
}
EOF
elif [ -f "setup.py" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
>&2 echo "NOTE: sspt assumes that the setup.py script will be executed by the correct python binary."
# ensure it is executable
......@@ -350,12 +347,12 @@ sspt_clean_config() {
}
EOF
elif [ -f "stack.yaml" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
stack build --only-configure
(>&2 echo "NOTE: stack doesn't honor \$SSPT_DEST_DIR, but installs" \
>&2 echo "NOTE: stack doesn't honor \$SSPT_DEST_DIR, but installs" \
"everything to \$XDG_CONFIG_HOME , which is also the default value" \
"of \$SSPT_DEST_DIR .")
"of \$SSPT_DEST_DIR ."
}
sspt_build() {
stack build --ghc-options -j$(nproc)
......@@ -371,7 +368,7 @@ sspt_clean_config() {
}
EOF
elif file_exists_glob ./*.cabal; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
cabal configure -O2 --user --prefix=\$SSPT_DEST_DIR --ghc-option=-j$(nproc)
}
......@@ -389,15 +386,15 @@ sspt_clean_config() {
}
EOF
elif [ -f "SConstruct" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
(>&2 echo "NOTE: SCons cannot install packages.")
>&2 echo "NOTE: SCons cannot install packages."
}
sspt_build() {
scons
}
sspt_install() {
(>&2 echo "NOTE: SCons cannot install packages.")
>&2 echo "NOTE: SCons cannot install packages."
}
sspt_clean() {
scons -c
......@@ -407,51 +404,51 @@ sspt_clean_config() {
}
EOF
elif [ -f "build.gradle" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
(>&2 echo "NOTE: Gradle cannot install packages.")
>&2 echo "NOTE: Gradle cannot install packages."
}
sspt_build() {
grdle -a
}
sspt_install() {
(>&2 echo "NOTE: Gradle cannot install packages.")
>&2 echo "NOTE: Gradle cannot install packages."
}
sspt_clean() {
(>&2 echo "NOTE: Gradle cannot clean packages.")
>&2 echo "NOTE: Gradle cannot clean packages."
}
sspt_clean_config() {
true
}
EOF
elif file_exists_glob ./*.sbt; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
(>&2 echo "NOTE: sbt cannot install packages.")
>&2 echo "NOTE: sbt cannot install packages."
}
sspt_build() {
sbt
}
sspt_install() {
(>&2 echo "NOTE: sbt cannot install packages.")
>&2 echo "NOTE: sbt cannot install packages."
}
sspt_clean() {
(>&2 echo "NOTE: sbt cannot clean packages.")
>&2 echo "NOTE: sbt cannot clean packages."
}
sspt_clean_config() {
true
}
EOF
elif [ -f "BUILD" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
(>&2 echo "NOTE: Bazel cannot install packages.")
>&2 echo "NOTE: Bazel cannot install packages."
}
sspt_build() {
bazel build
}
sspt_install() {
(>&2 echo "NOTE: Bazel cannot install packages.")
>&2 echo "NOTE: Bazel cannot install packages."
}
sspt_clean() {
bazel clean
......@@ -460,10 +457,10 @@ sspt_clean_config() {
true
}
EOF
(>&2 echo "NOTE: sspt cannot figure out which target to use. Please edit the .sstp file manually.")
>&2 echo "NOTE: sspt cannot figure out which target to use. Please edit the .sstp file manually."
return 1
elif [ -f "meson.build" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
meson --backend ninja --buildtype release --strip --prefix \$SSPT_DEST_DIR "$REL_DIR/build"
}
......@@ -481,7 +478,7 @@ sspt_clean_config() {
}
EOF
elif [ -f "build.ninja" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
true
}
......@@ -499,15 +496,15 @@ sspt_clean_config() {
}
EOF
elif [ -f "build.xml" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
(>&2 echo "NOTE: ant cannot install packages.")
>&2 echo "NOTE: ant cannot install packages."
}
sspt_build() {
ant
}
sspt_install() {
(>&2 echo "NOTE: ant cannot install packages.")
>&2 echo "NOTE: ant cannot install packages."
}
sspt_clean() {
ant clean
......@@ -517,7 +514,7 @@ sspt_clean_config() {
}
EOF
elif [ -f "pom.xml" ]; then
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
true
}
......@@ -536,9 +533,9 @@ sspt_clean_config() {
EOF
elif file_exists_glob ./*.ipkg; then
local IPKG_FILE=$(find ./*.ipkg -maxdepth 1 -type f | head -1) # ensure it's only 1 file
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
(>&2 echo "NOTE: idris doesn't honor \$SSPT_DEST_DIR")
>&2 echo "NOTE: idris doesn't honor \$SSPT_DEST_DIR"
}
sspt_build() {
idris --build "$REL_DIR/$IPKG_FILE"
......@@ -556,7 +553,7 @@ EOF
elif file_exists_glob ./*.sln; then
local SLN_FILE=$(find ./*.sln -maxdepth 1 -type f | head -1)
local PROBABLE_PROJECT_NAME=${SLN_FILE%.*}
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
>&2 echo "NOTE: the 'install' command for xbuild projects is extremely hacky, you might want to tweak it."
}
......@@ -564,8 +561,14 @@ sspt_build() {
xbuild /p:Configuration=Release "$REL_DIR/$SLN_FILE"
}
sspt_install() {
cp "$RELI_DIR/$PROBABLE_PROJECT_NAME/bin/Release/"*.exe \$SSPT_DEST_DIR/bin && \
cp "$RELI_DIR/$PROBABLE_PROJECT_NAME/bin/Release/"*.dll \$SSPT_DEST_DIR/lib
mkdir -vp "$SSPT_DEST_DIR/lib/mono/$1"
install -vm644 "$SSPT_DEST_DIR/lib/mono/$1" \
"$RELI_DIR/$PROBABLE_PROJECT_NAME/bin/Release/"*.{exe,dll}
cat >"$SSPT_DEST_DIR/bin/$1" <<EOF_
mono "$SSPT_DEST_DIR/lib/mono/$1/$1.exe"
EOF_
chmod +x "$SSPT_DEST_DIR/bin/$1"
}
sspt_clean() {
xbuild /p:Configuration=Release "$REL_DIR/$SLN_FILE" /t:Clean
......@@ -580,7 +583,7 @@ EOF
DONT_LOOK_INTO_BUILD=1 autogen_buildsys
return $?
else
cat >> "$SSPT_FILE" <<EOF
cat <<EOF
sspt_config() {
true
}
......@@ -597,7 +600,7 @@ sspt_clean_config() {
true
}
EOF
(>&2 echo "Could not detect how to compile package '$1'.")
>&2 echo "Could not detect how to compile package '$1'."
return 1
fi
......@@ -610,16 +613,13 @@ autogen_cwd() {
if [ -f ".sspt" ]; then
rm ".sspt"
fi
touch ".sspt"
#echo "name=\"$(basename `pwd`)\"" >> ".sspt"
autogen_vcs "$1"
autogen_buildsys "$1"
autogen_vcs "$1" >".sspt"
autogen_buildsys "$1" >>".sspt"
return $?
}
main() {
local ESCAPED_PKG=$(escape_string "$1")
case "$1" in
"-h"|"-?"|"--help")
print_help
......@@ -635,11 +635,11 @@ main() {
;;
*)
if ! exec_subcommand src-db exists "$1"; then
(>&2 echo "Package '$1' doesn't exist.")
>&2 echo "Package '$1' doesn't exist."
exit 1
fi
local PACKAGE_DIR="$SSPT_DL_DIR/$ESCAPED_PKG"
local PACKAGE_DIR="$SSPT_DL_DIR/$1"
pushd "$PACKAGE_DIR" >/dev/null
autogen_cwd "$1"
......
#!/usr/bin/env bash
print_help() {
(>&2 cat <<EOF
>&2 cat <<EOF
Modify the database of installed binaries.
Usage: sspt bin-db -h|-?|--help
Print this help text and exit.
......@@ -16,7 +16,6 @@ Usage: sspt bin-db -h|-?|--help
NOTE: this subcommand is supposed to be used only by sspt internally.
Proceed with caution.
EOF
)
}
main() {
......@@ -39,14 +38,14 @@ main() {
if ! grep -E -q -e "^$ESCAPED_PKG$" < "$SSPT_BIN_DB_FILE"; then
# doesn't exist
echo "$2" >> "$SSPT_BIN_DB_FILE"
cp "$3" "$SSPT_BIN_DB_DIR/$ESCAPED_PKG"
cp "$3" "$SSPT_BIN_DB_DIR/$2"
else
# update path
local TMPFILE="$(temp_filename)"
grep -E -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"
cp "$3" "$SSPT_BIN_DB_DIR/$2"
fi
;;
"unreg"|"unregister")
......@@ -57,9 +56,9 @@ main() {
local TMPFILE="$(temp_filename)"
grep -E -v -e "^$ESCAPED_PKG$" < "$SSPT_BIN_DB_FILE" > "$TMPFILE"
mv "$TMPFILE" "$SSPT_BIN_DB_FILE"
rm -f "$SSPT_BIN_DB_DIR/$ESCAPED_PKG"
rm -f "$SSPT_BIN_DB_DIR/$2"
else
(>&2 echo "Package doesn't exist.")
>&2 echo "Package doesn't exist."
fi
;;
esac
......
#!/usr/bin/env bash
print_help() {
(>&2 cat <<EOF
>&2 cat <<EOF
Build a package.
Usage: sspt build [-h|-?|--help]
Print this help text and exit.
- sspt build {-c|--configure} <package-name>
Build the package. Optionally configure it as well.
EOF
)
}
DO_CONFIG='auto'
......@@ -26,7 +25,7 @@ main() {
*)
if ! exec_subcommand src-db exists "$1"; then
# TODO: download if URL specified
(>&2 echo "Package '$1' doesn't exist.")
>&2 echo "Package '$1' doesn't exist."
exit 1
fi
......
#!/usr/bin/env bash
print_help() {
(>&2 cat <<EOF
>&2 cat <<EOF
Clean a package.
Usage: sspt clean [-h|-?|--help]
Print this help text and exit.
- sspt clean <package-name>
Clean the package.
EOF
)
}
main() {
......
#!/usr/bin/env bash
print_help() {
(>&2 cat <<EOF
>&2 cat <<EOF
Clean a package, including all configuration files.
Usage: sspt clean-config [-h|-?|--help]
Print this help text and exit.
- sspt clean-config <package-name>
Clean the package.
EOF
)
}
main() {
......@@ -18,7 +17,7 @@ main() {
;;
*)
if ! exec_subcommand src-db exists "$1"; then
(>&2 echo "Package '$1' package doesn't exist.")
>&2 echo "Package '$1' package doesn't exist."
exit 1
fi
exec_subcommand pkgcmd clean_config "$1"
......
#!/usr/bin/env bash
print_help() {
(>&2 cat <<EOF
>&2 cat <<EOF
Configure a pacakge.
Usage: sspt configure [-h|-?|--help]
Print this help text and exit.
- sspt configure <package-name>
Configure the package.
EOF
)
}
main() {
......@@ -19,7 +18,7 @@ main() {
*)
if ! exec_subcommand src-db exists "$1"; then
# TODO: download if URL specified
(>&2 echo "This package doesn't exist.")
>&2 echo "This package doesn't exist."
exit 1
fi
exec_subcommand pkgcmd config "$1"
......
#!/usr/bin/env bash
print_help() {
(>&2 cat <<EOF
>&2 cat <<EOF
Edit the .sspt file of a package.
Usage: sspt edit [-h|-?|--help]
Print this help text and exit.
- sspt edit <package-name>
Edit the .sspt file of the package using \$EDITOR.
EOF
)
}
main() {
local ESCAPED_PKG=$(escape_string "$1")