mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
Everywhere: Remove everything non-essential for "make clean all"
This commit removes everything not strictly necessary for running "make clean all" inside jw-build. packaging jw-devtest. This cuts the repo down from 24077 to 4725 lines of code. The idea is to 1) Further remove bloat from the remaining bits 2) Re-add what's necessary to build and package other essential repos. The decision should be based on whether or not jw-build can also be useful in a non-janware context. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
c36c83c164
commit
bc883deed4
199 changed files with 0 additions and 18851 deletions
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
while true; do
|
||||
make pkg-release-reinstall
|
||||
[ $? = 0 ] && break
|
||||
echo ================================================================================================================
|
||||
sleep 60
|
||||
done
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
log()
|
||||
{
|
||||
echo "=== $@"
|
||||
}
|
||||
|
||||
err()
|
||||
{
|
||||
log $@
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
err $@
|
||||
exit 1
|
||||
}
|
||||
|
||||
lp()
|
||||
{
|
||||
scm.sh ls-files | grep "/$1$"
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "$myname [-h] [-t target-dir ] [ package-name ]"
|
||||
[ "$1" ] && exit $1
|
||||
}
|
||||
|
||||
collect_changes()
|
||||
{
|
||||
local projs="$*"
|
||||
local proj changed_path project_path p b lp
|
||||
|
||||
[ "$projs" ] || {
|
||||
if [ -f .git ]; then
|
||||
projs=`pwd | xargs basename`
|
||||
projs="$proj-run $proj-devel"
|
||||
else
|
||||
projs="$(jw-pkg list | sed 's/-[0-9].*//')"
|
||||
fi
|
||||
}
|
||||
|
||||
for proj in $projs; do
|
||||
(
|
||||
changed_paths=`rpm -qV $proj | sed '
|
||||
/^..5.*/ !d
|
||||
s%^..5...... . /%/%
|
||||
'`
|
||||
[ "$changed_paths" ] || exit
|
||||
project_path=$(echo $proj | sed 's/-run$\|-devel$//')
|
||||
|
||||
cd $project_path || {
|
||||
err "Failed to change to $project_path"
|
||||
exit
|
||||
}
|
||||
|
||||
log "Handling project $proj"
|
||||
|
||||
for p in $changed_paths; do
|
||||
[ -r $p ] || {
|
||||
err "can't read $p"
|
||||
continue
|
||||
}
|
||||
b=`basename $p`
|
||||
lp=`lp "$b"`
|
||||
[ "$lp" ] || {
|
||||
err "$p is not in repository"
|
||||
continue
|
||||
}
|
||||
nl=`lp "$b" | wc -l`
|
||||
[ $nl -gt 1 ] && {
|
||||
log $p is more than once in repository:
|
||||
lp $b
|
||||
continue
|
||||
}
|
||||
diff -q $lp $p >/dev/null 2>&1 && {
|
||||
continue
|
||||
}
|
||||
log copying $p $lp
|
||||
cp $p $lp
|
||||
done
|
||||
)
|
||||
done
|
||||
}
|
||||
|
||||
# -- here we go
|
||||
|
||||
set -- `getopt 'ht:' $*`
|
||||
while [ "$1" != -- ]; do
|
||||
case "$1" in
|
||||
-h)
|
||||
usage 0
|
||||
;;
|
||||
-t)
|
||||
target="$2"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
[ "$target" ] && {
|
||||
cd $target || fatal "failed to change to target dir \"$target\""
|
||||
}
|
||||
|
||||
collect_changes
|
||||
|
|
@ -1,117 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
cat_header()
|
||||
{
|
||||
cat <<-EOT
|
||||
====== Dummy-Titel ======
|
||||
----
|
||||
|
||||
===== Links =====
|
||||
----
|
||||
|
||||
* {{$namespace:$n, Stand `date +'%d.%m.%Y'`}}
|
||||
|
||||
===== Backlinks =====
|
||||
----
|
||||
{{backlinks>.}}
|
||||
|
||||
===== Annotierte Version =====
|
||||
----
|
||||
EOT
|
||||
}
|
||||
|
||||
strip()
|
||||
{
|
||||
sed "s/^ *//; s/ *$//" | grep .
|
||||
}
|
||||
|
||||
field()
|
||||
{
|
||||
grep "| *$2 *\(|\|$\)" $files | grep "pdfwiki\|binary" | cut -d\| -f$1 | strip
|
||||
}
|
||||
|
||||
cmd_name_extern_2_intern()
|
||||
{
|
||||
field 3 "$1"
|
||||
}
|
||||
|
||||
cmd_name_intern_2_extern()
|
||||
{
|
||||
field 2 "$1"
|
||||
}
|
||||
|
||||
cmd_uploads()
|
||||
{
|
||||
cat $files | grep "pdfwiki\|binary" | cut -d\| -f3 | strip
|
||||
}
|
||||
|
||||
cmd_milk_dirs()
|
||||
{
|
||||
local dirs="$@"
|
||||
for d in $dirs; do
|
||||
ls $d/* 2>/dev/null | while read f; do
|
||||
l=`basename "$f"`
|
||||
n=`cmd_name_extern_2_intern "$l"`
|
||||
[ "$n" ] || {
|
||||
echo "ignoring unknown file \"$l\""
|
||||
continue
|
||||
}
|
||||
[ -e "$n" ] && {
|
||||
echo "ignoring existing file \"$l\""
|
||||
continue
|
||||
}
|
||||
type=$(field 1 "$l")
|
||||
echo type=$type
|
||||
case $type in
|
||||
pdfwiki)
|
||||
t=`echo $n | sed 's/\.[^.]*$//'`
|
||||
txt="$t.txt"
|
||||
[ -e "$txt" ] && {
|
||||
echo "ignoring existing file \"$txt\""
|
||||
continue
|
||||
}
|
||||
cp "$f" "tmp-$n"
|
||||
pdftotext "tmp-$n"
|
||||
pdfimages -png -j tmp-$n $n
|
||||
rm -f $n-*.pnm
|
||||
cat_header "$l" "$n" > $txt.tmp
|
||||
cat tmp-$txt >> $txt.tmp
|
||||
mv $txt.tmp $txt
|
||||
mv tmp-$n $n
|
||||
rm -f tmp-$txt
|
||||
;;
|
||||
binary)
|
||||
cp "$f" "$n"
|
||||
;;
|
||||
*)
|
||||
echo "ignoring file with unknown extension: \"$f\""
|
||||
;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# ------------------------------------------------ here we go
|
||||
|
||||
files=files.txt
|
||||
namespace=files:doc:extern
|
||||
eval set -- `getopt -o hn: -l namespace: -- "$@"`
|
||||
while [ "$1" != -- ]; do
|
||||
case $1 in
|
||||
-n|--namespace)
|
||||
namespace="$2"
|
||||
shift
|
||||
;;
|
||||
-h)
|
||||
usage 0;;
|
||||
*)
|
||||
usage 1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
cmd="${1/-/_}"
|
||||
shift
|
||||
eval cmd_$cmd "$@"
|
||||
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
in=$1
|
||||
if [ "$2" ]; then
|
||||
out="$2"
|
||||
else
|
||||
out=`echo $1 | sed 's/\.\([^.]\+$\)/-greyed-out.\1/'`
|
||||
fi
|
||||
|
||||
#convert -monochrome $in $out
|
||||
#convert -monochrome -opaque \#e5e5e5 $in $out
|
||||
#convert -modulate 100,40 $in $out
|
||||
#convert +level 25% $in $out
|
||||
#convert +level 30% $in $out
|
||||
#convert -colorspace Gray $in $out
|
||||
#convert +level 30% -colorspace Gray $in $out
|
||||
convert -colorspace Gray +level 30% -brightness-contrast 35 $in $out
|
||||
|
||||
|
||||
# TODO: overlay same image, 1px shifted down and right, with different gray level
|
||||
|
||||
# ------------------------------------------------
|
||||
#convert small.miff -modulate 100,40 small-grey.miff
|
||||
#montage -fill black -font $P/LucidaGrande.ttf -pointsize 10 -geometry +0+0 -label "${LABEL}" -background transparent small-grey.miff small-text.png
|
||||
#composite -size 48x48 xc:$BGCOL -compose copy small-text.png mask.miff
|
||||
#composite small-text.png -compose atop mask.miff apmask.miff
|
||||
|
||||
# ------------------------------------------------
|
||||
#convert $in \( +clone -background black -shadow 75x0+0-5 \) \
|
||||
# \( -clone 0 -alpha off -virtual-pixel black -motion-blur 0x3-90 -alpha on \) \
|
||||
# -delete 0 -background none -layers merge +repage $out
|
||||
|
||||
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
cfg_section()
|
||||
{
|
||||
ini_section "$inifile" $@
|
||||
}
|
||||
|
||||
cfg_value()
|
||||
{
|
||||
ini_value "$inifile" $@
|
||||
}
|
||||
|
||||
# -- here we go
|
||||
|
||||
echo "== running $0" "$@" >&2
|
||||
|
||||
export LANG=POSIX
|
||||
dir=`dirname $0`
|
||||
inifile="$1"
|
||||
. $dir/ini-tools.sh
|
||||
|
||||
cat << EOT
|
||||
format_depends()
|
||||
{
|
||||
echo "\$@" | sed 's/ */,/g; s/,\([><=]\+\),*/\1/g; s/, *,*/,/g; s/, *$//; s/^ *,//; s/\([><=]\+\)\([0-9.-]\+\)/ (\1\2) /g'
|
||||
}
|
||||
|
||||
#changelog()
|
||||
#{
|
||||
# #dch -c /dev/stdout --create -v \$VERSION-\$RELEASE --package \$NAME
|
||||
#cat << EOF
|
||||
#\$NAME (\$VERSION-\$RELEASE) UNRELEASED; urgency=medium
|
||||
#
|
||||
# * Initial release. (Closes: #XXXXXX)
|
||||
#
|
||||
# -- Jan Lindemann <jan@janware.com> `date -R`
|
||||
#
|
||||
#EOF
|
||||
#}
|
||||
|
||||
compat()
|
||||
{
|
||||
echo -n 9
|
||||
}
|
||||
|
||||
control()
|
||||
{
|
||||
cat << EOF
|
||||
Source: \$NAME
|
||||
Maintainer: Jan Lindemann <jan@janware.com>
|
||||
Section: `cfg_value global.group`
|
||||
Priority: optional
|
||||
Standards-Version: 3.9.2
|
||||
Build-Depends: debhelper (>= 9)
|
||||
EOT
|
||||
|
||||
cfg_value global.subpackages | grep -q run && cat << EOT
|
||||
|
||||
Package: \$NAME-run
|
||||
Architecture: any
|
||||
Depends: \`format_depends "\${shlibs:Depends}, \${misc:Depends}, \$REQUIRES_RUN"\`
|
||||
# untested:
|
||||
Conflicts: \`format_depends "\$CONFLICTS_RUN"\`
|
||||
Description: `cfg_value summary`
|
||||
`cfg_value description | sed 's/^/ /'`
|
||||
EOT
|
||||
|
||||
cfg_value global.subpackages | grep -q devel && cat << EOT
|
||||
|
||||
Package: \$NAME-devel
|
||||
Architecture: any
|
||||
Depends: \`format_depends "\$NAME-run = \$VERSION-\$RELEASE, \$REQUIRES_DEVEL"\`
|
||||
# untested:
|
||||
Conflicts: \`format_depends "\$CONFLICTS_DEVEL"\`
|
||||
Description: \$NAME Development Package
|
||||
Development tools for \$NAME-run
|
||||
EOT
|
||||
|
||||
cat << EOT
|
||||
EOF
|
||||
}
|
||||
|
||||
copyright()
|
||||
{
|
||||
echo -n "Copyright (c) `date +'%Y'`, janware GmbH"
|
||||
}
|
||||
|
||||
format()
|
||||
{
|
||||
echo "3.0 (quilt)"
|
||||
}
|
||||
|
||||
rules()
|
||||
{
|
||||
cat << "EOF"
|
||||
#!/usr/bin/make -f
|
||||
|
||||
# tip from https://pkg-perl.alioth.debian.org/debhelper.html
|
||||
# PACKAGE = \$(firstword \$(shell dh_listpackages))
|
||||
# TMP = \$(CURDIR)/debian/\$(PACKAGE)
|
||||
|
||||
NAME = \$(shell pwd | xargs basename | sed 's/-[0-9.-]\+//')
|
||||
DEB_DIR = \$\$(pwd)/debian
|
||||
ENV_PREFIX = \$\$(pwd)/debian/tmp/inst-root
|
||||
EOF
|
||||
|
||||
echo INSTALL_LOG = \$INSTALL_LOG
|
||||
|
||||
cat << "EOF"
|
||||
%:
|
||||
EOF
|
||||
echo -e "\tdh \$""@"
|
||||
cat << EOF
|
||||
|
||||
override_dh_auto_test:
|
||||
|
||||
override_dh_installdirs:
|
||||
@echo "running override_dh_installdirs ($@)"
|
||||
#dh_installdirs
|
||||
|
||||
override_dh_auto_install:
|
||||
@echo "running override_dh_auto_install ($@)"
|
||||
mkdir -p \`dirname \$INSTALL_LOG\`
|
||||
> \$INSTALL_LOG
|
||||
\\\$(MAKE) ENV_PREFIX=\\\$(ENV_PREFIX) INSTALL_LOG=\\\$(INSTALL_LOG) install
|
||||
PATH=$JWB_SCRIPT_DIR:\\\$(PATH) /bin/bash pkg.sh milk-install-log -p \\\$(ENV_PREFIX) -n \\\$(NAME) -t deb \$INSTALL_LOG \\\$(DEB_DIR)
|
||||
dh_installdirs
|
||||
|
||||
override_dh_install:
|
||||
dh_install --sourcedir=./debian/tmp/inst-root
|
||||
|
||||
override_dh_shlibdeps:
|
||||
LD_LIBRARY_PATH=lib:\\\$(LD_LIBRARY_PATH) dh_shlibdeps
|
||||
|
||||
override_dh_auto_clean:
|
||||
|
||||
override_dh_compress:
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
mkdir -p debian
|
||||
#dch --create --empty
|
||||
cd debian
|
||||
|
||||
for file in compat control copyright format rules; do
|
||||
test -e \$file && continue
|
||||
\$file > \$file
|
||||
done
|
||||
|
||||
chmod 755 rules
|
||||
|
||||
cd ..
|
||||
|
||||
dch --create --newversion \$VERSION-\$RELEASE --controlmaint --package \$NAME --force-distribution --distribution \$DISTRIBUTION "Release built by $0"
|
||||
|
||||
echo "Produced by $0, the output should be in the \"debian\" sub-directory."
|
||||
EOT
|
||||
|
||||
|
|
@ -1,168 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
_cat()
|
||||
{
|
||||
sed 's/^ *|//'
|
||||
}
|
||||
|
||||
cfg_section()
|
||||
{
|
||||
ini_section "$inifile" $@
|
||||
}
|
||||
|
||||
cfg_value()
|
||||
{
|
||||
ini_value "$inifile" $@
|
||||
}
|
||||
|
||||
cfg_escape()
|
||||
{
|
||||
sed 's/\\/\\\\/g; s/\$/\\$/g; s/`/\\`/g'
|
||||
}
|
||||
|
||||
# unneeded but kept, because it might come in handy in the future
|
||||
have_pkg()
|
||||
{
|
||||
echo "$subpackages" | grep -q "\(^[ ]*\|[ ]\+\)$1\([ ]\+\|$\)"
|
||||
return $?
|
||||
}
|
||||
|
||||
subpackage_description()
|
||||
{
|
||||
case $1 in
|
||||
run)
|
||||
echo "Runtime files"
|
||||
;;
|
||||
devel)
|
||||
echo "Development files"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
os_cascade()
|
||||
{
|
||||
# might want to run python3 path/to/projects.py --os=suse-tumbleweed os-cascade
|
||||
# or turn this into a python script and use projects.py as a module.
|
||||
|
||||
if [ "$DISTRIBUTION" ]; then
|
||||
echo os linux $DISTRIBUTION | sed 's/\([^-]\+\)-\([^-]\+\)/\1 \1-\2/g'
|
||||
else
|
||||
echo os linux
|
||||
fi
|
||||
}
|
||||
|
||||
# -- here we go
|
||||
|
||||
echo "== running $0" "$@" >&2
|
||||
|
||||
export LANG=POSIX
|
||||
dir=`dirname $0`
|
||||
inifile="$1"
|
||||
. $dir/ini-tools.sh
|
||||
|
||||
subpackages=`cfg_value global.subpackages`
|
||||
license=`cfg_value global.license`
|
||||
[ "$license" ] || license="janware GmbH proprietary license"
|
||||
vendor=`cfg_value global.vendor`
|
||||
[ "$vendor" ] || vendor="janware GmbH"
|
||||
url=`cfg_value global.url`
|
||||
[ "$url" ] || url="https://janware.com"
|
||||
|
||||
_cat <<- EOT
|
||||
|echo "%define debug_package %{nil}"
|
||||
|# ---------------------------------------
|
||||
|echo "Name: \$NAME"
|
||||
|echo "Summary: `cfg_value summary`"
|
||||
|echo "Version: \$VERSION"
|
||||
|echo "Release: \$RELEASE"
|
||||
|echo "License: $license"
|
||||
|echo "Group: System/Libraries"
|
||||
|[ -n "\$SOURCE" ] && echo "Source: \$SOURCE"
|
||||
|echo "Vendor: $vendor"
|
||||
|echo "URL: $url"
|
||||
|echo "BuildRoot: /var/tmp/%{name}-buildroot"
|
||||
|echo "Distribution: jw / openSUSE Tumbleweed"
|
||||
|echo ""
|
||||
|echo "%description"
|
||||
|echo "`cfg_value description`"
|
||||
|echo ""
|
||||
|# ---------------------------------------
|
||||
|echo "%prep"
|
||||
|echo "%setup -q -n \$NAME-\$V"
|
||||
|echo ""
|
||||
|echo "%build"
|
||||
|echo 'pwd'
|
||||
|echo 'make config'
|
||||
|echo 'make'
|
||||
|echo ""
|
||||
|echo "%install"
|
||||
|echo 'rm -rf \$RPM_BUILD_ROOT'
|
||||
|echo "export ENV_PREFIX=\\\$RPM_BUILD_ROOT"
|
||||
|echo "export INSTALL_LOG=\$INSTALL_LOG"
|
||||
|echo "mkdir -p \`dirname \$INSTALL_LOG\`"
|
||||
|echo "> \$INSTALL_LOG"
|
||||
|echo "make install"
|
||||
|echo "export PATH=$JWB_SCRIPT_DIR:\\\$PATH"
|
||||
|echo "/bin/bash pkg.sh milk-install-log -p \\\$ENV_PREFIX -n \$NAME -t rpm -s \\"$subpackages\\" \$INSTALL_LOG \`dirname \$INSTALL_LOG\`"
|
||||
|echo "exit 0" # <- Cut short CentOS magic appended to install scriptlet, which would generate .pyo files and other cruft.
|
||||
EOT
|
||||
|
||||
for p in $subpackages; do
|
||||
|
||||
P=${p^^}
|
||||
|
||||
_cat <<- EOT
|
||||
|echo ""
|
||||
|echo "# --------------------------------------- subpackage $p"
|
||||
|echo ""
|
||||
|echo "%package -n \$NAME-$p"
|
||||
|echo "Summary: `cfg_value summary`"
|
||||
|echo "Group: `cfg_value global.group`"
|
||||
|[ "\$REQUIRES_$P" ] && echo "Requires: \$REQUIRES_$P"
|
||||
|[ "\$CONFLICTS_$P" ] && echo "Conflicts: \$CONFLICTS_$P"
|
||||
|[ "\$PROVIDES_$P" ] && echo "Provides: \$PROVIDES_$P"
|
||||
|echo ""
|
||||
EOT
|
||||
|
||||
descr=`subpackage_description $p`
|
||||
if [ "$descr" ]; then
|
||||
_cat <<- EOT
|
||||
|echo ""
|
||||
|echo "%description -n \$NAME-$p"
|
||||
|echo "$descr"
|
||||
EOT
|
||||
fi
|
||||
|
||||
for stage in pre preun post postun; do
|
||||
echo "== processing stage $stage: cfg_section pkg.$p.$stage" >&2
|
||||
out=""
|
||||
#for os in '' `os_cascade | sed 's/\(^\| \)/ ./g'`; do
|
||||
for os in '' `os_cascade`; do
|
||||
sec=pkg.$p.$stage
|
||||
if [ "$os" ]; then
|
||||
sec="$sec.$os"
|
||||
head="\n# --- $os\n"
|
||||
else
|
||||
head=""
|
||||
fi
|
||||
cfg_section $sec | grep -q . || continue
|
||||
out="$out$head`cfg_section $sec`"
|
||||
done
|
||||
if [ "$out" ]; then
|
||||
echo -e "$out" >&2
|
||||
_cat <<- EOT
|
||||
|echo ""
|
||||
|echo "%$stage -n \$NAME-$p"
|
||||
EOT
|
||||
echo "cat << EOT"
|
||||
echo -e "$out" | cfg_escape
|
||||
echo "EOT"
|
||||
fi
|
||||
done
|
||||
|
||||
_cat <<- EOT
|
||||
|echo ""
|
||||
|echo "%files -n \$NAME-$p -f \$INSTALL_LOG.\$NAME-$p"
|
||||
|echo '%defattr (-, root, root)'
|
||||
EOT
|
||||
done
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
log()
|
||||
{
|
||||
echo $@
|
||||
}
|
||||
|
||||
err()
|
||||
{
|
||||
echo $@ >&2
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
err $@
|
||||
exit 1
|
||||
}
|
||||
|
||||
cmd_list_projects()
|
||||
{
|
||||
local all_proj proj p
|
||||
(
|
||||
cd $projroot || fatal Failed to change to $projroot
|
||||
all_proj=`find . -maxdepth 1 -mindepth 1 -type d`
|
||||
for p in $all_proj; do
|
||||
test -x $p || continue
|
||||
test -r $p || continue
|
||||
p=${p##./}
|
||||
test -f $HOME/cvs-list.txt && grep -q "^$p$" $HOME/cvs-list.txt || continue
|
||||
proj="$proj $p"
|
||||
done
|
||||
[ "$proj" ] && echo $proj
|
||||
)
|
||||
}
|
||||
|
||||
# ---------- here we go
|
||||
cvsroot=/srv/cvs
|
||||
projroot=$cvsroot/proj
|
||||
cmd=${1/-/_}
|
||||
shift
|
||||
eval cmd_$cmd $@
|
||||
189
scripts/dpm.sh
189
scripts/dpm.sh
|
|
@ -1,189 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
log_dpkg()
|
||||
{
|
||||
echo dpkg $@
|
||||
/usr/bin/dpkg $@
|
||||
}
|
||||
|
||||
run()
|
||||
{
|
||||
echo $@
|
||||
eval $@
|
||||
}
|
||||
|
||||
# to be used on debian prior to jessie
|
||||
dpkg_verify()
|
||||
{
|
||||
local exitcode file pkg hashfile rfile phash hash
|
||||
exitcode=0
|
||||
for file in $*; do
|
||||
pkg=`dpkg -S "$file" | cut -d: -f 1`
|
||||
hashfile="/var/lib/dpkg/info/$pkg.md5sums"
|
||||
if [ -s "$hashfile" ]; then
|
||||
rfile=`echo "$file" | cut -d/ -f 2-`
|
||||
phash=`grep -E "$rfile\$" "$hashfile" | cut -d\ -f 1`
|
||||
hash=`md5sum "$file" | cut -d\ -f 1`
|
||||
if [ "$hash" = "$phash" ]; then
|
||||
echo "$file: ok"
|
||||
else
|
||||
echo "$file: CHANGED"
|
||||
exitcode=1
|
||||
fi
|
||||
else
|
||||
echo "$file: UNKNOWN"
|
||||
exitcode=1
|
||||
fi
|
||||
done
|
||||
return $exitcode
|
||||
}
|
||||
|
||||
cmd_install()
|
||||
{
|
||||
local n=`basename $1`
|
||||
n=`echo $n | sed "s/_[0-9.-]\+_amd64.deb//"`
|
||||
/bin/bash $0 -q $n >/dev/null 2>&1 && {
|
||||
fatal "$n is already installed (`/bin/bash $0 -q $n`)"
|
||||
}
|
||||
cmd_update $1
|
||||
}
|
||||
|
||||
cmd_update()
|
||||
{
|
||||
$dpkg --dry-run -i $1 || fatal "Test-installation failed."
|
||||
$dpkg -i $1 || fatal "Installation failed."
|
||||
}
|
||||
|
||||
cmd_erase()
|
||||
{
|
||||
#$dpkg -r $1
|
||||
$dpkg --purge $*
|
||||
}
|
||||
|
||||
cmd_query()
|
||||
{
|
||||
[ "$query_cmds" ] && {
|
||||
local cmd installed
|
||||
local id=name
|
||||
if echo $query_cmds | grep -q p; then
|
||||
id=pkg
|
||||
query_cmds=`echo $query_cmds | sed 's/p//'`
|
||||
elif echo $query_cmds | grep -q f; then
|
||||
id=file
|
||||
query_cmds=`echo $query_cmds | sed 's/f//'`
|
||||
fi
|
||||
for cmd in $query_cmds; do
|
||||
case $cmd in
|
||||
V)
|
||||
$dpkg --verify $1
|
||||
;;
|
||||
i)
|
||||
case $id in
|
||||
file)
|
||||
$dpkg -I $1;;
|
||||
name)
|
||||
$dpkg -s $1;;
|
||||
#run apt-cache show $1;;
|
||||
pkg)
|
||||
$dpkg -S $1;;
|
||||
esac
|
||||
;;
|
||||
l)
|
||||
case $id in
|
||||
file)
|
||||
echo blah
|
||||
#$dpkg -p $1;;
|
||||
;;
|
||||
name)
|
||||
$dpkg -L $1;;
|
||||
pkg)
|
||||
$dpkg -c $1;;
|
||||
esac
|
||||
;;
|
||||
a)
|
||||
$dpkg -l $1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
return $?
|
||||
}
|
||||
|
||||
local p=`echo $1 | sed 's/-[0-9.-]\+$//'`
|
||||
local v=`echo $1 | sed "s/^$p-*//"`
|
||||
local ip=`dpkg-query -W -f '${Package}' $p >/dev/null 2>&1`
|
||||
[ $? != 0 -o -z "$ip" ] && exit 1
|
||||
local iv=`dpkg-query -W -f '${Version}' $p >/dev/null 2>&1`
|
||||
[ "$v" ] && {
|
||||
[ "$v" != "$iv" ] && {
|
||||
echo "tried $1, installed version is $iv" >&2
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
echo $ip-$iv
|
||||
return 0
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "usage: $myname [-h] [... misc rpm options]"
|
||||
[ "$1" ] && exit $1
|
||||
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
echo $@ >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# -- here we go
|
||||
myname=`basename $0`
|
||||
dpkg=log_dpkg
|
||||
cmd=""
|
||||
|
||||
set -- `getopt hqiUeVfapl "$@"`
|
||||
while [ "$1" != -- ]; do
|
||||
case $1 in
|
||||
-h)
|
||||
usage 0
|
||||
;;
|
||||
-q)
|
||||
[ "$cmd" ] && usage 1
|
||||
cmd=query
|
||||
;;
|
||||
-V|-f|-a|-p|-l)
|
||||
[ "$cmd" ] && {
|
||||
[ "$cmd" = query ] || usage 1
|
||||
query_cmds="$query_cmds ${1:1:1}"
|
||||
}
|
||||
;;
|
||||
-i)
|
||||
[ "$cmd" ] && {
|
||||
[ "$cmd" = query ] || usage 1
|
||||
query_cmds="$query_cmds ${1:1:1}"
|
||||
shift
|
||||
continue
|
||||
}
|
||||
cmd=install
|
||||
;;
|
||||
-U)
|
||||
[ "$cmd" ] && usage 1
|
||||
cmd=update
|
||||
;;
|
||||
-e)
|
||||
[ "$cmd" ] && usage 1
|
||||
cmd=erase
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
# [ $# != 1 ] && usage 1
|
||||
[ "$cmd" ] || usage 1
|
||||
|
||||
eval cmd_\$cmd $*
|
||||
|
||||
|
|
@ -1,201 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
myname=`basename $0`
|
||||
cwd=`pwd`
|
||||
|
||||
make_initrd_from_template()
|
||||
{
|
||||
uname_r=$1
|
||||
target=$2
|
||||
modules_dir=$3
|
||||
template=$4
|
||||
shift 4
|
||||
mod_names="$*"
|
||||
|
||||
# set up work space
|
||||
dir=`mktemp -d "/tmp/$myname""_XXXXXX"`
|
||||
mkdir $dir/source
|
||||
|
||||
# unpack template and copy it
|
||||
cat $template | (cd $dir/source; gunzip | cpio -i)
|
||||
cp -rp $dir/source $dir/target
|
||||
rm -rf $dir/target/lib/modules/*
|
||||
|
||||
# copy all modules both in template and kernel
|
||||
(
|
||||
cd $dir/source
|
||||
find . -name '*.ko'
|
||||
) | while read tmpl_relpath; do
|
||||
|
||||
mod_name=`basename $tmpl_relpath`
|
||||
source_mod=`cd $modules_dir; find . -name $mod_name`
|
||||
|
||||
if [ ! "$source_mod" ]; then
|
||||
echo "warning: module $mod_name not found in $modules_dir" >&2
|
||||
# exit 1
|
||||
else
|
||||
mod_relpath=`dirname $source_mod`
|
||||
target_path=$dir/target/lib/modules/$uname_r/$mod_relpath
|
||||
echo "copying $mod_name from $mod_relpath to $target_path"
|
||||
mkdir -p $target_path
|
||||
cp -p $modules_dir/$source_mod $target_path
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
# copy all explicitly specified modules
|
||||
for mod_name in $mod_names; do
|
||||
echo "processing explicitly requested module $mod_name"
|
||||
mod_source_path=`find $modules_dir -name $mod_name.ko`
|
||||
if [ -z "$mod_source_path" ]; then
|
||||
echo "warning: explicitly specified module $mod_name not found in $uname_r" >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
mod_relpath=`echo $mod_source_path | sed "s%$modules_dir%%g; s/$mod_name.ko$//"`
|
||||
target_path=$dir/target/lib/modules/$uname_r/$mod_relpath
|
||||
echo "copying $mod_name from $mod_relpath to $target_path"
|
||||
mkdir -p $target_path
|
||||
cp -p $mod_source_path $target_path
|
||||
done
|
||||
|
||||
# linuxrc
|
||||
if [ "$linux_rc" ]; then
|
||||
echo "copying $linux_rc to linuxrc"
|
||||
cp $linux_rc $dir/target/init
|
||||
fi
|
||||
|
||||
# depmod
|
||||
/sbin/depmod -a -b $dir/target -v $uname_r > /dev/null
|
||||
|
||||
# pack stuff up
|
||||
(cd $dir/target; find . | cpio -co) | gzip -9 > $target
|
||||
|
||||
rm -rf $dir
|
||||
}
|
||||
|
||||
unquote()
|
||||
{
|
||||
cat | sed 's/^[ ]*|//'
|
||||
}
|
||||
|
||||
config_section()
|
||||
{
|
||||
output_file=
|
||||
add_boot_dir=
|
||||
add_modules_basedir=
|
||||
root_dev=
|
||||
initrd_template=
|
||||
sed -n "/\[$2\]/,/\[/ p" $1 | sed '/]/ d; s/#.*//; /./ !d; s/ *= */=/; s/=\(.*\)/="\1"/'
|
||||
}
|
||||
|
||||
boot_sections()
|
||||
{
|
||||
sed '/\[boot\..*\]/ !d; s/\[boot\.//; s/\].*//' $1
|
||||
}
|
||||
|
||||
|
||||
name_filter()
|
||||
{
|
||||
echo $1 | \
|
||||
tr [A-Z] [a-z] | \
|
||||
sed 's/\.tar\.gz/.tgz/; s/-/_/g; s/\([^.]*\)\.\([^.]*\)$$/\1@\2/; s/\./_/g; s/@/./'
|
||||
}
|
||||
|
||||
#make_initrd $template $modules_dir
|
||||
|
||||
set -- `getopt 'i:f:o:d:' $*`
|
||||
|
||||
while [ "$1" != -- ]; do
|
||||
case $1 in
|
||||
-f)
|
||||
opt_config_file="$2"
|
||||
shift
|
||||
;;
|
||||
-o)
|
||||
opt_output_file="$2"
|
||||
shift
|
||||
;;
|
||||
-d)
|
||||
opt_build_dir="$2"
|
||||
boot_dir="$2"
|
||||
shift
|
||||
;;
|
||||
-i)
|
||||
linux_rc="$2"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
if [ ! "$opt_build_dir" ]; then
|
||||
boot_dir=`mktemp -d "/tmp/$myname""_XXXXXX"`
|
||||
fi
|
||||
|
||||
eval `config_section $opt_config_file global`
|
||||
|
||||
echo DEFAULT menu.c32 > $boot_dir/isolinux.cfg
|
||||
echo PROMPT 0 >> $boot_dir/isolinux.cfg
|
||||
|
||||
for sec in `boot_sections $opt_config_file`; do
|
||||
|
||||
echo "+ processing section boot.$sec"
|
||||
config_section $opt_config_file boot.$sec
|
||||
eval `config_section $opt_config_file boot.$sec`
|
||||
|
||||
if [ "$add_boot_dir" ]; then
|
||||
|
||||
echo "+ adding boot directory $add_boot_dir"
|
||||
for f in $add_boot_dir/*; do
|
||||
b=`basename $f`
|
||||
n=`name_filter $b`
|
||||
echo "+ copying $f -> $n"
|
||||
cp -p $f $boot_dir/$n
|
||||
done
|
||||
|
||||
kernels=`file $add_boot_dir/* | grep -ie 'linux.*kernel' | sed 's/:.*//'`
|
||||
for kernel in $kernels; do
|
||||
|
||||
kernel_version=`basename $kernel | sed 's/vmlinuz-//'`
|
||||
kernel_version_iso=`name_filter $kernel_version | cut -b1-21`
|
||||
|
||||
echo "+ processing kernel $kernel (version $kernel_version)"
|
||||
|
||||
# create initrd
|
||||
if [ "$initrd_template" ]; then
|
||||
echo "+ creating initial ram disk from template $initrd_template"
|
||||
make_initrd_from_template \
|
||||
$kernel_version \
|
||||
$boot_dir/initrd_$kernel_version_iso \
|
||||
$add_modules_basedir/$kernel_version \
|
||||
$initrd_template \
|
||||
$included_modules
|
||||
fi
|
||||
|
||||
# create isolinux.cfg
|
||||
cat << EOT | unquote >> $boot_dir/isolinux.cfg
|
||||
|
|
||||
|LABEL $kernel_version
|
||||
|KERNEL vmlinuz_$kernel_version_iso
|
||||
|APPEND initrd=initrd_$kernel_version_iso root=$root_dev
|
||||
EOT
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
cp $* $boot_dir
|
||||
|
||||
mkisofs -l --iso-level 2 -o $opt_output_file \
|
||||
-b isolinux.bin -c boot.cat \
|
||||
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
||||
$boot_dir
|
||||
|
||||
if [ ! "$opt_build_dir" ]; then
|
||||
rm -rf $boot_dir
|
||||
fi
|
||||
|
||||
|
|
@ -1,246 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
myname=`basename $0`
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOT | sed 's/^ |//'
|
||||
|
|
||||
| $myname [global options] cmd [cmd-arguments] ...
|
||||
|
|
||||
| global options are:
|
||||
|
|
||||
| -F flavour : flavour is one of: priv, jw, contrib
|
||||
|
|
||||
| commands are:
|
||||
|
|
||||
| create-repo name
|
||||
| update-descriptions
|
||||
| list-repos
|
||||
| create-repo-dir
|
||||
| list-maintainers
|
||||
|
|
||||
EOT
|
||||
[ "$1" ] && exit $1
|
||||
}
|
||||
|
||||
log()
|
||||
{
|
||||
echo $@
|
||||
logger -t $myname "$@"
|
||||
}
|
||||
|
||||
err()
|
||||
{
|
||||
echo $@ >&2
|
||||
logger -t $myname "error: $@"
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
err "fatal: $@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
md()
|
||||
{
|
||||
local dir=$1
|
||||
local mode=$2
|
||||
local owner=$3
|
||||
local group=$4
|
||||
|
||||
[ -d $dir ] || {
|
||||
|
||||
log "creating $dir as $owner.$group with mode $mode"
|
||||
/usr/bin/install -m $mode -o $owner -g $group -d $dir || {
|
||||
fatal "failed to create directory $dir"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
check_user_is_self()
|
||||
{
|
||||
[ "$id" != "$user" ] && fatal "User $id is not allowed to do this to user $user's repositories."
|
||||
}
|
||||
|
||||
# ----------------- commands
|
||||
md_p()
|
||||
{
|
||||
[ -d "$1" ] && return
|
||||
md_p `dirname "$1"` $2 $3 $4
|
||||
md $@
|
||||
}
|
||||
|
||||
cmd_cmd_create_repo_dir()
|
||||
{
|
||||
[ "$UID" != 0 ] && fatal "tried to create directory \"$dir\" as `whoami`, needs to be done as root"
|
||||
local gid=`id -g $id`
|
||||
md_p /srv/git 750 root git
|
||||
md_p /srv/git/$id 750 root git
|
||||
md_p `dirname $dir` 750 $id $gid
|
||||
md_p $dir 02750 $id $gid
|
||||
}
|
||||
|
||||
cmd_create_repo()
|
||||
{
|
||||
[ -e $dir ] && {
|
||||
err "$dir already exists"
|
||||
test $no_error_if_exists -eq 0
|
||||
exit $?
|
||||
}
|
||||
|
||||
/usr/bin/sudo `readlink -f $0` create-project-dir $dir || fatal "failed to create [$dir] as root"
|
||||
cd $dir || fatal "failed to change to $dir"
|
||||
git init --bare --shared=0640 || fatal "git init failed"
|
||||
}
|
||||
|
||||
read_project_metadata()
|
||||
{
|
||||
local pd="$1"
|
||||
local field="$2"
|
||||
git -C $pd show HEAD:make/project.conf | sed -n "/^\[$field\]/,/^\[/ p" | grep -v '\[' | cat -s | sed '${/^$/d;}'
|
||||
}
|
||||
|
||||
cmd_update_descriptions()
|
||||
{
|
||||
[ -d $pdir ] || return 0
|
||||
cd $pdir || return 1
|
||||
local projs="$*"
|
||||
[ "$projs" = all ] && projs=`cmd_list_repos`
|
||||
local proj
|
||||
for proj in $projs; do
|
||||
umask 0022
|
||||
[ -d "$proj" ] || fatal "Failed to find project $pdir/$proj"
|
||||
local tmp=`mktemp /tmp/$myname-XXXXXXX`
|
||||
local descr=$proj/description
|
||||
read_project_metadata $proj summary > $tmp
|
||||
[ -s "$tmp" ] || read_project_metadata $proj description > $tmp
|
||||
if [ -s "$tmp" ] && ! diff -q "$tmp" "$descr" >/dev/null 2>&1; then
|
||||
chown --reference=$proj $tmp
|
||||
chmod 640 $tmp
|
||||
echo "====== Changing description of $proj"
|
||||
echo '-- old --'
|
||||
cat $descr
|
||||
echo '-- new --'
|
||||
cat $tmp
|
||||
mv $tmp $descr
|
||||
fi
|
||||
rm -f $tmp
|
||||
done
|
||||
}
|
||||
|
||||
cmd_list_repos()
|
||||
{
|
||||
[ -d $pdir ] || return 0
|
||||
cd $pdir || return 1
|
||||
ls */HEAD | sed 's%/HEAD%%' 2>/dev/null
|
||||
return $?
|
||||
}
|
||||
|
||||
cmd_list_maintainers()
|
||||
{
|
||||
local dev_chief=jan
|
||||
local master_dir=/srv/git/$dev_chief/proj
|
||||
local d pdir p val
|
||||
|
||||
for d in $master_dir; do
|
||||
for pdir in `find $d -maxdepth 1 -mindepth 1 -type d`; do
|
||||
[ -x $pdir ] || continue
|
||||
[ -r $pdir ] || continue
|
||||
#echo "$d -> $pdir"
|
||||
p=`basename $pdir`
|
||||
val=`git -C $pdir show HEAD:make/project.conf 2>/dev/null |
|
||||
sed -n '/^\[global\]/,/^\[/ p' |
|
||||
sed '
|
||||
/^[[:space:]]*jw-maintainer/ !d;
|
||||
s/.*= *//
|
||||
'`
|
||||
[ "$val" ] || val="unknown"
|
||||
[ "$val" ] || continue
|
||||
printf "%-30s %s\n" $p $val
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# ----------------- here we go
|
||||
no_error_if_exists=0
|
||||
id=`whoami`
|
||||
#user=$id
|
||||
flavour=priv
|
||||
|
||||
OPTIND=1
|
||||
while getopts jhu:F: flag; do
|
||||
|
||||
case $flag in
|
||||
h)
|
||||
usage 0;;
|
||||
u)
|
||||
user=$OPTARG;;
|
||||
j) # legacy support
|
||||
flavour=jw;;
|
||||
F)
|
||||
flavour=$OPTARG;;
|
||||
p)
|
||||
no_error_if_exist=1;;
|
||||
*)
|
||||
usage 1;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
if [ "$user" ]; then
|
||||
id=$user
|
||||
else
|
||||
if [ "$SUDO_UID" ]; then
|
||||
id=`/usr/bin/getent passwd $SUDO_UID | cut -d: -f1`
|
||||
[ "$id" ] || fatal "failed to find uid $SUDO_UID in user database"
|
||||
fi
|
||||
user=$id
|
||||
fi
|
||||
|
||||
git_home=/srv/git/$id
|
||||
pdir=$git_home/priv
|
||||
|
||||
case $flavour in
|
||||
jw|proj)
|
||||
pdir=$git_home/proj;;
|
||||
priv)
|
||||
pdir=$git_home/priv;;
|
||||
test)
|
||||
pdir=$git_home/test;;
|
||||
contrib)
|
||||
pdir=$git_home/contrib;;
|
||||
*)
|
||||
fatal "unknown repository flavour \"$flavour\""
|
||||
esac
|
||||
|
||||
cmd=$1
|
||||
shift
|
||||
p=$1
|
||||
|
||||
dir=$pdir/$p
|
||||
|
||||
case $cmd in
|
||||
create-personal-project|create-repo)
|
||||
check_user_is_self
|
||||
cmd_create_repo "$@"
|
||||
;;
|
||||
update-descriptions|update-descr)
|
||||
cmd_update_descriptions "$@"
|
||||
;;
|
||||
list-personal-projects|list-repos)
|
||||
cmd_list_repos "$@"
|
||||
;;
|
||||
create-project-dir|create-repo-dir)
|
||||
dir=$1 # this is all a horrible variable and usage mess
|
||||
check_user_is_self
|
||||
cmd_cmd_create_repo_dir "$@"
|
||||
;;
|
||||
list-maintainers|maintainers)
|
||||
cmd_list_maintainers
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
get_conf_sec()
|
||||
{
|
||||
sed -n "/\[$1\]/,/\[/ p" | sed '/]/ d; s/#.*//; /./ !d; s/ *= */=/; s/=\(.*\)/="\1"/'
|
||||
}
|
||||
|
||||
cat $2 | get_conf_sec $1
|
||||
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
ini_section()
|
||||
{
|
||||
local inifile="$1"
|
||||
local sec="$2"
|
||||
cat "$inifile" |
|
||||
cut -d\# -f1 |
|
||||
tr -s '\n' '\n' |
|
||||
sed -n "/^ *\[$sec\]/,/^ *\[/ p" |
|
||||
grep -v '^ *\[' |
|
||||
sed '/^ *$/ d'
|
||||
}
|
||||
|
||||
ini_value()
|
||||
{
|
||||
local inifile="$1"
|
||||
local path="$2"
|
||||
local sec=`echo "$path" | sed 's/\.[^.]\+$//'`
|
||||
local key=`echo "$path" | sed 's/.*\.//'`
|
||||
|
||||
# echo "path=>$path<"
|
||||
# echo "sec=>$sec<"
|
||||
# echo "key=>$key<"
|
||||
|
||||
if [ "$key" = "$path" ]; then
|
||||
ini_section "$inifile" "$path"
|
||||
return 0
|
||||
fi
|
||||
|
||||
ini_section "$inifile" "$sec" | sed "
|
||||
/^ *$key *=/ !d
|
||||
s/^ *$key *= *//
|
||||
s/ *$//
|
||||
/^ *$/ d
|
||||
"
|
||||
}
|
||||
|
||||
ini_has_section()
|
||||
{
|
||||
local inifile="$1"
|
||||
local sec="$2"
|
||||
grep -q "^ *\[$sec\]" $inifile || return 1
|
||||
}
|
||||
|
||||
ini_has_value()
|
||||
{
|
||||
ini_value $@ | grep -q .
|
||||
}
|
||||
|
||||
ini_escape()
|
||||
{
|
||||
cat | sed '
|
||||
s/\$/\\$/g
|
||||
s/`/\\\`/g
|
||||
'
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load diff
226
scripts/jannet
226
scripts/jannet
|
|
@ -1,226 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
myname=`basename $0`
|
||||
longname=$0
|
||||
opts="v"
|
||||
|
||||
channel_present()
|
||||
{
|
||||
if smart channel --show $1 2>&1 | grep -q baseurl >/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOT
|
||||
|
||||
$myname command [arguments]
|
||||
|
||||
command is one of
|
||||
|
||||
help: show this help screen
|
||||
init: initialize
|
||||
uninit: undo initialization
|
||||
install: install packages in [arguments]
|
||||
update: update all jannet software on the system
|
||||
restore: restore a previous jannet software version state
|
||||
info: query information about installed software
|
||||
checklog: update the installation log file if necessary
|
||||
rpmnew: remove superfluous rpmnew files and show conflicts
|
||||
for others
|
||||
build-date: show installed jannet packages along with build date
|
||||
built-today: show installed jannet packages that were built today
|
||||
|
||||
EOT
|
||||
if [ "$1" ]; then
|
||||
exit $1
|
||||
fi
|
||||
}
|
||||
|
||||
get_opts()
|
||||
{
|
||||
set -- `getopt $opts $*`
|
||||
while [ "$1" != -- ] ; do
|
||||
case "$1" in
|
||||
-v)
|
||||
opt_verbose=true
|
||||
;;
|
||||
*)
|
||||
eusage
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
}
|
||||
|
||||
create_ldconfig_state()
|
||||
{
|
||||
echo "=== automatically created by $myname update script"
|
||||
echo "--- files"
|
||||
ls /etc/ld.so.conf.d
|
||||
echo "--- directories"
|
||||
find /etc/ld.so.conf.d -type f | xargs cat | sort -u
|
||||
}
|
||||
|
||||
check_ldconfig()
|
||||
{
|
||||
local state=/var/log/jw-build-ldconf.state
|
||||
[ -f $state ] && create_ldconfig_state | diff $state - >/dev/null 2>&1 && return
|
||||
echo -n "running ldconfig ... "
|
||||
/sbin/ldconfig
|
||||
create_ldconfig_state > $state
|
||||
echo "done."
|
||||
}
|
||||
|
||||
list_all_packages()
|
||||
{
|
||||
rpm -qa --queryformat '%{NAME}: %{URL}\n' | \
|
||||
grep -i '^[^ ]\+:.*\(jannet\.de\|janware\.com\)' | \
|
||||
sed 's/\(^[^ ]\+\) *:.*/\1/; s/[ ]*$//' |\
|
||||
sort -u
|
||||
}
|
||||
|
||||
cmd_rpmnew()
|
||||
{
|
||||
local file
|
||||
|
||||
list_all_packages |
|
||||
xargs rpm -ql |
|
||||
while read file; do
|
||||
if [ -e "$file.rpmnew" ]; then
|
||||
if diff -q $file $file.rpmnew; then
|
||||
if [ -L "$file" ]; then
|
||||
echo ========== skipping link $file
|
||||
diff $file.rpmnew $file
|
||||
continue
|
||||
fi
|
||||
echo mv $file.rpmnew $file
|
||||
sudo mv $file.rpmnew $file
|
||||
else
|
||||
echo =========== $file
|
||||
diff $file.rpmnew $file
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
cmd_diff()
|
||||
{
|
||||
local file
|
||||
|
||||
list_all_packages |
|
||||
xargs rpm -qV |
|
||||
sed '/^....L\|^..5/ !d; s%[^/]*/%/%' |
|
||||
while read file; do
|
||||
if diff -q $file $file.rpmnew; then
|
||||
if [ -L "$file" ]; then
|
||||
echo ========== skipping link $file
|
||||
diff $file.rpmnew $file
|
||||
continue
|
||||
fi
|
||||
echo mv $file.rpmnew $file
|
||||
sudo mv $file.rpmnew $file
|
||||
else
|
||||
echo =========== $file
|
||||
diff $file.rpmnew $file
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
cmd_build_date()
|
||||
{
|
||||
list_all_packages |
|
||||
xargs rpm -q --queryformat '%{BUILDTIME} %{NAME}\n' |
|
||||
sort -n |
|
||||
sed 's/-run\|-devel//' |
|
||||
sort -u |
|
||||
while read t p; do
|
||||
echo `date --date=@$t --rfc-3339=seconds` $p
|
||||
done
|
||||
}
|
||||
|
||||
cmd_built_today()
|
||||
{
|
||||
local today=`date +'%Y-%m-%d'`
|
||||
cmd_build_date | grep $today | cut -d' ' -f3
|
||||
}
|
||||
|
||||
cmd="$1"
|
||||
shift
|
||||
get_opts $*
|
||||
|
||||
case $cmd in
|
||||
|
||||
init)
|
||||
if ! channel_present jw-foss; then
|
||||
echo -n "adding installation source ... "
|
||||
sudo smart channel -y --add jw-foss \
|
||||
type=yast2 \
|
||||
baseurl=https://pkg:we0rntj3p@janware.com/files/packages/jw-foss/suse/tumbleweed?auth=basic&credentials=jannet.cat \
|
||||
>/dev/null 2>&1
|
||||
if channel_present; then echo done; else echo failed; fi
|
||||
fi
|
||||
;;
|
||||
|
||||
uninit)
|
||||
if channel_present jw-foss; then
|
||||
echo -n "removing installation source ... "
|
||||
sudo smart channel -y --remove jw-foss >/dev/null 2>&1
|
||||
echo done
|
||||
fi
|
||||
;;
|
||||
|
||||
update)
|
||||
sudo smart update jw-foss
|
||||
sudo smart upgrade -y
|
||||
check_ldconfig
|
||||
;;
|
||||
|
||||
install)
|
||||
sudo smart update jw-foss
|
||||
if [ -f $1 ]; then
|
||||
sudo smart install -y `cat $1`
|
||||
else
|
||||
sudo smart install -y $*
|
||||
fi
|
||||
check_ldconfig
|
||||
;;
|
||||
restore)
|
||||
echo "not yet implemented, sorry" >&2
|
||||
;;
|
||||
checklog)
|
||||
line=`jannet info | tr -s " "`
|
||||
echo $line
|
||||
;;
|
||||
info)
|
||||
if [ "$opt_verbose" = true ]; then
|
||||
list_all_packages | xargs rpm -qi
|
||||
else
|
||||
list_all_packages | xargs rpm -q
|
||||
fi
|
||||
;;
|
||||
rpmnew)
|
||||
cmd_rpmnew $@
|
||||
;;
|
||||
diff)
|
||||
cmd_diff $@
|
||||
;;
|
||||
build-date)
|
||||
cmd_build_date
|
||||
;;
|
||||
built-today)
|
||||
cmd_built_today
|
||||
;;
|
||||
help)
|
||||
usage 0
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
|
||||
2096
scripts/jcs
2096
scripts/jcs
File diff suppressed because it is too large
Load diff
|
|
@ -1,197 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
log()
|
||||
{
|
||||
echo $@
|
||||
}
|
||||
|
||||
err()
|
||||
{
|
||||
log $@
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
err $@
|
||||
exit 1
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "$myname [-h] [-s summary] [-d description] [-g pkg-group] name"
|
||||
[ "$1" ] && exit $1
|
||||
}
|
||||
|
||||
cat_Makefile()
|
||||
{
|
||||
cat <<-EOT
|
||||
TOPDIR = .
|
||||
|
||||
include \$(TOPDIR)/make/proj.mk
|
||||
include \$(JWBDIR)/make/topdir.mk
|
||||
EOT
|
||||
}
|
||||
|
||||
cat_VERSION()
|
||||
{
|
||||
cat <<-EOT
|
||||
1.0.0-0-dev
|
||||
EOT
|
||||
}
|
||||
|
||||
cat_make_Makefile()
|
||||
{
|
||||
cat <<-EOT
|
||||
TOPDIR = ..
|
||||
|
||||
include \$(TOPDIR)/make/proj.mk
|
||||
include \$(JWBDIR)/make/make.mk
|
||||
EOT
|
||||
}
|
||||
|
||||
cat_make_proj_mk()
|
||||
{
|
||||
cat <<-EOT
|
||||
# to be included from inside the project directory
|
||||
|
||||
DEV_PROJECTS_DIR ?= \$(TOPDIR)/..
|
||||
ifeq (\$(TARGET),mingw)
|
||||
FLAVOUR_PATH_PREFIX = win32/
|
||||
endif
|
||||
JWBDIR ?= \$(firstword \$(wildcard \$(DEV_PROJECTS_DIR)/jw-build \$(BUILD_TOOLS_PREFIX)/opt/\$(FLAVOUR_PATH_PREFIX)jw-build))
|
||||
|
||||
USE_PROJECT_LIB = false
|
||||
HDRDIR_SCOPE_SUFFIX = \$(PROJECT)
|
||||
EOT
|
||||
}
|
||||
|
||||
cat_make_project_conf()
|
||||
{
|
||||
local login=$JANWARE_USER
|
||||
[ "$login" ] || login=`whoami`
|
||||
|
||||
local fullname=`getent passwd $login | cut -d: -f5`
|
||||
[ "$fullname" ] || fullname=$JANWARE_USER
|
||||
[ "$fullname" ] || fullname=`whoami | xargs getent passwd | cut -d: -f5`
|
||||
[ "$fullname" ] || fullname=`whoami`
|
||||
|
||||
cat <<-EOT
|
||||
[summary]
|
||||
$summary
|
||||
|
||||
[description]
|
||||
$description
|
||||
|
||||
[global]
|
||||
group = "$pkg_group"
|
||||
subpackages = $subpackages
|
||||
license = Copyright (c) $fullname, all rights reserved
|
||||
jw-maintainer = $JANWARE_USER
|
||||
|
||||
[build]
|
||||
libname = none
|
||||
|
||||
[pkg.requires.jw]
|
||||
devel = $name-run = VERSION-REVISION, jw-build-devel = VERSION
|
||||
build = jw-build-devel
|
||||
EOT
|
||||
}
|
||||
|
||||
cat_gitignore()
|
||||
{
|
||||
cat <<-EOT
|
||||
*.done
|
||||
*.dist
|
||||
*.dep.mk
|
||||
.cache.mk
|
||||
*.o
|
||||
*.so.*
|
||||
*.so
|
||||
*.a
|
||||
*.rep
|
||||
ld-*.conf
|
||||
*.ldscript
|
||||
*.pc
|
||||
$name
|
||||
*_generated_*
|
||||
*.secret
|
||||
local.mk
|
||||
.gdb_history
|
||||
dist
|
||||
mkspec.sh
|
||||
*.out
|
||||
*.orig
|
||||
*.old
|
||||
.feedfs_history
|
||||
.exrc
|
||||
*.swp
|
||||
*tmp*
|
||||
__init__.py
|
||||
__pycache__
|
||||
EOT
|
||||
}
|
||||
|
||||
# ---------------------- here we go
|
||||
|
||||
myname=`basename $0`
|
||||
projdir=.
|
||||
|
||||
summary=
|
||||
description=
|
||||
subpackages="run"
|
||||
|
||||
eval set -- `getopt -- hd:s:p:g: "$@"`
|
||||
|
||||
while [ "$1" != -- ]; do
|
||||
case $1 in
|
||||
-d)
|
||||
eval description=\"$2\"
|
||||
shift;;
|
||||
-s)
|
||||
eval summary=\"$2\"
|
||||
shift;;
|
||||
-p)
|
||||
eval subpackages=\"$2\"
|
||||
shift;;
|
||||
-g)
|
||||
eval pkg_group=\"$2\"
|
||||
shift;;
|
||||
-h)
|
||||
usage 0;;
|
||||
*)
|
||||
usage 1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
[ -z "$description" ] && description="$summary"
|
||||
[ -z "$summary" ] && summary="$description"
|
||||
[ -z "$pkg_group" ] && pkg_group="Amusements/Teaching/Other"
|
||||
|
||||
[ -f $projdir/Makefile ] || {
|
||||
fatal "$projdir doesn't contain a Makefile"
|
||||
}
|
||||
|
||||
name="$1"
|
||||
|
||||
[ -d $projdir/$name ] && {
|
||||
fatal "$projdir/$name already exists"
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
mkdir -p $projdir
|
||||
mkdir $name
|
||||
cd $projdir/$name
|
||||
|
||||
mkdir make
|
||||
cat_Makefile > Makefile
|
||||
cat_make_Makefile > make/Makefile
|
||||
cat_VERSION > VERSION
|
||||
cat_make_proj_mk > make/proj.mk
|
||||
cat_make_project_conf > make/project.conf
|
||||
cat_gitignore > .gitignore
|
||||
|
||||
log Successfully created project template \"$name\".
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
/usr/bin/ssh $JW_BUILD_SSH_EXTRA_OPTS "$@"
|
||||
|
||||
503
scripts/jw-pkg
503
scripts/jw-pkg
|
|
@ -1,503 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
log()
|
||||
{
|
||||
if [ "$1" = -n ]; then
|
||||
shift
|
||||
echo -n "$myname: $*"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$1" = -c ]; then
|
||||
shift
|
||||
echo "$*"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$1" = -C ]; then
|
||||
shift
|
||||
echo -n "$*"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "$myname: $*"
|
||||
}
|
||||
|
||||
channel_present()
|
||||
{
|
||||
if smart channel --show $1 2>&1 | grep -q baseurl >/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOT
|
||||
|
||||
$myname [global options] command [options] [package ...]
|
||||
|
||||
command is one of
|
||||
|
||||
help: show this help screen
|
||||
init: initialize
|
||||
uninit: undo initialization
|
||||
install: install packages in [arguments]
|
||||
update: update all jannet software on the system
|
||||
restore: restore a previous jannet software version state
|
||||
list: query information about installed software packages
|
||||
list-projects: query information about installed software projects
|
||||
checklog: update the installation log file if necessary
|
||||
rpmnew: remove superfluous rpmnew files and show conflicts
|
||||
for others
|
||||
build-date: show installed janware packages along with build date
|
||||
built-today: show installed janware packages built today
|
||||
|
||||
list-changed-files: list files changed since installation
|
||||
|
||||
list-templates: list templates
|
||||
list-template-tables: list templates tables
|
||||
list-template-output: list template output files
|
||||
rm-template-output: remove template output files
|
||||
compile-templates: compile templates
|
||||
|
||||
global options are
|
||||
|
||||
-v be verbose
|
||||
|
||||
package
|
||||
|
||||
optional whitespace-separated list of package names, generally limiting the
|
||||
scope of the command to the specified packages, defaults to all installed
|
||||
janware packages
|
||||
|
||||
EOT
|
||||
[ "$1" ] && exit $1
|
||||
}
|
||||
|
||||
create_ldconfig_state()
|
||||
{
|
||||
echo "=== automatically created by $myname update script"
|
||||
echo "--- files"
|
||||
ls /etc/ld.so.conf.d
|
||||
echo "--- directories"
|
||||
find /etc/ld.so.conf.d -type f | xargs cat | sort -u
|
||||
}
|
||||
|
||||
check_ldconfig()
|
||||
{
|
||||
local state=/var/log/jw-build-ldconf.state
|
||||
[ -f $state ] && create_ldconfig_state | diff $state - >/dev/null 2>&1 && return
|
||||
echo -n "running ldconfig ... "
|
||||
/sbin/ldconfig
|
||||
create_ldconfig_state > $state
|
||||
echo "done."
|
||||
}
|
||||
|
||||
list_packages()
|
||||
{
|
||||
local query_tags=""
|
||||
|
||||
eval set -- `getopt -- VPNUD "$@"`
|
||||
while [ "$1" != -- ]; do
|
||||
case $1 in
|
||||
-V)
|
||||
query_tags="$query_tags %{Vendor}"
|
||||
;;
|
||||
-P)
|
||||
query_tags="$query_tags %{Packager}"
|
||||
;;
|
||||
-U)
|
||||
query_tags="$query_tags %{URL}"
|
||||
;;
|
||||
-D)
|
||||
query_tags="$query_tags %{Distribution}"
|
||||
;;
|
||||
*)
|
||||
echo -e "Unexpected argument >$1<\n" >&2
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
[ "$query_tags" ] || query_tags="%{URL}"
|
||||
|
||||
local names="$1"
|
||||
local rpm_args
|
||||
if [ -n "$names" ]; then
|
||||
rpm_args="$rpm_args $names"
|
||||
else
|
||||
rpm_args="$rpm_args -a"
|
||||
fi
|
||||
rpm -q --queryformat "%{Name}: $query_tags\n" $rpm_args | \
|
||||
grep -i '^[^ ]\+:.*\(jannet\|janware\)' | \
|
||||
sed 's/\(^[^ ]\+\) *:.*/\1/; s/[ ]*$//' |\
|
||||
sort -u
|
||||
}
|
||||
|
||||
list_projects()
|
||||
{
|
||||
list_packages "$@" | xargs -r rpm -q --queryformat '%{SOURCERPM}\n' | \
|
||||
sed 's/[ ]*//; s/-[0-9]\+.*//' |\
|
||||
sort -u
|
||||
}
|
||||
|
||||
list_files()
|
||||
{
|
||||
# Need to sort -u, because apparently, during installation, rpm -ql
|
||||
# returns every file in the package _twice_. Funny.
|
||||
list_packages "$@" | sort -u | xargs -r rpm -ql
|
||||
}
|
||||
|
||||
cmd_rpmnew()
|
||||
{
|
||||
local file
|
||||
|
||||
list_files "$@" |
|
||||
while read file; do
|
||||
if [ -e "$file.rpmnew" ]; then
|
||||
if diff -q $file $file.rpmnew; then
|
||||
if [ -L "$file" ]; then
|
||||
echo ========== skipping link $file
|
||||
diff $file.rpmnew $file
|
||||
continue
|
||||
fi
|
||||
echo mv $file.rpmnew $file
|
||||
sudo mv $file.rpmnew $file
|
||||
else
|
||||
echo =========== $file
|
||||
diff $file.rpmnew $file
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
cmd_diff()
|
||||
{
|
||||
local file
|
||||
|
||||
list_packages "$@" |
|
||||
xargs -r rpm -qV |
|
||||
sed '/^....L\|^..5/ !d; s%[^/]*/%/%' |
|
||||
while read file; do
|
||||
if diff -q $file $file.rpmnew; then
|
||||
if [ -L "$file" ]; then
|
||||
echo ========== skipping link $file
|
||||
diff $file.rpmnew $file
|
||||
continue
|
||||
fi
|
||||
echo mv $file.rpmnew $file
|
||||
sudo mv $file.rpmnew $file
|
||||
else
|
||||
echo =========== $file
|
||||
diff $file.rpmnew $file
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
cmd_build_date()
|
||||
{
|
||||
list_packages "$@" |
|
||||
xargs -r rpm -q --queryformat '%{BUILDTIME} %{NAME}\n' |
|
||||
sort -n |
|
||||
sed 's/-run\|-devel//' |
|
||||
sort -u |
|
||||
while read t p; do
|
||||
echo `date --date=@$t --rfc-3339=seconds` $p
|
||||
done
|
||||
}
|
||||
|
||||
cmd_list_templates()
|
||||
{
|
||||
local ext_from="$template_exts" # TODO: support more than one
|
||||
local ext_from_re=`echo $ext_from | sed 's/\./\\./g'`
|
||||
local f
|
||||
|
||||
list_files "$@" | while read f; do
|
||||
[ -f "$f" -o -L "$f" ] || continue
|
||||
echo $f | grep -q "$ext_from_re$" || continue
|
||||
echo $f
|
||||
done
|
||||
}
|
||||
|
||||
cmd_list_template_tables()
|
||||
{
|
||||
local ext_from="$table_exts"
|
||||
local e f t
|
||||
list_files "$@" | while read f; do
|
||||
[ -f "$f" -o -L "$f" ] || continue
|
||||
for e in $ext_from; do
|
||||
t="${f%.*}$e"
|
||||
[ -f "$t" ] || continue
|
||||
echo $t
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
cmd_list_template_output()
|
||||
{
|
||||
local re=`echo $template_exts | sed 's/\./\\\\./g; s/^ *//; s/ *$//; s/ */$\\\\|/g; s/\(.*\)/\\\\(\1$\\\\)/'`
|
||||
local f
|
||||
list_files "$@" | sed "/$re/ !d; s/$re//" | while read f; do
|
||||
[ -f "$f" -o -L "$f" ] || continue
|
||||
echo $f
|
||||
done
|
||||
}
|
||||
|
||||
cmd_rm_template_output()
|
||||
{
|
||||
local restore=0
|
||||
while [ "${1:0:1}" = '-' ]; do
|
||||
case "$1" in
|
||||
-r)
|
||||
restore=1
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
local f
|
||||
cmd_list_template_output $@ | while read f; do
|
||||
log "removing $f"
|
||||
rm $f
|
||||
bak=$f$template_bak_ext
|
||||
if [ "$restore" = 1 -a -f "$bak" ]; then
|
||||
log "restoring $f from $bak"
|
||||
mv $bak $f
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
cmd_compile_templates()
|
||||
{
|
||||
__md() {
|
||||
stat --format '%U:%G %a' "$1" 2>/dev/null
|
||||
}
|
||||
|
||||
local ext_from="$template_exts" # TODO: support more than one
|
||||
local ext_from_re=`echo $template_exts | sed 's/\./\\./g'`
|
||||
local ext_to=""
|
||||
local ext_tables="$table_exts"
|
||||
local default_group=root
|
||||
local default_owner=root
|
||||
local default_mode=600
|
||||
local conf_patt="^[ ]*# *conf:"
|
||||
local missing_table=0
|
||||
local backup=0
|
||||
|
||||
umask 0077
|
||||
|
||||
while [ "${1:0:1}" = '-' ]; do
|
||||
case "$1" in
|
||||
-o)
|
||||
default_owner="$2"
|
||||
shift
|
||||
;;
|
||||
-m)
|
||||
default_mode="$2"
|
||||
shift
|
||||
;;
|
||||
-g)
|
||||
default_group="$2"
|
||||
shift
|
||||
;;
|
||||
-b)
|
||||
backup=1
|
||||
;;
|
||||
-c)
|
||||
conf_patt="$2"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
local f
|
||||
while read f; do
|
||||
local base=`echo $f | sed "s/$ext_from_re$//"`
|
||||
[ "$base" ] || continue
|
||||
local to=$base$ext_to
|
||||
local table=""
|
||||
local ext
|
||||
for ext in $ext_tables; do
|
||||
table=$base$ext
|
||||
[ -f "$table" ] && break
|
||||
done
|
||||
[ -f $table ] || {
|
||||
log "WARNING: No key-value table found for template $f, not compiling." >&2
|
||||
((missing_table++))
|
||||
continue
|
||||
}
|
||||
# TODO: use mktemp -d and keep temporary files in read-only dir
|
||||
local tmp=$to.tmp
|
||||
log -n "Applying macros in $table to $f"
|
||||
local mode=$default_mode
|
||||
local owner=$default_owner
|
||||
local group=$default_group
|
||||
local diff=""
|
||||
eval `sed "/$conf_patt/ !d; s/$conf_patt//" $f`
|
||||
eval `sed "/$conf_patt/ !d; s/$conf_patt//" $table`
|
||||
sed 's|^[ ]*#.*||; s|/|\\/|g; s|\([^ =]\+\)[ =]\+\(.*\)|s/\1/\2/g|' $table | sed -f - $f > $tmp
|
||||
chmod $mode $tmp
|
||||
chown $owner $tmp
|
||||
chgrp $group $tmp
|
||||
diff -q $tmp $to >/dev/null 2>&1 || diff="@content"
|
||||
local md_to=$(__md "$to")
|
||||
local md_tmp=$(__md "$tmp")
|
||||
[ "$md_to" = "$md_tmp" ] || diff="$diff@metadata ($md_to -> $md_tmp)"
|
||||
if [ -z "$diff" ]; then
|
||||
log -c ", no changes."
|
||||
rm $tmp
|
||||
continue
|
||||
fi
|
||||
local bak=$to$template_bak_ext
|
||||
if [ "$backup" = 1 -a -f $to ] && ! diff -q $to $bak >/dev/null 2>&1; then
|
||||
log -C ", saving backup to $to to $bak"
|
||||
cp -p $to $bak
|
||||
fi
|
||||
mv $tmp $to
|
||||
diff=${diff##@}
|
||||
log -c ", updating ${diff//@/ + }, done."
|
||||
done <<< $(cmd_list_templates "$@")
|
||||
|
||||
if [ "$missing_table" != 0 ]; then
|
||||
log "WARNING: $missing_table missing tables found. You might want to add them and run sudo $cmdline again."
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_get_value_from_tables()
|
||||
{
|
||||
local key show_file
|
||||
eval set -- `getopt -- k: "$@"`
|
||||
while [ "$1" != -- ]; do
|
||||
case $1 in
|
||||
-k)
|
||||
key=$2
|
||||
shift
|
||||
;;
|
||||
-f)
|
||||
show_file=1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo -e "Unexpected argument >$1<\n" >&2
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
local f
|
||||
while read f; do
|
||||
grep -q "^\s*$key\s\+" $f || continue
|
||||
[ "$show_file" = 1 ] && echo -n "$f: "
|
||||
sed "s|^[ ]*#.*||; /^\s*$key\(\s\|=\)\+/ !d; s/^\s*$key\(\s\|=\)\+//" $f
|
||||
done <<< $(cmd_list_template_tables "$@")
|
||||
}
|
||||
|
||||
cmd_built_today()
|
||||
{
|
||||
local today=`date +'%Y-%m-%d'`
|
||||
cmd_build_date | grep $today | cut -d' ' -f3
|
||||
}
|
||||
|
||||
cmd_list_changed_files()
|
||||
{
|
||||
list_projects "$@" | xargs rpm -qV | grep '^..5' | sed 's|[^/]*/|/|'
|
||||
}
|
||||
|
||||
# ----- here we go
|
||||
|
||||
cmdline="$0 $@"
|
||||
myname=`basename $0`
|
||||
longname=$0
|
||||
opts="v"
|
||||
table_exts=".jw-secret .jw-vars"
|
||||
template_exts=".jw-tmpl"
|
||||
template_bak_ext=".jw-pkg.bak"
|
||||
|
||||
while [ "${1:0:1}" = '-' ]; do
|
||||
case "$1" in
|
||||
-v)
|
||||
opt_verbose=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
cmd="${1//-/_}"
|
||||
shift
|
||||
|
||||
case $cmd in
|
||||
|
||||
# -- TODO: re-implement this using pkg-manager.sh, or integrate with pkg-manager.sh
|
||||
#init)
|
||||
# if ! channel_present ftp.jannet.de; then
|
||||
# echo -n "adding installation source ... "
|
||||
# sudo smart channel -y --add ftp.jannet.de \
|
||||
# type=yast2 \
|
||||
# baseurl=ftp://dspadm:dspasswd@ftp.jannet.de/pub/packages/linux/suse/10.1 \
|
||||
# >/dev/null 2>&1
|
||||
# if channel_present; then echo done; else echo failed; fi
|
||||
# fi
|
||||
# ;;
|
||||
#
|
||||
#uninit)
|
||||
# if channel_present ftp.jannet.de; then
|
||||
# echo -n "removing installation source ... "
|
||||
# sudo smart channel -y --remove ftp.jannet.de >/dev/null 2>&1
|
||||
# echo done
|
||||
# fi
|
||||
# ;;
|
||||
#
|
||||
#update)
|
||||
# sudo smart update ftp.jannet.de
|
||||
# sudo smart upgrade -y
|
||||
# check_ldconfig
|
||||
# ;;
|
||||
#
|
||||
#install)
|
||||
# sudo smart update ftp.jannet.de
|
||||
# if [ -f $1 ]; then
|
||||
# sudo smart install -y `cat $1`
|
||||
# else
|
||||
# sudo smart install -y $*
|
||||
# fi
|
||||
# check_ldconfig
|
||||
# ;;
|
||||
#restore)
|
||||
# echo "not yet implemented, sorry" >&2
|
||||
# ;;
|
||||
list)
|
||||
if [ "$opt_verbose" = true ]; then
|
||||
list_packages "$@" | xargs -r rpm -qi
|
||||
else
|
||||
list_packages "$@" | xargs -r rpm -q
|
||||
fi
|
||||
;;
|
||||
list_projects)
|
||||
list_projects "$@"
|
||||
;;
|
||||
compile_templates|list_templates|list_template_tables|list_template_output|rm_template_output|diff|build_date|built_today|rpmnew|get_value_from_tables|list_changed_files)
|
||||
cmd_$cmd "$@"
|
||||
;;
|
||||
help)
|
||||
usage 0
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
ldflags="$@"
|
||||
for f in $ldflags; do
|
||||
echo checking $f
|
||||
if [ "${f:0:2}" = -l ]; then
|
||||
libs="$libs ${f:2}"
|
||||
fi
|
||||
done
|
||||
|
||||
echo libs=$libs
|
||||
path=$LD_LIBRARY_PATH
|
||||
path=${path//:/ }
|
||||
for l in $libs; do
|
||||
lp=
|
||||
for p in $path; do
|
||||
lpc=$p/lib$l.so
|
||||
if [ -r $lpc ]; then
|
||||
lp=$lpc
|
||||
break
|
||||
fi
|
||||
done
|
||||
[ -n "$lp" ] || {
|
||||
echo library $l not found in path, skipping
|
||||
continue
|
||||
}
|
||||
echo ==================================== $lp
|
||||
lddtree $lp
|
||||
done
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
#!/bin/sh
|
||||
########################################################################
|
||||
# #
|
||||
# generic utiltiy modules #
|
||||
# (c) 2001 jannet it services #
|
||||
# contact@jannet.de #
|
||||
# #
|
||||
# $Id$
|
||||
# #
|
||||
# This program is free software; permission to use, copy, modify, #
|
||||
# distribute, and sell this software and its documentation under the #
|
||||
# terms of the GNU Public license as published by the Free Software #
|
||||
# Foundation, either version 2 or any later version of the license, is #
|
||||
# hereby granted without fee, provided that (i) the above copyright #
|
||||
# notices and this permission notice appear in all copies of the #
|
||||
# software and related documentation, and (ii) the name of JanNet may #
|
||||
# not be used in any advertising or publicity relating to the software #
|
||||
# without the specific, prior written permission of JanNet. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but #
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- #
|
||||
# TABILITY 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 Founda- #
|
||||
# tion, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
|
||||
version_tag=$1
|
||||
|
||||
cat << EOT
|
||||
VERSION {
|
||||
$version_tag {
|
||||
global:
|
||||
*;
|
||||
};
|
||||
}
|
||||
EOT
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
usage()
|
||||
{
|
||||
echo usage: $MYNAME /path/to/mkspec.sh -h [-N name] [-T topdir] [-V version] [-S source] [-R requires] [-P project] >&2
|
||||
[ "$1" ] && exit $1
|
||||
}
|
||||
|
||||
append()
|
||||
{
|
||||
local var=$1
|
||||
shift
|
||||
local tmp=`eval echo \"\\$$var $@\" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//'`
|
||||
eval $var=\"$tmp\"
|
||||
}
|
||||
|
||||
# -- here we go
|
||||
|
||||
#set -x
|
||||
|
||||
MYNAME=`basename $0`
|
||||
ID=`whoami`
|
||||
[ ! "$INSTALL_LOG" ] && INSTALL_LOG=/tmp/rpmbuild-$ID/install.log
|
||||
|
||||
eval set -- `getopt -l "provides-run:" -l "provides-devel:" -o "P:T:V:S:N:hR:D:X:Y:d:" -- "$@"`
|
||||
|
||||
while [ "$1" != -- ]; do
|
||||
echo checking "$1=$2" >&2
|
||||
case $1 in
|
||||
-h)
|
||||
usage 0;;
|
||||
-T)
|
||||
TOPDIR="$2"
|
||||
shift;;
|
||||
-V)
|
||||
V="$2"
|
||||
shift;;
|
||||
-S)
|
||||
SOURCE="$2"
|
||||
shift;;
|
||||
-N)
|
||||
NAME="$2"
|
||||
shift;;
|
||||
-R)
|
||||
append REQUIRES_RUN "$2"
|
||||
shift
|
||||
;;
|
||||
-X)
|
||||
append CONFLICTS_RUN "$2"
|
||||
shift
|
||||
;;
|
||||
-D)
|
||||
append REQUIRES_DEVEL "$2"
|
||||
shift
|
||||
;;
|
||||
-Y)
|
||||
append CONFLICTS_DEVEL "$2"
|
||||
shift
|
||||
;;
|
||||
--provides-run)
|
||||
append PROVIDES_RUN "$2"
|
||||
shift
|
||||
;;
|
||||
--provides-devel)
|
||||
append PROVIDES_DEVEL "$2"
|
||||
shift
|
||||
;;
|
||||
-P)
|
||||
PROJECT="$2"
|
||||
shift;;
|
||||
-d)
|
||||
DISTRIBUTION="$2"
|
||||
shift;;
|
||||
*)
|
||||
usage 1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
MKSPEC_SH="$1"
|
||||
shift
|
||||
|
||||
[ -z "$TOPDIR" ] && TOPDIR=.
|
||||
|
||||
if [ -z "$V" ]; then
|
||||
if [ -f $TOPDIR/VERSION ]; then
|
||||
VERSION="`cat $TOPDIR/VERSION | cut -d- -f1`"
|
||||
RELEASE="`cat $TOPDIR/VERSION | cut -d- -f2- | sed 's/[-_].*//'`"
|
||||
else
|
||||
VERSION=noversion
|
||||
RELEASE=norelease
|
||||
fi
|
||||
else
|
||||
VERSION="`echo $V | cut -d- -f1`"
|
||||
RELEASE="`cat $TOPDIR/VERSION | cut -d- -f2- | sed 's/[-_].*//'`"
|
||||
fi
|
||||
|
||||
if [ -z "$NAME" ]; then
|
||||
NAME=`pwd | xargs basename`
|
||||
fi
|
||||
|
||||
REQUIRES="$REQUIRES_RUN $REQUIRES_DEVEL"
|
||||
CONFLICTS="$CONFLICTS_RUN $CONFLICTS_DEVEL"
|
||||
#if [ -n "$REQUIRES" ]; then
|
||||
# REQUIRES_RUN=`echo $REQUIRES |
|
||||
# sed -e '
|
||||
# s/\([a-zA-Z-]\+\) *\([<>=]*\) *\([a-zA-Z0-9\.-]*\)/\1-run \2 \3,/g
|
||||
# s/,$//
|
||||
# s/-run-run/-run/
|
||||
# '`
|
||||
# REQUIRES_DEVEL="$REQUIRES_RUN, $NAME-run = $VERSION-$RELEASE, `echo $REQUIRES_RUN | sed -e 's/-run/-devel/g'`"
|
||||
#fi
|
||||
|
||||
#echo "REQUIRES_RUN=\"$REQUIRES_RUN\""
|
||||
#exit
|
||||
|
||||
export \
|
||||
REQUIRES REQUIRES_RUN REQUIRES_DEVEL \
|
||||
CONFLICTS CONFLICTS_RUN CONFLICTS_DEVEL \
|
||||
PROVIDES PROVIDES_RUN PROVIDES_DEVEL \
|
||||
TOPDIR \
|
||||
PROJECT NAME \
|
||||
SOURCE \
|
||||
VERSION RELEASE V \
|
||||
INSTALL_LOG \
|
||||
DISTRIBUTION
|
||||
|
||||
bash $MKSPEC_SH
|
||||
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
#! /usr/bin/awk -f
|
||||
# A script to extract the actual suppression info from the output of (for example) valgrind --leak-check=full --show-reachable=yes --error-limit=no --gen-suppressions=all ./minimal
|
||||
# The desired bits are between ^{ and ^} (including the braces themselves).
|
||||
# The combined output should either be appended to /usr/lib/valgrind/default.supp, or placed in a .supp of its own
|
||||
# If the latter, either tell valgrind about it each time with --suppressions=<filename>, or add that line to ~/.valgrindrc
|
||||
|
||||
# NB This script uses the |& operator, which I believe is gawk-specific. In case of failure, check that you're using gawk rather than some other awk
|
||||
|
||||
# The script looks for suppressions. When it finds one it stores it temporarily in an array,
|
||||
# and also feeds it line by line to the external app 'md5sum' which generates a unique checksum for it.
|
||||
# The checksum is used as an index in a different array. If an item with that index already exists the suppression must be a duplicate and is discarded.
|
||||
|
||||
BEGIN { suppression=0; md5sum = "md5sum" }
|
||||
# If the line begins with '{', it's the start of a supression; so set the var and initialise things
|
||||
/^{/ {
|
||||
suppression=1; i=0; next
|
||||
}
|
||||
# If the line begins with '}' its the end of a suppression
|
||||
/^}/ {
|
||||
if (suppression)
|
||||
{ suppression=0;
|
||||
close(md5sum, "to") # We've finished sending data to md5sum, so close that part of the pipe
|
||||
ProcessInput() # Do the slightly-complicated stuff in functions
|
||||
delete supparray # We don't want subsequent suppressions to append to it!
|
||||
}
|
||||
}
|
||||
# Otherwise, it's a normal line. If we're inside a supression, store it, and pipe it to md5sum. Otherwise it's cruft, so ignore it
|
||||
{ if (suppression)
|
||||
{
|
||||
supparray[++i] = $0
|
||||
print |& md5sum
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ProcessInput()
|
||||
{
|
||||
# Pipe the result from md5sum, then close it
|
||||
md5sum |& getline result
|
||||
close(md5sum)
|
||||
# gawk can't cope with enormous ints like $result would be, so stringify it first by prefixing a definite string
|
||||
resultstring = "prefix"result
|
||||
|
||||
if (! (resultstring in chksum_array) )
|
||||
{ chksum_array[resultstring] = 0; # This checksum hasn't been seen before, so add it to the array
|
||||
OutputSuppression() # and output the contents of the suppression
|
||||
}
|
||||
}
|
||||
|
||||
function OutputSuppression()
|
||||
{
|
||||
# A suppression is surrounded by '{' and '}'. Its data was stored line by line in the array
|
||||
print "{"
|
||||
for (n=1; n <= i; ++n)
|
||||
{ print supparray[n] }
|
||||
print "}"
|
||||
}
|
||||
202
scripts/pgit.sh
202
scripts/pgit.sh
|
|
@ -1,202 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
log()
|
||||
{
|
||||
echo $@
|
||||
}
|
||||
|
||||
err()
|
||||
{
|
||||
log $@
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
err $@
|
||||
exit 1
|
||||
}
|
||||
|
||||
marker()
|
||||
{
|
||||
log "# ------------- [$cur/$n_projects] $@"
|
||||
}
|
||||
|
||||
fat_marker()
|
||||
{
|
||||
log "# ==================================================== [$cur/$n_projects] $@"
|
||||
}
|
||||
|
||||
config()
|
||||
{
|
||||
[ "$pdir" ] || {
|
||||
# guess pdir
|
||||
pdir=`pwd`
|
||||
while [ `cat $pdir/CVS/Repository 2>/dev/null` != proj ]; do
|
||||
[ "$pdir" = / ] && fatal "didn't find \"proj\" in directory components"
|
||||
pdir=`dirname $pdir`
|
||||
done
|
||||
}
|
||||
|
||||
[ "$pdirs" ] || {
|
||||
pdirs=`(cd $pdir; ls -d */.git 2>/dev/null | sed 's%/.git%%')`
|
||||
}
|
||||
n_projects=`echo $pdirs | wc -w`
|
||||
}
|
||||
|
||||
run_git()
|
||||
{
|
||||
marker git "$@"
|
||||
# sadly, CentOS 7 has git 1.8.3.1, which doesn't support -C
|
||||
if [ "$1" = -C ]; then
|
||||
(
|
||||
cd $2
|
||||
shift 2
|
||||
git "$@"
|
||||
)
|
||||
return $?
|
||||
fi
|
||||
git "$@"
|
||||
}
|
||||
|
||||
# ------------- commands
|
||||
run()
|
||||
{(
|
||||
local cmd=$1
|
||||
local d
|
||||
|
||||
shift
|
||||
config
|
||||
cd $pdir
|
||||
|
||||
if [ "$PGIT_KEEP_GOING" != y ]; then set -e; fi
|
||||
for d in $pdirs; do
|
||||
cur=`expr $cur + 1`
|
||||
run_git -C $d $cmd "$@"
|
||||
done
|
||||
)}
|
||||
|
||||
commit()
|
||||
{(
|
||||
local d do_cvs
|
||||
|
||||
if [ "$1" = --cvs ]; then
|
||||
do_cvs=true
|
||||
shift
|
||||
fi
|
||||
|
||||
config
|
||||
cd $pdir
|
||||
|
||||
if [ "$PGIT_KEEP_GOING" != y ]; then set -e; fi
|
||||
for d in $pdirs; do
|
||||
cur=`expr $cur + 1`
|
||||
if run_git -C $d diff-index --quiet HEAD --; then
|
||||
log "Nothing to commit"
|
||||
continue
|
||||
fi
|
||||
run_git -C $d commit "$@"
|
||||
done
|
||||
|
||||
if [ "$do_cvs" = true -a -d CVS ]; then
|
||||
cvs commit "$@"
|
||||
fi
|
||||
)}
|
||||
|
||||
clone()
|
||||
{(
|
||||
local p
|
||||
config
|
||||
cd $pdir
|
||||
local refspec=(${PGIT_CLONE_FROM_USER//:/ })
|
||||
local fromuser=${refspec[0]}
|
||||
local fromref=${refspec[1]}
|
||||
local toref=${refspec[2]}
|
||||
local login=$JANWARE_USER
|
||||
local projects="$PGIT_CLONE_PROJECTS"
|
||||
local ignore="$PGIT_IGNORE"
|
||||
[ "$login" ] || login=`whoami`
|
||||
[ "$fromuser" ] || fromuser=`whoami`
|
||||
[ "$fromref" ] || fromref=master
|
||||
local git_srv_admin="$SSH $login@git.janware.com /opt/jw-build/bin/git-srv-admin.sh"
|
||||
if [ -z "$projects" ]; then
|
||||
projects=`$git_srv_admin -u $fromuser -j list-personal-projects`
|
||||
[ "$?" != 0 ] && exit 1
|
||||
fi
|
||||
n_projects=`echo $projects | wc -w`
|
||||
if [ "$PGIT_KEEP_GOING" != y ]; then set -e; fi
|
||||
for p in $projects; do
|
||||
if echo $ignore | grep -q "\b$p\b"; then
|
||||
continue
|
||||
fi
|
||||
cur=`expr $cur + 1`
|
||||
local pullurl=ssh://$login@git.janware.com/srv/git/$fromuser/proj/$p
|
||||
local pushurl=ssh://$login@git.janware.com/srv/git/$login/proj/$p
|
||||
local curref=""
|
||||
fat_marker "Fetching project $p from user $fromuser"
|
||||
if [ "$fromuser" = "$login" ]; then
|
||||
if [ -d $p ]; then
|
||||
run_git -C $p pull --recurse-submodules=on-demand
|
||||
else
|
||||
run_git clone ssh://$login@git.janware.com/srv/git/$fromuser/proj/$p
|
||||
fi
|
||||
else
|
||||
local remotename="jw-$fromuser"
|
||||
if [ -d $p ]; then
|
||||
run_git -C $p remote | grep -q "^$remotename$" || {
|
||||
run_git -C $p remote add $remotename $pullurl
|
||||
run_git -C $p remote set-url --push $remotename no_push
|
||||
}
|
||||
run_git -C $p fetch --prune --recurse-submodules=on-demand $remotename $fromref
|
||||
if [ "$toref" ]; then
|
||||
curref=`git -C $p branch --show-current`
|
||||
if [ "$curref" = "$toref" ]; then
|
||||
run_git -C $p pull --recurse-submodules=on-demand $remotename $fromref
|
||||
else
|
||||
run_git -C $p fetch --recurse-submodules=on-demand $remotename $fromref:$toref
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# set -x
|
||||
run_git clone ssh://$login@git.janware.com/srv/git/$fromuser/proj/$p
|
||||
run_git -C $p remote rename origin $remotename || fatal failed to rename remote in $p
|
||||
run_git -C $p remote set-url --push $remotename no_push
|
||||
$git_srv_admin -u $login -j create-personal-project $p
|
||||
run_git -C $p remote add origin $pushurl
|
||||
run_git -C $p push --recurse-submodules=on-demand origin master
|
||||
$git_srv_admin -u $login -j update-descriptions $p
|
||||
run_git -C $p branch --set-upstream-to origin/master master
|
||||
# set +x
|
||||
fi
|
||||
fi
|
||||
run_git -C $p submodule update --init --recursive || fatal git submodule update failed in $p
|
||||
done
|
||||
)}
|
||||
|
||||
diff()
|
||||
{(
|
||||
local d
|
||||
config
|
||||
cd $pdir
|
||||
for d in $pdirs; do
|
||||
cur=`expr $cur + 1`
|
||||
# marker $d
|
||||
run_git -C $d diff --src-prefix=$d/ --dst-prefix=$d/ "$@"
|
||||
done
|
||||
)}
|
||||
|
||||
echo "running $0 $@ GIT_SSH=$GIT_SSH" >&2
|
||||
|
||||
SSH=ssh
|
||||
[ "$GIT_SSH" ] && SSH=$GIT_SSH
|
||||
|
||||
cmd=$1
|
||||
cur=0
|
||||
shift
|
||||
case $cmd in
|
||||
clone|diff|commit)
|
||||
$cmd "$@"
|
||||
;;
|
||||
*)
|
||||
run $cmd "$@"
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
log()
|
||||
{
|
||||
echo $@ >&2
|
||||
}
|
||||
|
||||
err()
|
||||
{
|
||||
echo $@ >&2
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
err "Giving up: $@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
cat<<-EOT
|
||||
$myname cmd args
|
||||
EOT
|
||||
}
|
||||
|
||||
run()
|
||||
{
|
||||
log "Running ==== $@"
|
||||
"$@"
|
||||
}
|
||||
|
||||
cmd_install()
|
||||
{
|
||||
local env opts global_opts
|
||||
local non_interactive
|
||||
|
||||
set -- `getopt 'y' $*`
|
||||
while [ "$1" != -- ] ; do
|
||||
case "$1" in
|
||||
-y)
|
||||
non_interactive=1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
case $ID in
|
||||
opensuse|suse)
|
||||
[ "$non_interactive" = 1 ] && {
|
||||
opts="--force-resolution --auto-agree-with-licenses"
|
||||
global_opts="$global_opts --non-interactive --gpg-auto-import-keys --no-gpg-checks"
|
||||
}
|
||||
run sudo $env -S zypper $global_opts install $opts "$@"
|
||||
;;
|
||||
debian|ubuntu|raspbian)
|
||||
[ "$non_interactive" = 1 ] && {
|
||||
global_opts="$global_opts -yq"
|
||||
env="$env DEBIAN_FRONTEND=noninteractive"
|
||||
}
|
||||
run sudo $env -S apt-get $global_opts install "$@"
|
||||
;;
|
||||
arch)
|
||||
[ "$non_interactive" = 1 ] && {
|
||||
global_opts="$global_opts --noconfirm"
|
||||
env="$env DEBIAN_FRONTEND=noninteractive"
|
||||
}
|
||||
run sudo $env -S pacman $global_opts -S --needed "$@"
|
||||
;;
|
||||
centos)
|
||||
run sudo $env -S yum $global_opts install -y "$@"
|
||||
;;
|
||||
*)
|
||||
fatal "Tried to install on unsupported platform \"$ID\""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cmd_refresh()
|
||||
{
|
||||
local env opts global_opts
|
||||
local non_interactive
|
||||
|
||||
set -- `getopt 'y' $*`
|
||||
while [ "$1" != -- ] ; do
|
||||
case "$1" in
|
||||
-y)
|
||||
non_interactive=1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
case $ID in
|
||||
opensuse|suse)
|
||||
[ "$non_interactive" = 1 ] && {
|
||||
global_opts="$global_opts --non-interactive --gpg-auto-import-keys --no-gpg-checks"
|
||||
}
|
||||
run sudo $env -S zypper $global_opts refresh $opts "$@"
|
||||
;;
|
||||
debian|ubuntu|raspbian)
|
||||
run sudo $env -S apt-get $global_opts update "$@"
|
||||
;;
|
||||
centos)
|
||||
run sudo $env -S yum $global_opts clean expire-cache "$@"
|
||||
run sudo $env -S yum $global_opts makecache "$@"
|
||||
;;
|
||||
*)
|
||||
fatal "Tried to update unsupported platform \"$ID\""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# -- here we go
|
||||
myname=`basename $0`
|
||||
. /etc/os-release
|
||||
ID=${ID%%-*}
|
||||
cmd="$1"
|
||||
shift
|
||||
cmd_$cmd "$@"
|
||||
1237
scripts/pkg.sh
1237
scripts/pkg.sh
File diff suppressed because it is too large
Load diff
|
|
@ -1,114 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
log()
|
||||
{
|
||||
echo $@
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
log $@
|
||||
exit 1
|
||||
}
|
||||
|
||||
goodbye()
|
||||
{
|
||||
rm -f $scm_status
|
||||
}
|
||||
|
||||
check_scm()
|
||||
{
|
||||
local p=$1
|
||||
if [ -d $p/.git ]; then
|
||||
log + checking git
|
||||
#git -C $p pull --no-edit || fatal "git pull failed, giving up"
|
||||
if git -C $p status --porcelain --untracked-files=no | grep -v '^??' | grep -q . ; then
|
||||
git -C $p status
|
||||
fatal "git in project \"$p\" has locally modified files, giving up"
|
||||
fi
|
||||
else
|
||||
log + checking cvs
|
||||
#cvs update -dP $p
|
||||
cvs status $p > $scm_status 2>&1
|
||||
if [ $? != 0 ]; then
|
||||
cat $scm_status
|
||||
fatal "\n======== cvs status failed in project \"$p\", giving up."
|
||||
fi
|
||||
grep -qi "locally modified" $scm_status && \
|
||||
fatal "cvs copy in project \"$p\" has locally modified files, giving up"
|
||||
grep -qi "needs" $scm_status && \
|
||||
fatal "+ cvs copy in project \"$p\" is out-of-date, giving up"
|
||||
fi
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
ssh=ssh
|
||||
[ "$CVS_RSH" ] && ssh="$CVS_RSH"
|
||||
[ "$GIT_SSH" ] && ssh="$GIT_SSH"
|
||||
ssh=`which $ssh`
|
||||
[ -x "$ssh" ] || fatal "SSH executable \"$ssh\" not found"
|
||||
[ "$JANWARE_USER" ] || JANWARE_USER=`whoami`
|
||||
ssh="$ssh -l $JANWARE_USER"
|
||||
|
||||
for host in cvs.janware.com git.janware.com; do
|
||||
$ssh $host echo hallo >/dev/null 2>&1 || fatal "Can't ssh into host $host"
|
||||
done
|
||||
|
||||
local_cvs_proj=`ls -d */CVS 2>/dev/null | sed 's%/[^/]*%%'`
|
||||
local_git_proj=`ls -d */.git 2>/dev/null | sed 's%/[^/]*%%'`
|
||||
remote_cvs_proj=`$ssh cvs.janware.com find /srv/cvs/proj -maxdepth 1 -mindepth 1 -type d -executable -readable | sed 's%.*/%%'`
|
||||
remote_git_proj=`$ssh git.janware.com git-srv-admin.sh -j list-personal-projects`
|
||||
|
||||
date=`date +'%Y%m%d'`
|
||||
myname=`basename $0`
|
||||
|
||||
trap goodbye EXIT INT QUIT KILL
|
||||
scm_status=`mktemp /tmp/$myname""_XXXXXX`
|
||||
|
||||
for p in $local_cvs_proj; do
|
||||
[ -L $p ] && continue
|
||||
[ -d $p ] || continue
|
||||
echo $remote_cvs_proj | grep -q "\(^\| \)$p\($\| \)" && continue
|
||||
n=purged/cvs/$date/$p
|
||||
mkdir -p `dirname $n`
|
||||
echo "--------------- moving stale cvs project $p to $n"
|
||||
if ! make -C $p distclean; then echo "distclean failed, ignoring"; fi
|
||||
if ! make -C $p clean; then echo "clean failed, ignoring"; fi
|
||||
mv $p $n
|
||||
sed -i "/\/$p\// d" CVS/Entries
|
||||
purged="$purged $p"
|
||||
done
|
||||
|
||||
[ -d old ] && mv old purged
|
||||
|
||||
[ "$purged" ] && {
|
||||
cp -p CVS/Entries CVS/Entries-$date-`date +'%H%M%S'`
|
||||
}
|
||||
|
||||
for p in $purged; do
|
||||
sed -i "/D\/$p\/\/\/\// d" CVS/Entries
|
||||
done
|
||||
|
||||
if [ -d dspc/src/CVS ]; then
|
||||
for i in dspcd shared; do
|
||||
sed -i "/D\/$i\/\/\/\// d" dspc/src/CVS/Entries
|
||||
done
|
||||
fi
|
||||
|
||||
for i in dspider-btools dspider-shared; do
|
||||
[ -L "$i" ] && rm $i
|
||||
done
|
||||
|
||||
for p in $local_git_proj; do
|
||||
[ -L $p ] && continue
|
||||
[ -d $p ] || continue
|
||||
echo $remote_git_proj | grep -q "\(^\| \)$p\($\| \)" && continue
|
||||
check_scm $p
|
||||
echo done checking scm
|
||||
n=purged/git/$date/$p
|
||||
mkdir -p `dirname $n`
|
||||
mv $p $n
|
||||
log "moving stale project \"$p\" to \"$n\""
|
||||
done
|
||||
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<-EOT
|
||||
|
||||
usage $myname [-e sed-extract-command] [-m module] file.py ...
|
||||
|
||||
EOT
|
||||
[ "$1" ] && exit $1
|
||||
}
|
||||
|
||||
module_path()
|
||||
{
|
||||
if [ "$module" ]; then
|
||||
echo $module.$1
|
||||
return
|
||||
fi
|
||||
echo $1
|
||||
}
|
||||
|
||||
cmd_create_init()
|
||||
{
|
||||
local import_submodules=0
|
||||
local e f files base extracted module_path
|
||||
local del="-------------------------- generated by $myname"
|
||||
echo "# >> $del >>"
|
||||
echo "from pkgutil import extend_path"
|
||||
echo "from typing import Iterable"
|
||||
echo "__path__ = extend_path(__path__, __name__) # type: ignore" # was "type Iterable[str]"
|
||||
files="$*"
|
||||
for f in $files; do
|
||||
test -d $f && continue
|
||||
base=${f##*/}
|
||||
base=${base%.py}
|
||||
if [ "$sed_extract_command" ]; then
|
||||
#echo running $sed_extract_command on $f
|
||||
extracted=`sed "$sed_extract_command" $f`
|
||||
#extracted="$sed_extract_command"
|
||||
for e in $extracted; do
|
||||
echo "from `module_path $base` import $e"
|
||||
done
|
||||
fi
|
||||
done
|
||||
if [ "$import_submodules" = 1 ]; then
|
||||
for f in $files; do
|
||||
[ -f $f/__init__.py ] && echo "import `module_path $f` as $f"
|
||||
done
|
||||
fi
|
||||
echo "# << $del <<"
|
||||
}
|
||||
|
||||
# --------------------- here we go
|
||||
|
||||
myname=`basename $0`
|
||||
|
||||
eval set -- `getopt -o 'he:m:' "$@"`
|
||||
while [ "$1" != -- ]; do
|
||||
case $1 in
|
||||
-e)
|
||||
sed_extract_command="$2"
|
||||
shift
|
||||
;;
|
||||
-m)
|
||||
module=$2
|
||||
shift
|
||||
;;
|
||||
-h)
|
||||
usage 0;;
|
||||
*)
|
||||
echo unknown argument $1
|
||||
usage 1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
cmd=cmd_${1//-/_}
|
||||
shift
|
||||
|
||||
eval $cmd $*
|
||||
|
|
@ -1,223 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
goodbye()
|
||||
{
|
||||
:
|
||||
rm -rf $tmp_files
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOT >&2
|
||||
|
||||
$myname -h
|
||||
$myname {net|<image-file>} [-b hostname]
|
||||
|
||||
EOT
|
||||
[ "$1" ] && exit $1
|
||||
exit 0
|
||||
}
|
||||
|
||||
log()
|
||||
{
|
||||
echo "$log_delim $*"
|
||||
/usr/bin/logger -t "$myname" "$*"
|
||||
}
|
||||
|
||||
err()
|
||||
{
|
||||
echo "$log_delim $*" >&2
|
||||
/usr/bin/logger -t "$myname" "$*"
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
err "Fatal: $@ ... giving up"
|
||||
exit 1
|
||||
}
|
||||
|
||||
do_sudo()
|
||||
{
|
||||
if [ "$UID" = 0 ]; then
|
||||
while [[ $1 =~ ^- ]]; do shift; done
|
||||
log running $@
|
||||
eval "$@"
|
||||
return $?
|
||||
fi
|
||||
log running sudo $@
|
||||
#sudo -p "Password for $myname:" $@
|
||||
eval sudo "$@"
|
||||
return $?
|
||||
}
|
||||
|
||||
ldap_search()
|
||||
{
|
||||
local ldap_server=ldap.lcl
|
||||
local binddn=cn=ldapadm,dc=jannet,dc=de
|
||||
local password_files="$HOME/.feedfs-ldap/passwords/$binddn@$ldap_server $HOME/.ldap.secret"
|
||||
local p password_file
|
||||
for p in $password_files; do
|
||||
[ -r "$p" ] || continue
|
||||
password_file=$p
|
||||
break
|
||||
done
|
||||
[ "$password_file" ] || fatal "None of the LDAP password files $password_files exists"
|
||||
ldapsearch -y $password_file -xZ -h $ldap_server -D $binddn -b $base,ou=networks,dc=jannet,dc=de $@
|
||||
}
|
||||
|
||||
list_hostnames()
|
||||
{
|
||||
ldap_search -LLL "(objectClass=dhcpHost)" cn | sed '/cn: / !d; s/cn: //'
|
||||
}
|
||||
|
||||
boot_net()
|
||||
{
|
||||
local mac
|
||||
[ "$hostname" ] && {
|
||||
#set -x
|
||||
mac=`ldap_search -LLL "(cn=$short_hostname) dhcpHWAddress" |
|
||||
sed '/dhcpHWAddress:/ !d; s/dhcpHWAddress: ethernet *//'`
|
||||
macaddr=",macaddr=$mac"
|
||||
}
|
||||
|
||||
systemctl try-start dhcpd-priv.lcl
|
||||
systemctl try-start nfsserver
|
||||
|
||||
[ "$nic_model" ] || nic_model=",model=e1000"
|
||||
# need this for net access, would be nicer if it didn't run as root
|
||||
# -nographic
|
||||
|
||||
do_sudo -E /usr/bin/$qemu_exe \
|
||||
-boot n \
|
||||
-net tap,ifname=tap0,script=$tmpdir/qemu-ifup,downscript=$tmpdir/qemu-ifdown \
|
||||
-net nic$nic_model$macaddr \
|
||||
"$qemu_opts"
|
||||
|
||||
# invalid param macaddr
|
||||
# do_sudo -E /usr/bin/$qemu_exe \
|
||||
# -boot n \
|
||||
# -net bridge,br=$bridge,$nic_model,macaddr=$macaddr \
|
||||
# $qemu_opts
|
||||
|
||||
# access denied by ACL files
|
||||
# do_sudo -E /usr/bin/$qemu_exe \
|
||||
# -boot n \
|
||||
# -net bridge,br=$bridge,$nic_model \
|
||||
# $qemu_opts
|
||||
}
|
||||
|
||||
boot_image()
|
||||
{
|
||||
local boot_image="$1"
|
||||
|
||||
test -r "$boot_image" || fatal "inaccessible boot image \"$boot_image\""
|
||||
#-net bridge,br=$bridge \
|
||||
#-net nic,vlan=1$nic_model,macaddr=00:02:36:22:13:6c \
|
||||
#-net tap,ifname=tap1,vlan=1,script=$tmpdir/qemu-ifup,downscript=$tmpdir/qemu-ifdown \
|
||||
#set -x
|
||||
do_sudo -E /usr/bin/$qemu_exe \
|
||||
-net nic,$nic_model$macaddr \
|
||||
-net tap,ifname=tap0,vlan=0,script=$tmpdir/qemu-ifup,downscript=$tmpdir/qemu-ifdown \
|
||||
"$qemu_opts" \
|
||||
-drive file=$boot_image
|
||||
}
|
||||
|
||||
boot()
|
||||
{
|
||||
tmpdir=`mktemp -d /tmp/$myname-XXXXXX`
|
||||
ln -s $exe $tmpdir/qemu-ifup
|
||||
ln -s $exe $tmpdir/qemu-ifdown
|
||||
|
||||
#do_sudo /sbin/modprobe kvm-intel
|
||||
tmp_files="$tmp_files $tmpdir"
|
||||
xhost +
|
||||
|
||||
case $1 in
|
||||
net)
|
||||
shift
|
||||
boot_net "$@"
|
||||
;;
|
||||
*)
|
||||
boot_image "$@"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# -- here we go
|
||||
|
||||
myname=`basename $0`
|
||||
log_delim="==========================="
|
||||
log running $0 $@
|
||||
[ -x $0 ] || chmod u+x $0 || fatal "$0 is not executable"
|
||||
exe=`readlink -f $0`
|
||||
dirname=`dirname $exe`
|
||||
bridge=priv0
|
||||
bridge=pub0
|
||||
#bridge=enp0s31f6
|
||||
#bridge=in1
|
||||
macaddr=,macaddr=00:0B:DC:9B:D6:DA
|
||||
base=dc=priv,dc=lcl
|
||||
qemu_exe=qemu-kvm
|
||||
qemu_exe=qemu-system-x86_64
|
||||
qemu_opts=""
|
||||
ip=`PATH=/usr/sbin:/sbin:/usr/bin /usr/bin/which ip`
|
||||
#nic_model=",model=rtl8139"
|
||||
tmp_files=""
|
||||
tmpdir=""
|
||||
|
||||
trap goodbye INT QUIT EXIT KILL TERM PIPE
|
||||
|
||||
OPTIND=1
|
||||
while getopts lhb:o:x:n:B:M: flag; do
|
||||
case $flag in
|
||||
h)
|
||||
usage 0;;
|
||||
l)
|
||||
list_hostnames
|
||||
exit 0;;
|
||||
b)
|
||||
hostname="$OPTARG"
|
||||
short_hostname=`echo $hostname | sed 's/\..*//'`
|
||||
dns_domain=`echo $hostname | cut -d. -f2-`
|
||||
base=`echo $dns_domain | sed 's/\./,/g; s/\(^\|,\)/\1dc=/g'`
|
||||
;;
|
||||
x)
|
||||
qemu_exe="$OPTARG";;
|
||||
o)
|
||||
qemu_opts="$OPTARG";;
|
||||
n)
|
||||
nic_model=",model=$OPTARG";;
|
||||
B)
|
||||
bridge=$OPTARG;;
|
||||
M)
|
||||
macaddr=",macaddr=$OPTARG";;
|
||||
|
||||
*)
|
||||
usage 1;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
case $myname in
|
||||
*ifup*)
|
||||
virt_if=$1
|
||||
touch /tmp/i-ran-$myname
|
||||
do_sudo $ip link set $virt_if up
|
||||
do_sudo $ip link set dev $virt_if master $bridge
|
||||
;;
|
||||
|
||||
*ifdown*)
|
||||
virt_if=$1
|
||||
do_sudo $ip link set dev $virt_if nomaster
|
||||
do_sudo $ip link set dev $virt_if down
|
||||
;;
|
||||
qemu.sh)
|
||||
boot "$@"
|
||||
;;
|
||||
qemu-boot.sh) # legacy
|
||||
boot "$@"
|
||||
;;
|
||||
*)
|
||||
echo called as unknown executable name $0
|
||||
;;
|
||||
esac
|
||||
174
scripts/scm.sh
174
scripts/scm.sh
|
|
@ -1,174 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
cmd_mv()
|
||||
{
|
||||
local from="$1"
|
||||
local to="$2"
|
||||
case $scm in
|
||||
cvs)
|
||||
cp "$from" "$to"
|
||||
cvs add "$to"
|
||||
cvs remove -f "$from"
|
||||
;;
|
||||
git)
|
||||
git mv "$from" "$to"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cmd_commit()
|
||||
{
|
||||
C=''
|
||||
for i in "$@"; do
|
||||
C="$C \"${i//\"/\\\"}\""
|
||||
done
|
||||
eval $scm commit "$C"
|
||||
}
|
||||
|
||||
cmd_add()
|
||||
{
|
||||
$scm add "$@"
|
||||
}
|
||||
|
||||
cmd_rm()
|
||||
{
|
||||
case $scm in
|
||||
cvs)
|
||||
cvs remove "$@"
|
||||
;;
|
||||
git)
|
||||
git rm "$@"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cmd_clean()
|
||||
{
|
||||
case $scm in
|
||||
cvs)
|
||||
while [ "${1:0:1}" = - ]; do
|
||||
shift
|
||||
done
|
||||
set +e
|
||||
local file
|
||||
for file in $@; do
|
||||
if ! grep -q "/$file/" CVS/Entries; then
|
||||
rm -f $file
|
||||
fi
|
||||
done
|
||||
;;
|
||||
git)
|
||||
git clean -x "$@"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cmd_ls_files()
|
||||
{
|
||||
filter_deleted()
|
||||
{
|
||||
local rc_file="$1"
|
||||
shift
|
||||
local cand
|
||||
for cand in "$@"; do
|
||||
grep -q "^R ./$cand/" $rc_file && continue
|
||||
echo $cand
|
||||
done
|
||||
}
|
||||
|
||||
output()
|
||||
{
|
||||
if [ "$zero_terminate" = 1 ]; then
|
||||
echo -en "$*\x00"
|
||||
else
|
||||
echo "$*"
|
||||
fi
|
||||
}
|
||||
|
||||
list_dirents_cvs()
|
||||
{
|
||||
local dirs=`sed '/^D\// !d; s%^D/%%; s%/.*%%' $1/CVS/Entries`
|
||||
dirs="`filter_deleted $1/CVS/Entries $dirs`"
|
||||
local cands
|
||||
if [ -f $1/CVS/Entries.Log ]; then
|
||||
cands="`sed '/^A D\// !d; s%^A D/%%; s%/.*%%' $1/CVS/Entries.Log`"
|
||||
dirs="$dirs `filter_deleted $1/CVS/Entries.Log $cands`"
|
||||
fi
|
||||
local files=`sed '/^\// !d; s%/%%; s%/.*%%; s%^%%' $1/CVS/Entries`
|
||||
files="`filter_deleted $1/CVS/Entries $files`"
|
||||
local d f
|
||||
for f in $files; do
|
||||
output "$1/$f"
|
||||
done
|
||||
for d in $dirs; do
|
||||
[ "$opt_only_regular_files" = 1 ] || output $1/$d
|
||||
list_dirents_cvs $1/$d
|
||||
done
|
||||
}
|
||||
|
||||
list_dirents_git()
|
||||
{
|
||||
local opts="$git_ls_files_opts"
|
||||
git --version | grep -q "version *1" && opt_no_submodules=1
|
||||
[ "$opt_no_submodules" = 1 ] || opts="$opts --recurse-submodules"
|
||||
git ls-files --recurse-submodules $opts $1
|
||||
}
|
||||
|
||||
list_dirents()
|
||||
{
|
||||
if [ -d $1/CVS ]; then
|
||||
list_dirents_cvs $1
|
||||
return
|
||||
fi
|
||||
git status >/dev/null 2>&1 || {
|
||||
echo "failed to list versioned files in $1: no VCS" >&2
|
||||
exit 1
|
||||
}
|
||||
list_dirents_git $1
|
||||
}
|
||||
|
||||
set -- `getopt fnzt "$@"`
|
||||
|
||||
while [ "$1" != -- ]; do
|
||||
case $1 in
|
||||
-f)
|
||||
opt_only_regular_files=1
|
||||
;;
|
||||
-n)
|
||||
opt_no_submodules=1
|
||||
;;
|
||||
-z)
|
||||
zero_terminate=1
|
||||
git_ls_files_opts="$git_ls_files_opts -z"
|
||||
opt_sort="$opt_sort -z"
|
||||
;;
|
||||
-t)
|
||||
text_files=1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
proj_dir="$1"
|
||||
[ "$proj_dir" ] && cd $proj_dir
|
||||
|
||||
if [ "$text_files" ]; then
|
||||
list_dirents . | sort $opt_sort | xargs file -N | grep ":.*text" | cut -d: -f1
|
||||
else
|
||||
list_dirents . | sort $opt_sort
|
||||
fi
|
||||
}
|
||||
|
||||
# ------- here we go
|
||||
export LANG=POSIX
|
||||
myname=`basename $0`
|
||||
cmd=cmd_${1//-/_}
|
||||
shift
|
||||
if [ -d "CVS" ]; then
|
||||
scm=cvs
|
||||
else
|
||||
scm=git
|
||||
fi
|
||||
|
||||
$cmd "$@"
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
goodbye()
|
||||
{
|
||||
rm -rf $tmp
|
||||
[ "$1" ] && exit $1
|
||||
}
|
||||
|
||||
log()
|
||||
{
|
||||
echo $@
|
||||
}
|
||||
|
||||
error()
|
||||
{
|
||||
log $@
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
error $@
|
||||
goodbye 1
|
||||
}
|
||||
|
||||
set_var()
|
||||
{
|
||||
local var=$1
|
||||
shift
|
||||
eval local check=\$$var
|
||||
if [ -z "$check" ]; then
|
||||
eval $var="$@"
|
||||
fi
|
||||
}
|
||||
|
||||
set_defaults()
|
||||
{
|
||||
set_var modules `cd $dir; ls streamline-*.sh | sed 's/streamline-//; s/\.sh//; /^project$/ d'`
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<- EOT | sed 's/^ *|//'
|
||||
|
|
||||
| $myname [options] module ...
|
||||
|
|
||||
| module(s) are the module to be executed, currently selected: $modules
|
||||
|
|
||||
| options are
|
||||
|
|
||||
| -h: display this help message and exit sucessfully
|
||||
|
|
||||
EOT
|
||||
goodbye $1
|
||||
}
|
||||
|
||||
# -------------- here we go
|
||||
|
||||
trap goodbye INT KILL EXIT
|
||||
|
||||
myname=`basename $0`
|
||||
dir=`dirname $0`
|
||||
|
||||
eval set -- `getopt -- h "$@"`
|
||||
|
||||
while [ "$1" != -- ]; do
|
||||
case $1 in
|
||||
-h)
|
||||
usage=0;;
|
||||
*)
|
||||
usage=1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
# modules="$@"
|
||||
|
||||
set_defaults
|
||||
|
||||
[ "$usage" ] && usage $usage
|
||||
|
||||
for m in $modules; do
|
||||
mod_script=$dir/streamline-$m.sh
|
||||
log running $mod_script status
|
||||
status=`$mod_script status`
|
||||
r=$?
|
||||
if [ "$r" != 0 ]; then
|
||||
fatal "running "$mod_script status" failed ($r)"
|
||||
fi
|
||||
case $status in
|
||||
not-implemented)
|
||||
log "module $m is not implemented, yet, ignoring"
|
||||
;;
|
||||
due)
|
||||
log "need to run module $m"
|
||||
;;
|
||||
*)
|
||||
fatal "unrecognized output from module $m"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
shift # get rid of the '-c' supplied by make.
|
||||
log=/tmp/make-cmds.log
|
||||
/usr/bin/time --format "%E $*" -ao $log /bin/bash -c "$*"
|
||||
|
||||
|
|
@ -1,362 +0,0 @@
|
|||
#!/bin/sh
|
||||
########################################################################
|
||||
# #
|
||||
# generic utiltiy modules #
|
||||
# (c) 2001 jannet it services #
|
||||
# contact@jannet.de #
|
||||
# #
|
||||
# $Id$
|
||||
# #
|
||||
# This program is free software; permission to use, copy, modify, #
|
||||
# distribute, and sell this software and its documentation under the #
|
||||
# terms of the GNU Public license as published by the Free Software #
|
||||
# Foundation, either version 2 or any later version of the license, is #
|
||||
# hereby granted without fee, provided that (i) the above copyright #
|
||||
# notices and this permission notice appear in all copies of the #
|
||||
# software and related documentation, and (ii) the name of JanNet may #
|
||||
# not be used in any advertising or publicity relating to the software #
|
||||
# without the specific, prior written permission of JanNet. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but #
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- #
|
||||
# TABILITY 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 Founda- #
|
||||
# tion, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
|
||||
MYNAME=`basename $0`
|
||||
HOST=pkg.janware.com
|
||||
CFG_FILE=$HOME/.uploadrc
|
||||
|
||||
login=`whoami`
|
||||
method=
|
||||
pw_ftp=
|
||||
pw_scp=$HOME/.ssh/identity
|
||||
pw_rsync=
|
||||
pw_rsync_ssh=$HOME/.ssh/identity
|
||||
file_mode=
|
||||
dir_mode=
|
||||
file_owner=
|
||||
file_group=
|
||||
ssh_identity=
|
||||
|
||||
test -f $CFG_FILE && . $CFG_FILE
|
||||
|
||||
if [ -n "$ssh_identity" ]; then
|
||||
CFG_IDENTITY="-i $ssh_identity"
|
||||
fi
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOT
|
||||
|
||||
Unified Upload Interface
|
||||
Version '$Revision$' - '$Date$'
|
||||
(c) 2002 Jannet IT Services http://www.jannet.de
|
||||
|
||||
usage: $MYNAME -h
|
||||
$MYNAME [-v] [-c variable] source [method://][[password:]login@]host[:target[:mode[:dirmode[:owner[.group]]]]] ...
|
||||
|
||||
where "method" is one of "ftp", "scp", "rsync", "rsync_ssh".
|
||||
|
||||
"password" may be a valid rsa private key file, too, if this makes sense with the chosen method.
|
||||
|
||||
"source" may be a directory or a file. If it ends with a slash, it is treated as an existing
|
||||
directory and expands to its contents. Thus, in the following, "source" denotes either a single
|
||||
or multiple files or directories.
|
||||
|
||||
"target" may be a directory or a file.
|
||||
+ If it is an existing directory, it will be populated with "source". The name(s) of "source" will be preserved.
|
||||
+ If it is not an existing directory, and does not have a trailing slash,
|
||||
$MYNAME will skip everything following the last slash for a directory name, create
|
||||
it, and populate it with "source". "source" will get renamed to the last portion of "target".
|
||||
+ If it is not an existing directory and has a trailing slash it will be created and populated with
|
||||
"source".
|
||||
|
||||
The default values for the optional parameters can be redefined in $CFG_FILE.
|
||||
Currently they are:
|
||||
|
||||
login="$login"
|
||||
method="$method"
|
||||
pw_ftp="$pw_ftp"
|
||||
pw_scp="$pw_scp"
|
||||
pw_rsync="$pc_rsync"
|
||||
pw_rsync_ssh="$pw_rsync_ssh"
|
||||
file_mode="$file_mode"
|
||||
dir_mode="$dir_mode"
|
||||
file_owner="$file_owner"
|
||||
file_group="$file_group"
|
||||
ssh_identity="$ssh_identity"
|
||||
|
||||
Options:
|
||||
|
||||
-h : show this help screen
|
||||
-c variable : show contents of variable
|
||||
valid variables are login, method, passwd, file_owner, file_group, file_mode, dir_mode,
|
||||
source, target_file
|
||||
-p : parse command line into variables, show results and exit if -x switch is active
|
||||
-x : exit after informational commands
|
||||
|
||||
EOT
|
||||
[ -n "$1" ] && exit $1
|
||||
}
|
||||
|
||||
log()
|
||||
{
|
||||
echo $@
|
||||
}
|
||||
|
||||
err()
|
||||
{
|
||||
log $@
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
err $@
|
||||
exit 1
|
||||
}
|
||||
|
||||
is_dir()
|
||||
{
|
||||
isdir="`echo $1 | sed 's/.*\/$/yes/'`"
|
||||
test "$isdir" = yes
|
||||
}
|
||||
|
||||
parse_target()
|
||||
{
|
||||
target=$1
|
||||
LOGIN=`echo $target | sed -e 's/^.*:\/\///; /@/ !d; s/@.*//; s/.*://'`
|
||||
test -n "$LOGIN" && echo login="\"$LOGIN\";"
|
||||
METHOD=`echo $target | sed -e '/:\/\// !d; s/:\/\/.*//'`
|
||||
test -n "$METHOD" && echo method="\"$METHOD\";"
|
||||
PASSWD=`echo $target | sed -e '/@/ !d; /@/ !d; s/^.*:\/\///; s/@.*//' | rev | cut -d: -f2 | rev`
|
||||
if [ -n "$PASSWD" ]; then
|
||||
echo passwd="\"$PASSWD\";"
|
||||
if [ -f "$PASSWD" ]; then
|
||||
echo IDENTITY="\"-i $PASSWD\";"
|
||||
else
|
||||
echo IDENTITY="\"$CFG_IDENTITY\";"
|
||||
fi
|
||||
echo pw_ftp="\"$PASSWD\";"
|
||||
echo pw_scp="\"$PASSWD\";"
|
||||
echo pw_rsync="\"$PASSWD\";"
|
||||
echo pw_rsync_ssh="\"$PASSWD\";"
|
||||
fi
|
||||
HOST=`echo $target | sed -e 's/^.*:\/\///; s/.*@//' | cut -d: -f1`
|
||||
case $METHOD in
|
||||
rsync_ssh)
|
||||
if [ -z "$HOST" ]; then
|
||||
PARSE_TARGET=FALSE
|
||||
return
|
||||
fi
|
||||
echo host="\"$HOST\";"
|
||||
;;
|
||||
"")
|
||||
;;
|
||||
*)
|
||||
PARSE_TARGET=FALSE
|
||||
return
|
||||
;;
|
||||
esac
|
||||
TARGET_FILE=`echo $target | sed -e 's/^.*:\/\///; s/.*@//' | cut -d: -f2`
|
||||
if [ -n "$TARGET_FILE" ]; then
|
||||
echo target_file="\"$TARGET_FILE\";"
|
||||
else
|
||||
PARSE_TARGET=FALSE
|
||||
return
|
||||
fi
|
||||
FILE_MODE=`echo $target | sed -e 's/^.*:\/\///; s/.*@//; /:/ !d' | cut -d: -f3`
|
||||
test -n "$FILE_MODE" && echo file_mode="\"$FILE_MODE\";"
|
||||
DIR_MODE=`echo $target | sed -e 's/^.*:\/\///; s/.*@//; /:/ !d' | cut -d: -f4`
|
||||
test -n "$DIR_MODE" && echo dir_mode="\"$DIR_MODE\";"
|
||||
FILE_OWNER=`echo $target | sed -e 's/^.*:\/\///; s/.*@//; /:/ !d' | cut -d: -f5 | cut -d. -f1`
|
||||
test -n "$FILE_OWNER" && echo file_owner="\"$FILE_OWNER\";"
|
||||
FILE_GROUP=`echo $target | sed -e 's/^.*:\/\///; s/.*@//; /:/ !d' | cut -d: -f5 | cut -d. -f2`
|
||||
test -n "$FILE_GROUP" && echo file_group="\"$FILE_GROUP\";"
|
||||
|
||||
if is_dir "$target_file" ; then
|
||||
echo target_path=\"$TARGET_FILE/`basename $TARGET_FILE`\" # TODO: this is bullshit
|
||||
else
|
||||
echo target_path=\"$TARGET_FILE\" # TODO: this is bullshit
|
||||
fi
|
||||
|
||||
echo "PARSE_TARGET=\"OK\";"
|
||||
}
|
||||
|
||||
ssh_exec_stdin()
|
||||
{
|
||||
$SSH -l $login $IDENTITY $host -C "SCRIPT=\`mktemp /tmp/$MYNAME""_XXXXXX\`; cat > \$SCRIPT; /bin/sh \$SCRIPT; rm \$SCRIPT"
|
||||
}
|
||||
|
||||
ssh_mkdir()
|
||||
{
|
||||
set -e
|
||||
dir=`echo $1 | sed -e 's/\/[^\/]*$//; s/\/*$//'`
|
||||
parts="/ `echo $dir | sed -e 's%/% %g'`"
|
||||
test -n "$dir_mode" && MODE="-m $dir_mode"
|
||||
cat << EOT |
|
||||
for part in $parts; do
|
||||
path="\$path/\$part"
|
||||
if [ ! -d \$path ]; then
|
||||
mkdir \$path || break
|
||||
test -n "$2" && chown "$2" \$path || continue
|
||||
test -n "$3" && chgrp "$3" \$path || continue
|
||||
test -n "$4" && chmod "$4" \$path || continue
|
||||
fi
|
||||
if [ ! -d \$path ]; then
|
||||
fatal "failed to create directory \$path, owner=\$file_owner, group=\$file_group, mode=\$dir_mode"
|
||||
fi
|
||||
done
|
||||
EOT
|
||||
ssh_exec_stdin
|
||||
}
|
||||
|
||||
ssh_chown()
|
||||
{
|
||||
set -e
|
||||
dir=`echo $1 | sed -e 's/\/[^\/]*$//; s/\/*$//'`
|
||||
cat << EOT |
|
||||
if [ -f "$1" -a -n "$file_owner" ]; then chown $file_owner $1; fi
|
||||
if [ -f "$1" -a -n "$file_group" ]; then chgrp $file_group $1; fi
|
||||
#cd $1
|
||||
#if [ -n "$2" ]; then chown -R $2 . ; fi
|
||||
#if [ -n "$3" ]; then chown -R $3 . ; fi
|
||||
EOT
|
||||
ssh_exec_stdin
|
||||
}
|
||||
|
||||
ssh_chmod()
|
||||
{
|
||||
set -e
|
||||
dir=`echo $1 | sed -e 's/\/[^\/]*$//; s/\/*$//'`
|
||||
cat << EOT |
|
||||
if [ -f "$1" -a -n "$file_mode" ]; then chmod $file_mode $1; fi
|
||||
#if [ -n "$2" ]; then find . -type f | xargs --no-run-if-empty chmod $2 ; fi
|
||||
#if [ -n "$3" ]; then find . -type d | xargs --no-run-if-empty chmod $3 ; fi
|
||||
EOT
|
||||
ssh_exec_stdin
|
||||
}
|
||||
|
||||
# -- here we go
|
||||
# -- command line arguments
|
||||
set -- `getopt 'hvc:px' $*`
|
||||
while [ "$1" != -- ]; do
|
||||
case $1 in
|
||||
-h)
|
||||
usage 0;;
|
||||
-v)
|
||||
VERBOSE=1;;
|
||||
-c)
|
||||
VARIABLE=$2
|
||||
shift;;
|
||||
-p)
|
||||
PARSE=1;;
|
||||
-x)
|
||||
EXIT=1;;
|
||||
*)
|
||||
usage 1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
test -z "$VARIABLE" && test $# -lt 2 && usage 1
|
||||
|
||||
# -- get parameters from command line
|
||||
n_targets=`expr $# - 1`
|
||||
target="`echo $* | cut -d' ' -f$#`"
|
||||
source="`echo $* | cut -d' ' -f1-$n_targets`"
|
||||
#echo target=$target
|
||||
#echo source=$source
|
||||
|
||||
# -- check run
|
||||
for s in $source; do
|
||||
if [ ! -d "$s" -a ! -f "$s" -a ! -L "$s" ]; then
|
||||
fatal \"$s\" is neither a regular file, nor a directory, nor a link. Exiting. >&2
|
||||
fi
|
||||
done
|
||||
|
||||
eval `parse_target $target`
|
||||
if [ "$PARSE_TARGET" != OK ]; then
|
||||
echo "Failed to parse target \"$t\"; exiting."
|
||||
parse_target $t
|
||||
exit 2
|
||||
fi
|
||||
case $method in
|
||||
rsync_ssh)
|
||||
if [ "$login" != root ]; then
|
||||
if [ "$file_owner" -a "$file_owner" != "$login" ]; then
|
||||
fatal "File owner \"$file_owner\" is only legal, if you log in as \"$login\" or as \"root\"."
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
"")
|
||||
;;
|
||||
*)
|
||||
fatal "Support for method \"$method\" is not implemented." >&2
|
||||
;;
|
||||
esac
|
||||
|
||||
# -- real run
|
||||
|
||||
SSH=ssh
|
||||
[ "$RSYNC_RSH" ] && SSH=$RSYNC_RSH
|
||||
|
||||
if [ -n "$VARIABLE" ]; then
|
||||
eval `parse_target`
|
||||
case "$VARIABLE" in
|
||||
login) echo $login;;
|
||||
method) echo $method;;
|
||||
passwd) echo $passwd;;
|
||||
file_owner) echo $file_owner;;
|
||||
file_group) echo $file_group;;
|
||||
file_mode) echo $file_mode;;
|
||||
dir_mode) echo $dir_mode;;
|
||||
source) echo $source;;
|
||||
target_file) echo $target_file;;
|
||||
*) fatal Unknown variable \"$VARIABLE\". Exiting. >&2;;
|
||||
esac
|
||||
test "$EXIT" = 1 && exit 0
|
||||
fi
|
||||
|
||||
if [ "$PARSE" = 1 ]; then
|
||||
|
||||
eval `parse_target`
|
||||
|
||||
for var in login method passwd file_owner file_group file_mode dir_mode source target_file ; do
|
||||
|
||||
eval echo $var = \$$var
|
||||
done
|
||||
test "$EXIT" = 1 && exit 0
|
||||
fi
|
||||
|
||||
eval `parse_target $target`
|
||||
case $method in
|
||||
rsync_ssh)
|
||||
tmp_dir=/tmp/$login/rsync-ssh
|
||||
ssh_mkdir $target_file $file_owner $file_group $dir_mode || fatal "failed to create directory for $target_file"
|
||||
/usr/bin/rsync -az --links $RSYNC_EXTRA_OPTS -e "$SSH -l $login $IDENTITY" $source $login@$host:$target_file
|
||||
ssh_chown $target_path $file_owner $file_group
|
||||
ssh_chmod $target_path $file_mode $dir_mode
|
||||
;;
|
||||
"")
|
||||
#[ "$file_owner" ] || file_owner=`stat -c %u $source | head -1`
|
||||
#[ "$file_group" ] || file_group=`stat -c %g $source | head -1`
|
||||
#[ "$file_mode" ] || file_mode=`stat -c %a $source | head -1`
|
||||
#install -m $file_mode -o $file_owner -g $file_group $source $target
|
||||
$do_sudo cp $source $target
|
||||
if [ "$file_owner" ] ; then $do_sudo chown $file_owner $target; fi
|
||||
if [ "$file_group" ] ; then $do_sudo chgrp $file_group $target; fi
|
||||
if [ "$file_mode" ] ; then $do_sudo chmod $file_mode $target; fi
|
||||
;;
|
||||
*)
|
||||
fatal "Internal error: \"$method\" is not implemented." >&2
|
||||
;;
|
||||
esac
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue