diff --git a/Makefile b/Makefile index 3ded585..4816a5e 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ DESTDIR=/ install: if [ ! -d ${DESTDIR}/etc/pm ]; then \ mkdir -pv ${DESTDIR}/etc/pm; \ - touch ${DESTDIR}/etc/pm/repo; \ + # touch ${DESTDIR}/etc/pm/repo; \ fi if [ ! -d ${DESTDIR}/tmp ]; then \ mkdir -pv ${DESTDIR}/tmp; \ @@ -14,7 +14,7 @@ install: fi if [ ! -d ${DESTDIR}/usr/share/pm ]; then \ mkdir -pv ${DESTDIR}/usr/share/pm/{packages,repos}; \ - touch ${DESTDIR}/usr/share/pm/query; \ + # touch ${DESTDIR}/usr/share/pm/query; \ fi if [ ! -d ${DESTDIR}/var/cache/pm/pkg ]; then \ mkdir -pv ${DESTDIR}/var/cache/pm/pkg; \ diff --git a/PMBUILD b/PMBUILD new file mode 100644 index 0000000..41d9061 --- /dev/null +++ b/PMBUILD @@ -0,0 +1,11 @@ +pkgname=pm +pkgver=1.1 +pkgrel=1 +# srcdir=/home/tola/Documents/linux/pm +gitsource="https://gitea.home.com:3000/TolaMironcenko/pm.git" +deps="busybox" + +package() { + cd $srcdir + make install DESTDIR=$pkgdir +} diff --git a/src/pm b/src/pm index 4cda774..96dfa79 100755 --- a/src/pm +++ b/src/pm @@ -107,6 +107,7 @@ down() { if [[ $j == $1 ]]; then if [ ! -f $cachedpkgdir/$1.pkg.gz ]; then printf "$YELLOW**$RESET Downloading $YELLOW$serverdir: $Bwhite$j\n$RESET" + echo $i/$1.pkg.gz wget $i/$1.pkg.gz -P $cachedpkgdir check $? "Download package" # if [[ "$?" == "0" ]]; then @@ -328,22 +329,23 @@ search() { done exit 0 fi - + found=false for i in $servers; do serverdir=$(echo $i | sed -e "/http:\/\//s///") serverdir=$(echo $serverdir | sed -e "/ftp:\/\//s///") repoquery=$(/usr/bin/cat $reposquerydir/$serverdir/query | sed -e '/.pkg.gz/s///') for j in $repoquery; do - if [[ $j == $1 ]]; then + if [[ $j =~ $1 ]]; then printf "$YELLOW$serverdir: $BWHITE$j\n$RESET" - exit 0 + # exit 0 + found=true fi done done - printf "$YELLOW**$RED error:$RESET can't find package ($1)\n" + [ "$found" = "false" ] && printf "$YELLOW**$RED error:$RESET can't find package ($1)\n" } ss() { - search + search $1 } #------------------------------------------------------------------------ @@ -365,6 +367,56 @@ deps() { cat $installedpackagesdir/$1.pkg/deps } +buildpkg() { + if [ ! -f ./PMBUILD ]; then + if [ "$1" != "" ]; then + source $1 + else + printf "$BBLUE**$BWHITE Can't find PMBUILD [$BRED ERROR $BWHITE]\n$RESET" + fi + else + source ./PMBUILD + fi + [ ! -d src ] && mkdir -pv src + [ ! -d pkg/$pkgname-$pkgver-$pkgrel.pkg ] && mkdir -pv pkg/$pkgname-$pkgver-$pkgrel.pkg + export buildroot=$(pwd) + export pkgdir=$buildroot/pkg/$pkgname-$pkgver-$pkgrel.pkg + if [ "$srcdir" = "" ]; then + export srcdir=$buildroot/src/$pkgname + fi + echo $pkgdir + echo $srcdir + if [ "$gitsource" != "" ]; then + echo $gitsource + git clone $gitsource $srcdir + fi + if [[ $(type -t build) = function ]]; then + echo "yes" + else + echo "no" + fi + if [[ $(type -t package) == function ]]; then + echo "yes" + package + else + echo "no" + fi + cd $pkgdir + find -type f > $buildroot/list + sed -i "s/.\///" $buildroot/list + cd $buildroot + mv -v list $pkgdir/list + if [ "$deps" != "" ]; then + for i in $deps; do + echo $i >> $pkgdir/deps + done + fi + cd $pkgdir + tar -czvf $buildroot/$pkgname-$pkgver-$pkgrel.pkg.gz .. + cd $buildroot + unset pkgdir srcdir buildroot +} + case "$1" in add|a|del|d) checkroot @@ -374,6 +426,9 @@ case "$1" in checkroot "$1" $2 ;; + build) + buildpkg $2 + ;; *) help ;;