/usr/bin/starpkg is in starplot 0.95.5-7.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | #!/bin/sh
# StarPlot - A program for interactively viewing 3D maps of stellar positions.
# Copyright (C) 2000-2008 Kevin B. McCarty
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# This shell script makes it easier to install and update StarPlot data sets
# using starconvert.
printusage() {
cat << EOF
starpkg usage:
starpkg [ --dataset ] <data-set> [ --dest <destination> ]
Assuming that \`data-set' contains a valid StarPlot data set (either a
directory or a tar.gz file), this command converts it to a
StarPlot-formatted data file. If the \`--dest' option is omitted, the
default location of the output file is the first of the directories
$DEFAULTDIR, \$PWD, \$HOME in which the user has write
permissions. If \`--dest' is omitted or \`destination' is a directory,
the default name of the output file is \${specfilename%.spec}.stars
The \`--dataset' flag may be omitted.
starpkg --recurse <dir> [ --dest <dest-dir> ]
Executes the above action for every file and directory in \`dir',
putting the resulting .stars files into \`dest-dir'. If the \`--dest'
option is omitted, the default destination directory is chosen
as above.
--quiet / --verbose: Print only errors or all starconvert output, respectively.
--starconvert-option <option>: Pass <option> through to starconvert.
starpkg: version 0.95.5 (C) 2000-2008 Kevin B. McCarty
starpkg comes with ABSOLUTELY NO WARRANTY; for details, see the file
COPYING that should have come with your distribution of StarPlot.
EOF
}
input=""
dest=""
action=dataset
verbosity=1
spoptions=""
scoptions=""
prefix="/usr"
datarootdir="${prefix}/share"
DEFAULTDIR="${datarootdir}/starplot"
starpkg="$0"
case "$starpkg" in
*/*) starconvert="$(dirname "$starpkg")/starconvert" ;;
*) starconvert="starconvert" ;;
esac
# select a default destination in case user doesn't specify one
[ -n "$HOME" ] && [ -w "$HOME" ] && dest="$HOME"
[ -n "$PWD" ] && [ -w "$PWD" ] && dest="$PWD"
[ -w "$DEFAULTDIR" ] && [ -d "$DEFAULTDIR" ] && dest="$DEFAULTDIR"
# read command-line opts
[ $# -eq 0 ] && printusage && exit 0
while [ $# -gt 0 ] ; do
case "$1" in
--dataset|-s)
shift; input="$1" ;;
--recurse|-r)
action=update
shift; input="$1" ;;
--dest|-d)
shift; dest="$1" ;;
--quiet|-q)
verbosity=0 ; spoptions="$spoptions $1" ;;
--verbose|-v)
verbosity=2 ; spoptions="$spoptions $1" ;;
--starconvert-option)
shift; scoptions="$scoptions \"$1\"" ;
spoptions="$spoptions --starconvert-option \"$1\"";;
-*)
printusage; exit 0 ;;
*)
input="$1" ;;
esac ;
shift
done
# sanity checks on input
[ -z "$input" ] && printusage && exit 0
if [ ! -e "$input" ] ; then
echo "*** Requested input file or directory does not exist."
exit 1
fi
if [ ! -r "$input" ] ; then
echo "*** You do not have read permissions to requested input file."
exit 1
fi
# sanity checks on destination
if [ -z "$dest" ] ; then
echo "*** No destination specified, and you have no write permissions"
echo " to any of $DEFAULTDIR, \$PWD, \$HOME!"
exit 1
fi
if [ ! -d "$dest" ] && [ ! -e "`dirname "$dest"`" ] ; then
echo "*** Requested directory of destination does not exist."
exit 1
fi
if [ -d "$dest" ] && [ ! -w "$dest" ] || \
[ ! -d "$dest" ] && [ ! -w "`dirname "$dest"`" ]; then
echo "*** You do not have write permissions to that destination."
exit 1
fi
if [ $action = update ] ; then
for file in $input/* ; do
[ "$verbosity" -eq 0 ] || echo "Examining $file:"
eval \""$starpkg"\" --dataset \""$file"\" --dest \""$dest"\" $spoptions
[ "$verbosity" -eq 0 ] || echo
done
exit 0
fi
# if we have gotten this far, then action is for a single data set
if [ -d "$input" ] ; then
# test for spec file and catalog.dat
num_specfiles=`find "$input" -name '*.spec' | wc -l`
if [ $num_specfiles -eq 0 ] ; then
echo "*** Does not contain starconvert spec file."; exit 1
elif [ $num_specfiles -gt 1 ] ; then
echo "*** Contains $num_specfiles starconvert spec files (should only be one)."
exit 1
fi
num_catalogs=`find "$input" -name catalog.dat | wc -l`
if [ $num_catalogs -eq 0 ] ; then
echo "*** Does not contain catalog.dat data file."; exit 1
elif [ $num_catalogs -gt 1 ] ; then
echo "*** Contains $num_catalogs catalog.dat data files (should only be one)."
exit 1
fi
specname="`find "$input" -name '*.spec'`"
catalog="`find "$input" -name catalog.dat`"
dataname="`basename "$specname"`"
dataname="${dataname%.spec}.stars"
[ -d "$dest" ] && dest="$dest/$dataname"
[ "$verbosity" -eq 0 ] || echo "Will create file $dest"
if [ "$verbosity" -ge 2 ] ; then
eval \""$starconvert"\"$scoptions \""$specname"\" \""$catalog"\" \""$dest"\"
result=$?
else
eval \""$starconvert"\"$scoptions \""$specname"\" \""$catalog"\" \""$dest"\" > /dev/null 2>&1
result=$?
fi
if [ "$result" -ne 0 ] ; then
echo 1>&2
echo -n "*** starconvert failed" 1>&2
if [ "$verbosity" -ge 2 ] ; then
echo "." 1>&2
else
echo "; use the -v flag to starpkg" 1>&2
echo "*** to see the starconvert error output." 1>&2
fi
exit 1
else
[ "$verbosity" -eq 0 ] || echo "Done!"
fi
else # if we get here, we expect $input to be a tar.gz file
[ -n "$TMPDIR" ] || TMPDIR=/tmp
if [ ! -d "$TMPDIR" ] ; then
echo "*** Your temporary directory $TMPDIR is not a directory!"
exit 1
elif [ ! -w "$TMPDIR" ] ; then
echo "*** Your temporary directory $TMPDIR is not writable!"
exit 1
fi
# create a temporary directory in a safe and portable way
tmpfile=""
until mkdir "$tmpfile" > /dev/null 2>&1 ; do
RND="`head -n 10 /dev/urandom | tr -d -c "[:alnum:]" \
| cut -b 1-6`"
tmpfile="$TMPDIR/starpkg.$RND"
done
# uncompress tarball into the temp dir
(gunzip -c "$input" > "$tmpfile"/temp.tar) > /dev/null 2>&1
if [ "$?" -ne 0 ] ; then
echo "*** File does not seem to be a tar.gz archive."
rm -rf "$tmpfile"
exit 1
fi
cd "$tmpfile"
tar -xf temp.tar
if [ "$?" -ne 0 ] && [ "$verbosity" -gt 0 ] ; then
echo "*** Error untarring archive; will try to proceed anyway."
fi
rm -f temp.tar
# some shells output the new directory when executing "cd -"
cd - > /dev/null 2>&1
input="$tmpfile/`ls -1 "$tmpfile"`"
eval \""$starpkg"\" --dataset \""$input"\" --dest \""$dest"\" $spoptions
rm -rf "$tmpfile"
fi
|