소스관리 툴
소스 코드를 /srcman 디렉토리에 모아 놓고 빌드, 설치 등을 할 수 있는 툴입니다.
*사용할 때에는 반드시 mkdir /srcman 디렉토리를 만드셔야 합니다.
*아래의 코드는 /sbin 에 srcman 이라는 이름으로 저장하세요.
--------------------------스크립트--------------------------------
#!/bin/bash
BUILD='make'
FILE=''
RMOBJ='N'
case "$1" in
add)
if !(test -e /srcman/); then
echo "ERROR: No file."
exit 0;
else
FILE=$PWD'/'$2
cd /srcman/
if test -e $FILE; then
echo "Unpackaging..."
tar xzvf $FILE
else
if test -e $2; then
echo "Unpackaging..."
tar xzvf $2
else
echo "ERROR: No file."
exit 0;
fi
fi
fi
echo "finished."
;;
install)
if !(test -e /srcman/$2); then
echo "ERROR: No file."
exit 0;
else
cd /srcman/$2
if !(test -e ".configure"); then
echo "running configure..."
./configure | cat > .configure
fi
if test -e "Makefile"; then
BUILD='make'
else
if test -e "Jamfile"; then
BUILD='jam'
else
echo "ERROR: Unsupport build tool."
exit 0;
fi
fi
if !(test -e ".build"); then
echo "building..."
cat .configure | $BUILD | cat > .build
fi
cat "installing..."
cat .build | $BUILD | cat > install.log
cat install.log
fi
echo "finished."
;;
uninstall)
if !(test -e /srcman/$2); then
echo "ERROR: No file."
exit 0;
else
cd /srcman/$2
if test -e "Makefile"; then
BUILD='make'
else
if test -e "Jamfile"; then
BUILD='jam'
else
echo "ERROR: Unsupport build tool."
exit 0;
fi
fi
$BUILD uninstall
echo "Do you want remove object files? (Y/N default: N)"
read RMOBJ
if [ "$RMOBJ" = "y" -o "$RMOBJ" = "Y" ]; then
$BUILD clean
rm -rf .configure
rm -rf .build
rm -rf install.log
echo "remove successful."
fi
fi
echo "finished."
;;
rebuild)
if !(test -e /srcman/$2); then
echo "ERROR: No file."
exit 0;
else
cd /srcman/$2
echo "running configure..."
./configure | cat > .configure
if test -e "Makefile"; then
BUILD='make'
else
if test -e "Jamfile"; then
BUILD='jam'
else
echo "ERROR: Unsupport build tool."
exit 0;
fi
fi
echo "cleaning..."
$BUILD clean
echo "building..."
cat .configure | $BUILD | cat > .build
echo "installing..."
cat .build | $BUILD install | cat > install.log
cat install.log
fi
echo "finished."
;;
remove)
if !(test -e /srcman/); then
echo "ERROR: No file."
exit 0;
else
cd /srcman/
if [ "$2" = "" ]; then
echo "ERROR: No source to remove."
exit 0;
else
rm -rf /srcman/$2*
fi
fi
echo "finished."
;;
list)
if !(test -e /srcman/); then
echo "ERROR: No file."
exit 0;
else
cd /srcman/
ls -l | grep d | more
fi
;;
*)
echo "Usage: srcman {add|remove|install|uninstall|rebuild|list filename}"
exit 1
;;
esac
exit 0;
오류 또는 개선점 있으면
오류 또는 개선점 있으면 댓글 달아주세요.
-----------------------------절 취 선-----------------------------------
홈페이지: yonghyu.dyndns.org
B.Y.H
-----------------------------절 취 선-----------------------------------
따라하지 마세요.
홈페이지: yonghyu.dyndns.org
B.Y.H
댓글 달기