mirror of
https://github.com/outbackdingo/scratchpkg.git
synced 2026-03-19 23:13:41 +00:00
updated
This commit is contained in:
@@ -1,156 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
INDEX_DIR="/var/lib/scratchpkg/index"
|
||||
|
||||
PKG=(
|
||||
linux-api-headers
|
||||
man-pages
|
||||
glibc
|
||||
tzdata
|
||||
zlib
|
||||
file
|
||||
readline
|
||||
m4
|
||||
bc
|
||||
binutils
|
||||
gmp
|
||||
mpfr
|
||||
libmpc
|
||||
gcc
|
||||
bzip2
|
||||
pkg-config
|
||||
ncurses
|
||||
attr
|
||||
acl
|
||||
libcap
|
||||
sed
|
||||
shadow
|
||||
psmisc
|
||||
iana-etc
|
||||
bison
|
||||
flex
|
||||
grep
|
||||
bash
|
||||
libtool
|
||||
gdbm
|
||||
gperf
|
||||
expat
|
||||
inetutils
|
||||
perl
|
||||
perl-xml-parser
|
||||
intltool
|
||||
autoconf
|
||||
automake
|
||||
xz
|
||||
kmod
|
||||
gettext
|
||||
elfutils
|
||||
procps-ng
|
||||
e2fsprogs
|
||||
coreutils
|
||||
diffutils
|
||||
gawk
|
||||
findutils
|
||||
groff
|
||||
grub
|
||||
less
|
||||
gzip
|
||||
iproute2
|
||||
kbd
|
||||
libpipeline
|
||||
make
|
||||
patch
|
||||
sysklogd
|
||||
sysvinit
|
||||
eudev
|
||||
util-linux
|
||||
man-db
|
||||
tar
|
||||
texinfo
|
||||
vim
|
||||
filesystem
|
||||
base-meta
|
||||
openssl
|
||||
ca-certificates-utils
|
||||
ca-certificates
|
||||
wget
|
||||
curl
|
||||
httpup
|
||||
scratchpkg
|
||||
rc-init
|
||||
)
|
||||
|
||||
adjustingtoolchain() {
|
||||
echo "Adjusting toolchain"
|
||||
mv -v /tools/bin/{ld,ld-old}
|
||||
mv -v /tools/$(uname -m)-pc-linux-gnu/bin/{ld,ld-old}
|
||||
mv -v /tools/bin/{ld-new,ld}
|
||||
ln -sv /tools/bin/ld /tools/$(uname -m)-pc-linux-gnu/bin/ld
|
||||
|
||||
gcc -dumpspecs | sed -e 's@/tools@@g' \
|
||||
-e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \
|
||||
-e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \
|
||||
`dirname $(gcc --print-libgcc-file-name)`/specs
|
||||
|
||||
echo 'int main(){}' > dummy.c
|
||||
cc dummy.c -v -Wl,--verbose &> dummy.log
|
||||
readelf -l a.out | grep ': /lib'
|
||||
|
||||
grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log
|
||||
grep -B1 '^ /usr/include' dummy.log
|
||||
grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'
|
||||
grep "/lib.*/libc.so.6 " dummy.log
|
||||
grep found dummy.log
|
||||
rm -v dummy.c a.out dummy.log
|
||||
sleep 5
|
||||
}
|
||||
|
||||
for i in ${PKG[@]}; do
|
||||
if [[ -d "$INDEX_DIR/$i" ]]; then
|
||||
echo "$i is installed"
|
||||
else
|
||||
echo
|
||||
echo "Installing $i..."
|
||||
case $i in
|
||||
glibc)
|
||||
ln -sfv /tools/lib/gcc /usr/lib
|
||||
#ln -sfv /tools/bin/m4 /usr/bin
|
||||
scratch install -d $i || exit 1
|
||||
adjustingtoolchain
|
||||
rm /usr/lib/gcc
|
||||
#rm /usr/bin/m4
|
||||
;;
|
||||
bc)
|
||||
ln -sfv /tools/lib/libncursesw.so.6 /usr/lib/libncursesw.so.6
|
||||
ln -sfv libncurses.so.6 /usr/lib/libncurses.so
|
||||
scratch install -d $i || exit 1
|
||||
rm /usr/lib/{libncurses.so,libncursesw.so.6}
|
||||
;;
|
||||
gcc)
|
||||
scratch -id -p $i || exit 1
|
||||
rm -f /usr/lib/{libgcc_s.so{,.1},libstdc++.{a,so{,.6}}}
|
||||
scratch install -d $i || exit 1
|
||||
;;
|
||||
bash|coreutils|filesystem|scratchpkg)
|
||||
# scratchpkg is hardly depends on bash and coreutils
|
||||
# so, ignore conflict, mean just replacing the files
|
||||
scratch install -dc $i || exit 1
|
||||
;;
|
||||
perl)
|
||||
echo "127.0.0.1 localhost $(hostname)" > /etc/hosts
|
||||
scratch install -d $i || exit 1
|
||||
rm /etc/hosts
|
||||
rm /usr/bin/perl
|
||||
scratch install -d $i || exit 1
|
||||
;;
|
||||
base-meta)
|
||||
scratch install $i || exit 1
|
||||
;;
|
||||
*)
|
||||
scratch install -d $i || exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -1,7 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "/usr/share/scratchpkg/color"
|
||||
source "/usr/share/scratchpkg/message"
|
||||
RED='\e[0;31m' #Red
|
||||
GREEN='\e[0;32m' #Green
|
||||
CRESET='\e[0m' #Reset color
|
||||
|
||||
msg() {
|
||||
echo -e "${GREEN}==>${CRESET} $1"
|
||||
}
|
||||
|
||||
msgerr() {
|
||||
echo -e "${RED}==> ERROR:${CRESET} $1"
|
||||
}
|
||||
|
||||
if [ "$UID" != "0" ]; then
|
||||
msgerr "Chroot need root access!"
|
||||
@@ -11,12 +20,12 @@ fi
|
||||
LFS=$1
|
||||
|
||||
if [ -z $1 ]; then
|
||||
msgerr "Please set mount point for chroot!"
|
||||
msgerr "Please set directory for chroot!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d $LFS ]; then
|
||||
msgerr "Dir '$LFS' not exist"
|
||||
msgerr "Directory '$LFS' not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -32,16 +41,16 @@ if [ -h $LFS/dev/shm ]; then
|
||||
mkdir -pv $LFS/$(readlink $LFS/dev/shm)
|
||||
fi
|
||||
|
||||
if [ -d $LFS/tools ]; then
|
||||
chroot "$LFS" /tools/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin /tools/bin/bash --login +h
|
||||
else
|
||||
chroot "$LFS" /usr/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login
|
||||
fi
|
||||
chroot "$LFS" /usr/bin/env -i \
|
||||
HOME=/root \
|
||||
TERM="$TERM" \
|
||||
PS1='\u:\w\$ ' \
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login
|
||||
|
||||
popd
|
||||
echo chroot exited
|
||||
msg "Chroot exited"
|
||||
|
||||
echo "Unmounting virtual filesystem"
|
||||
msg "Unmounting virtual filesystem"
|
||||
umount -v $LFS/dev/pts
|
||||
umount -v $LFS/dev
|
||||
umount -v $LFS/run
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "/usr/share/scratchpkg/functions"
|
||||
|
||||
if [ ! "$1" ]; then
|
||||
msgerr "Please specify package name to list its dependencies order."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while read repodir repourl junk; do
|
||||
case $repodir in
|
||||
""|"#"*) continue ;;
|
||||
esac
|
||||
PORT_REPO+=($repodir)
|
||||
done < /etc/scratchpkg.repo
|
||||
|
||||
checkdep() {
|
||||
|
||||
if getportpath "$1" >/dev/null; then
|
||||
pushd $(getportpath "$1")
|
||||
getpkginfo
|
||||
popd
|
||||
fi
|
||||
|
||||
for dep in ${depends[@]}; do
|
||||
echo $dep
|
||||
done
|
||||
|
||||
for mdep in ${makedepends[@]}; do
|
||||
echo $mdep
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
getportpath() {
|
||||
|
||||
for repo in ${PORT_REPO[@]}; do
|
||||
if [[ -f $repo/$1/$BUILD_SCRIPT ]]; then
|
||||
echo "$(dirname $repo/$1/$BUILD_SCRIPT)"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
|
||||
}
|
||||
|
||||
calc_dep() {
|
||||
|
||||
# check currently process package for loop
|
||||
if [ ${#CHECK[@]} -gt 0 ]; then
|
||||
if [[ "$(echo ${CHECK[@]} | tr " " "\n" | grep -x $1)" == "$1" ]]; then
|
||||
msgerr "loop dependency found: $1"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# add package to currently process
|
||||
CHECK+=($1)
|
||||
|
||||
# check dependencies
|
||||
for i in $(checkdep "$1"); do
|
||||
if [[ $(echo ${DEP[@]} | tr " " "\n" | grep -x $i) = "" ]]; then
|
||||
calc_dep $i
|
||||
fi
|
||||
done
|
||||
|
||||
# add dependency to list checked dep
|
||||
DEP+=($1)
|
||||
|
||||
# delete process package array
|
||||
for i in "${!CHECK[@]}"; do
|
||||
if [[ ${CHECK[i]} = "$1" ]]; then
|
||||
unset 'CHECK[i]'
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
CHECK=()
|
||||
DEP=()
|
||||
|
||||
calc_dep $1
|
||||
|
||||
for deps in ${DEP[@]}; do
|
||||
if [ -e $INDEX_DIR/$deps/.pkginfo ]; then
|
||||
msginst "$deps"
|
||||
elif ! getportpath "$deps" >/dev/null; then
|
||||
msgmiss "$deps"
|
||||
else
|
||||
msgnoinst "$deps"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -12,9 +12,6 @@ msgerr() {
|
||||
echo -e "${RED}==> ERROR:${CRESET} $1"
|
||||
}
|
||||
|
||||
#source "/usr/share/scratchpkg/color"
|
||||
#source "/usr/share/scratchpkg/message"
|
||||
|
||||
if [ ! $1 ]; then
|
||||
msgerr "This script requires one arguments."
|
||||
exit 1
|
||||
@@ -51,5 +48,4 @@ pushd / >/dev/null
|
||||
done < <(tac $INDEX_DIR/$1/.files | grep -E ^"(bin/|lib/|libexec/|sbin/|usr/bin/|usr/lib/|usr/libexec/|usr/sbin/)" | grep -v "/$")
|
||||
popd >/dev/null
|
||||
|
||||
echo "Shared lib from package(s):"
|
||||
echo $deppkg | tr ' ' '\n'
|
||||
|
||||
@@ -7,7 +7,6 @@ else
|
||||
mkdir $1
|
||||
echo "# description :
|
||||
# backup :
|
||||
# conflict :
|
||||
# depends :
|
||||
# noextract :
|
||||
|
||||
|
||||
19
revdep
19
revdep
@@ -2,8 +2,17 @@
|
||||
|
||||
INDEX_DIR="/var/lib/scratchpkg/index"
|
||||
|
||||
source "/usr/share/scratchpkg/color"
|
||||
source "/usr/share/scratchpkg/message"
|
||||
RED='\e[0;31m' #Red
|
||||
GREEN='\e[0;32m' #Green
|
||||
CRESET='\e[0m' #Reset color
|
||||
|
||||
msg() {
|
||||
echo -e "${GREEN}==>${CRESET} $1"
|
||||
}
|
||||
|
||||
msgerr() {
|
||||
echo -e "${RED}==> ERROR:${CRESET} $1"
|
||||
}
|
||||
|
||||
onepkg() {
|
||||
|
||||
@@ -19,8 +28,6 @@ onepkg() {
|
||||
done
|
||||
MISSING=yes
|
||||
fi ;;
|
||||
*)
|
||||
continue ;;
|
||||
esac
|
||||
done < <(grep -E '(*\.so\.*|^bin/|^sbin/|^usr/bin/|^usr/sbin/|^usr/libexec)' $INDEX_DIR/$1/.files | grep -Ev "(opt/|firmware/)")
|
||||
popd >/dev/null
|
||||
@@ -58,8 +65,6 @@ allpkg() {
|
||||
fi
|
||||
done
|
||||
fi ;;
|
||||
*)
|
||||
continue ;;
|
||||
esac
|
||||
done < <(grep -E '(*\.so\.*|^bin/|^sbin/|^usr/bin/|^usr/sbin/|^usr/libexec)' $INDEX_DIR/${allpkgs[pkgs]}/.files | grep -Ev "(opt/|firmware/|/share/theme/|/share/icons/)")
|
||||
done
|
||||
@@ -112,7 +117,7 @@ parse_options "$@"
|
||||
|
||||
if [ "${#PKG[@]}" -gt 0 ]; then
|
||||
for pkg in ${PKG[@]}; do
|
||||
if [ ! -d "$INDEX_DIR/$pkg" ]; then
|
||||
if [ ! -f "$INDEX_DIR/$pkg/.files" ]; then
|
||||
msgerr "Package '$pkg' not installed."
|
||||
else
|
||||
onepkg "$pkg"
|
||||
|
||||
397
scratch
397
scratch
@@ -1,5 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
RED='\e[0;31m' #Red
|
||||
GREEN='\e[0;32m' #Green
|
||||
YELLOW='\e[0;33m' #Yellow
|
||||
CYAN='\e[0;36m' #CyanBlue
|
||||
PURPLE='\e[0;35m' #Purple
|
||||
CRESET='\e[0m' #Reset color
|
||||
|
||||
msg() {
|
||||
echo -e "${GREEN}==>${CRESET} $1"
|
||||
}
|
||||
|
||||
msgerr() {
|
||||
echo -e "${RED}==> ERROR:${CRESET} $1"
|
||||
}
|
||||
|
||||
msginst() {
|
||||
echo -e "[${GREEN}i${CRESET}] $1"
|
||||
}
|
||||
|
||||
msgmiss() {
|
||||
echo -e "[${YELLOW}m${CRESET}] $1"
|
||||
}
|
||||
|
||||
msgnoinst() {
|
||||
echo -e "[ ] $1"
|
||||
}
|
||||
|
||||
msgwarn() {
|
||||
echo -e "${YELLOW}==> WARNING:${CRESET} $1"
|
||||
}
|
||||
|
||||
needroot() {
|
||||
if [ $UID != 0 ]; then
|
||||
if [ "$#" -eq 0 ]; then
|
||||
needroot "This operation"
|
||||
else
|
||||
msgerr "$@ need root access!"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
getportpath() {
|
||||
for repo in ${PORT_REPO[@]}; do
|
||||
if [[ -f $repo/$1/$BUILD_SCRIPT ]]; then
|
||||
@@ -10,6 +52,34 @@ getportpath() {
|
||||
return 1
|
||||
}
|
||||
|
||||
pushd() {
|
||||
command pushd $1 &>/dev/null
|
||||
}
|
||||
|
||||
popd() {
|
||||
command popd &>/dev/null
|
||||
}
|
||||
|
||||
vercomp() {
|
||||
if [ "$1" = "$2" ]; then
|
||||
return 0 # same version
|
||||
elif [ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]; then
|
||||
return 1 # $1 lower than $2
|
||||
else
|
||||
return 2 # $1 higher than $2
|
||||
fi
|
||||
}
|
||||
|
||||
installed_pkg_info() {
|
||||
if [ -f $INDEX_DIR/$2/.pkginfo ]; then
|
||||
echo $(cat $INDEX_DIR/$2/.pkginfo | grep ^$1 | cut -d " " -f3-)
|
||||
fi
|
||||
}
|
||||
|
||||
allinstalled() {
|
||||
ls ${INDEX_DIR}/*/.pkginfo | rev | cut -d '/' -f2 | rev 2>/dev/null
|
||||
}
|
||||
|
||||
confirm() {
|
||||
read -r -p "$1 (Y/n) " response
|
||||
case "$response" in
|
||||
@@ -18,6 +88,226 @@ confirm() {
|
||||
esac
|
||||
}
|
||||
|
||||
checktool() {
|
||||
if ! type -p $1 &>/dev/null; then
|
||||
msgerr "'$1' not exist in your system!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
catport() {
|
||||
if PPATH=$(getportpath "$1"); then
|
||||
cat "$PPATH/$BUILD_SCRIPT"
|
||||
else
|
||||
msgerr "Port '$1' not exist."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
listorphan() {
|
||||
local pkg all depends deps
|
||||
|
||||
for pkg in $(allinstalled); do
|
||||
if [ $(getportpath $pkg) ]; then
|
||||
depends=$(grep "^# depends[[:blank:]]*:" $(getportpath $pkg)/$BUILD_SCRIPT | sed 's/^# depends[[:blank:]]*:[[:blank:]]*//')
|
||||
. $(getportpath $pkg)/$BUILD_SCRIPT
|
||||
fi
|
||||
for deps in ${depends[@]}; do
|
||||
ALL_DEP+=($deps)
|
||||
done
|
||||
done
|
||||
|
||||
# find orphan package
|
||||
for all in $(allinstalled); do
|
||||
ORPHAN=yes
|
||||
for depended in ${ALL_DEP[@]}; do
|
||||
if [ $depended = $all ]; then
|
||||
ORPHAN=no
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$ORPHAN" = yes ]; then
|
||||
iname=$(installed_pkg_info name $all)
|
||||
iversion=$(installed_pkg_info version $all)
|
||||
irelease=$(installed_pkg_info release $all)
|
||||
echo -e "$iname ${GREEN}$iversion${CRESET}-${BLUE}$irelease${CRESET}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
listinstalled() {
|
||||
local pkg
|
||||
|
||||
for pkg in $(allinstalled); do
|
||||
iname=$(installed_pkg_info name $pkg)
|
||||
iversion=$(installed_pkg_info version $pkg)
|
||||
irelease=$(installed_pkg_info release $pkg)
|
||||
echo -e "$iname ${GREEN}$iversion${CRESET}-${CYAN}$irelease${CRESET}"
|
||||
done
|
||||
}
|
||||
|
||||
lockpkg() {
|
||||
local pkg
|
||||
|
||||
needroot "Locking package"
|
||||
|
||||
for pkg in "$@"; do
|
||||
if [ ! -f $INDEX_DIR/$pkg/.pkginfo ]; then
|
||||
msgerr "Package '$pkg' is not installed."
|
||||
else
|
||||
touch $INDEX_DIR/$pkg/.lock && msg "Successfully locked package '$pkg'."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
listlocked() {
|
||||
local pkg
|
||||
|
||||
for pkg in $(allinstalled); do
|
||||
if [ -f "$INDEX_DIR"/$pkg/.lock ]; then
|
||||
echo -e "$pkg"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
showdepends() {
|
||||
local dep
|
||||
|
||||
if [ $(getportpath "$1") ]; then
|
||||
pushd $(getportpath "$1")
|
||||
depends=$(grep "^# depends[[:blank:]]*:" $BUILD_SCRIPT | sed 's/^# depends[[:blank:]]*:[[:blank:]]*//')
|
||||
. $BUILD_SCRIPT
|
||||
popd
|
||||
else
|
||||
msgerr "Port '$1' not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for dep in ${depends[@]}; do
|
||||
if [ -d $INDEX_DIR/$dep ]; then
|
||||
msginst "$dep"
|
||||
elif getportpath $dep >/dev/null; then
|
||||
msgnoinst "$dep"
|
||||
else
|
||||
msgmiss "$dep"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
showdependent() {
|
||||
local port all dep
|
||||
|
||||
for port in ${PORT_REPO[@]}; do
|
||||
if [ -d $port ]; then
|
||||
for all in $(ls $port/*/$BUILD_SCRIPT | rev | cut -d '/' -f2 | rev 2>/dev/null); do
|
||||
if [ -f $port/$all/$BUILD_SCRIPT ]; then
|
||||
depend=$(cat $port/$all/$BUILD_SCRIPT | grep ^'# depends' | tr -d ':' | cut -d " " -f3-)
|
||||
for dep in ${depend[@]}; do
|
||||
if [ $dep = $1 ]; then
|
||||
GDP=yes
|
||||
if [ -d $INDEX_DIR/$all ]; then
|
||||
msginst "$all"
|
||||
else
|
||||
msgnoinst "$all"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
[ "$GDP" ] || msg "No package depends on '$1'."
|
||||
}
|
||||
|
||||
checkowner() {
|
||||
for pkg in $(allinstalled); do
|
||||
for output in $(cat $INDEX_DIR/$pkg/.files | grep $1); do
|
||||
echo -e "${CYAN}$pkg${CRESET} => ${PURPLE}$output${CRESET}"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
showtree() {
|
||||
if [ ! -f $INDEX_DIR/$1/.pkginfo ]; then
|
||||
msg "Package'$1' not installed."
|
||||
else
|
||||
while IFS=' ' read -r line; do
|
||||
echo "$line"
|
||||
done < <(cat $INDEX_DIR/$1/.files)
|
||||
fi
|
||||
}
|
||||
|
||||
updports() {
|
||||
checktool httpup
|
||||
|
||||
needroot "Updating ports"
|
||||
|
||||
if [ ! -e "$REPO_FILE" ]; then
|
||||
msgerr "Repo file not found! ($REPO_FILE)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while read repodir repourl junk; do
|
||||
case $repodir in
|
||||
""|"#"*) continue ;;
|
||||
esac
|
||||
if [ -n "$repodir" ] && [ -n "$repourl" ]; then
|
||||
httpup sync $repourl $repodir
|
||||
fi
|
||||
done < "$REPO_FILE"
|
||||
}
|
||||
|
||||
printreadme() {
|
||||
|
||||
if PPATH=$(getportpath "$1"); then
|
||||
if [ -f "$PPATH/readme" ]; then
|
||||
cat "$PPATH/readme"
|
||||
else
|
||||
msgerr "Port '$1' does not have readme."
|
||||
fi
|
||||
else
|
||||
msgerr "Port '$1' not exist."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
searchpkg() {
|
||||
local port found OUTPUT
|
||||
|
||||
for port in ${PORT_REPO[@]}; do
|
||||
if [ -d $port ]; then
|
||||
pushd $port
|
||||
OUTPUT=$(grep -R description | grep "$BUILD_SCRIPT:# description[[:blank:]]*:" | sed "s/$BUILD_SCRIPT:# description[[:blank:]]*://" | grep -i "$1" | cut -d '/' -f1)
|
||||
popd
|
||||
if [ -n "$OUTPUT" ]; then
|
||||
found=yes
|
||||
for out in ${OUTPUT[@]}; do
|
||||
if [ -f $port/$out/$BUILD_SCRIPT ]; then
|
||||
pushd $port/$out
|
||||
description=$(grep "^# description[[:blank:]]*:" $BUILD_SCRIPT | sed 's/^# description[[:blank:]]*:[[:blank:]]*//')
|
||||
. $BUILD_SCRIPT
|
||||
popd
|
||||
if [ ! -z "$name" ] && [ ! -z "$version" ] && [ ! -z "$release" ]; then
|
||||
portname=$(basename $port)
|
||||
search_result="${PURPLE}($portname)${CRESET} $name ${CYAN}$version-$release${CRESET} $description"
|
||||
if [ -e $INDEX_DIR/$name/.pkginfo ]; then
|
||||
echo -e "[${GREEN}*${CRESET}] $search_result"
|
||||
else
|
||||
echo -e "[ ] $search_result"
|
||||
fi
|
||||
unset description name version release
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ ! "$found" ]; then
|
||||
msg "No matching package found."
|
||||
fi
|
||||
}
|
||||
|
||||
installpkg() {
|
||||
local pkg i int pkgcount count IPKG
|
||||
|
||||
@@ -85,6 +375,43 @@ removepkg() {
|
||||
fi
|
||||
}
|
||||
|
||||
outdate() {
|
||||
local pkg
|
||||
|
||||
for pkg in $(allinstalled); do
|
||||
if [ $(getportpath $pkg) ]; then
|
||||
. $(getportpath $pkg)/$BUILD_SCRIPT
|
||||
iversion=$(installed_pkg_info version $pkg)
|
||||
irelease=$(installed_pkg_info release $pkg)
|
||||
[ -f "$INDEX_DIR/$pkg/.lock" ] && ITSLOCK="[locked]"
|
||||
outdatemsg="$name ${RED}$iversion-$irelease${CRESET} => ${GREEN}$version-$release${CRESET} ${CYAN}$ITSLOCK${CRESET}"
|
||||
newerinstmsg="$name ${RED}$iversion-$irelease${CRESET} => ${GREEN}$version-$release${CRESET} ${YELLOW}[newer installed]${CRESET} ${CYAN}$ITSLOCK${CRESET}"
|
||||
if [ "$version" != "$iversion" ]; then
|
||||
vercomp $version $iversion
|
||||
if [ $? = 2 ]; then
|
||||
echo -e "$outdatemsg"
|
||||
OUTDATE=yes
|
||||
elif [ $? = 1 ]; then
|
||||
echo -e "$newerinstmsg"
|
||||
OUTDATE=yes
|
||||
fi
|
||||
elif [ "$release" != "$irelease" ]; then
|
||||
vercomp $release $irelease
|
||||
if [ $? = 2 ]; then
|
||||
echo -e "$outdatemsg"
|
||||
OUTDATE=yes
|
||||
elif [ $? = 1 ]; then
|
||||
echo -e "$newerinstmsg"
|
||||
OUTDATE=yes
|
||||
fi
|
||||
fi
|
||||
unset ITSLOCK
|
||||
fi
|
||||
done
|
||||
|
||||
[ ! "$OUTDATE" ] && msg "All package is up to date."
|
||||
}
|
||||
|
||||
parse_opts() {
|
||||
while [ "$1" ]; do
|
||||
case $1 in
|
||||
@@ -100,6 +427,11 @@ main() {
|
||||
|
||||
parse_opts "$@"
|
||||
|
||||
if [ -z "$PORT_REPO" ]; then
|
||||
msgerr 'repository is empty!'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$mode" = "install" ]; then
|
||||
installpkg
|
||||
exit 0
|
||||
@@ -109,6 +441,71 @@ main() {
|
||||
removepkg
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$mode" = "outdate" ]; then
|
||||
outdate
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$mode" = "listorphan" ]; then
|
||||
listorphan
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$mode" = "search" ]; then
|
||||
searchpkg $1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$mode" = "sync" ]; then
|
||||
updports
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$mode" = "listinstalled" ]; then
|
||||
listinstalled
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$mode" = "readme" ]; then
|
||||
printreadme $1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$mode" = "pkgtree" ]; then
|
||||
showtree $1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$mode" = "own" ]; then
|
||||
checkowner $1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$mode" = "dependent" ]; then
|
||||
showdependent $1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$mode" = "cat" ]; then
|
||||
catport $1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$mode" = "depends" ]; then
|
||||
showdepends $1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$mode" = "lock" ]; then
|
||||
lockpkg $@
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$mode" = "listlocked" ]; then
|
||||
listlocked
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Run 'scratch help' to see available mode and options"
|
||||
exit 5
|
||||
|
||||
@@ -612,11 +612,8 @@ duplicateports() {
|
||||
|
||||
}
|
||||
|
||||
searchpkg() {
|
||||
|
||||
local port
|
||||
local found
|
||||
local OUTPUT
|
||||
searchpkg() {
|
||||
local port found OUTPUT
|
||||
|
||||
for port in ${PORT_REPO[@]}; do
|
||||
if [ -d $port ]; then
|
||||
|
||||
Reference in New Issue
Block a user