WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Is it possible to fix tcz "search" function in TinyCore 3.x?  (Read 1715 times)

Offline littlebat

  • Newbie
  • *
  • Posts: 25
Hi, I have some reason to use TinyCore 3.x, but the tcz "search" function seems  broken in the old TinyCore. It seems "cgi" problem in "search.sh" and "provides.sh". So I try to modify these two files in 3.x to fix this problem. My idea is to borrow the way of Tinycore 5.x, so I need to know where can I find "tags.db.gz" and "provides.db" in TinyCore 3.x? Just like they are in TinyCore 5.x: www.tinycorelinux.net/5.x/x86/tcz/tags.db.gz, http://www.tinycorelinux.net/5.x/x86/tcz/provides.db.

But, if TinyCore Linux official can fix this problem in the sever side easily. It would be ok.

Any idea?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Is it possible to fix tcz "search" function in TinyCore 3.x?
« Reply #1 on: July 17, 2014, 05:24:26 AM »
3.x relied entirely on server side, and has long been discontinued. We're not planning to bring it back, 3.x is unsupported.

As 3.x is not changing at all, you might mirror the entire 3.x repo locally? Searches would then be rather quick and easy.

edit: 3.x tcz repo without src is about 8 gb.
The only barriers that can stop you are the ones you create yourself.

Offline littlebat

  • Newbie
  • *
  • Posts: 25
Re: Is it possible to fix tcz "search" function in TinyCore 3.x?
« Reply #2 on: July 30, 2014, 05:45:34 AM »
I modified "/usr/bin/search.sh" and "/usr/bin/provides.sh" in TinyCore Linux 3.x to make its tcz package search function working. I integrated them into my Open Source Project MobileMate( http://www.learndiary.com/mobilemate/ ), which is customized based on TinyCore Linux 3.7.1.

The modified files below:

"/usr/bin/search.sh"
Code: (bash) [Select]
#!/bin/sh
# $1 is the search word(s)
[ -f "info.lst" ] && rm "info.lst"
touch "info.lst"
[ -z "$1" ] && exit 1
keyword=$1
[ "${keyword}" != "${keyword#/}" ] && keyword="^${keyword#/}"
[ "${keyword}" != "${keyword%/}" ] && keyword="${keyword%/}$"

read TCEDIR < /opt/.tce_dir
[ -z "${TCEDIR}" ] && TCEDIR="/tmp/tce"
if [ ! -d "${TCEDIR}" ]; then
  sudo mkdir "${TCEDIR}"
  sudo chown root:staff "${TCEDIR}"
fi
TCZSLST_GZ="${TCEDIR}/3.x_tczs.lst.gz"

if [ ! -f "${TCZSLST_GZ}" ]; then
  TCZSLST_S1="http://sourceforge.net/projects/mobilemate/files/0.1/3.x_tczs.lst.gz/download"
  TCZSLST_S2="http://www.learndiary.com/mobilemate/releases/0.1/3.x_tczs.lst.gz"
  echo "Downloading tcz packages list file..."
  wget -cq "${TCZSLST_S1}" -O "${TCZSLST_GZ}"
  if [ "$?" -ne "0" ]; then
    echo "Trying the next server..."
    wget -cq "${TCZSLST_S2}" -O "${TCZSLST_GZ}"
    if [ "$?" -ne "0" ]; then
      echo "Download tcz packages list file failed. Exit."
      exit 1
    fi
  fi
  echo "Downloaded tcz packages list file \"${TCZSLST_GZ}\" ok."
fi

zcat "${TCZSLST_GZ}" | grep -i "${keyword}" > info.lst
sed -i "s/\ *$/.tcz/g" info.lst

"/usr/bin/provides.sh"
Code: (bash) [Select]
#!/bin/sh
# $1 is the filename
[ -f "info.lst" ] && rm "info.lst"
touch "info.lst"
[ -z "$1" ] && exit 1
keyword=$1
read TCEDIR < /opt/.tce_dir
[ -z "${TCEDIR}" ] && TCEDIR="/tmp/tce"
if [ ! -d "${TCEDIR}" ]; then
  sudo mkdir "${TCEDIR}"
  sudo chown root:staff "${TCEDIR}"
fi
TCZSPLST_GZ="${TCEDIR}/3.x_tczs_provides.lst.gz"

if [ ! -f "${TCZSPLST_GZ}" ]; then
  TCZSPLST_S1="http://sourceforge.net/projects/mobilemate/files/0.1/3.x_tczs_provides.lst.gz/download"
  TCZSPLST_S2="http://www.learndiary.com/mobilemate/releases/0.1/3.x_tczs_provides.lst.gz"
  echo "Downloading tcz packages' files list file..."
  wget -cq "${TCZSPLST_S1}" -O "${TCZSPLST_GZ}"
  if [ "$?" -ne "0" ]; then
    echo "Trying the next server..."
    wget -cq "${TCZSPLST_S2}" -O "${TCZSPLST_GZ}"
    if [ "$?" -ne "0" ]; then
      echo "Download tcz packages' files list file failed. Exit."
      exit 1
    fi
  fi
  echo "Downloaded tcz packages' files list file \"${TCZSPLST_GZ}\" ok."
fi

zcat "${TCZSPLST_GZ}" | grep -i "$1" | while read line; do
  tcz=${line%%/*}
  files="/${line#*/}"
  [ -n "$(echo  "${files}" | grep -i "$1")" ] && echo "${tcz}" >> info.lst
done
sed -i "s/\ *$/.tcz/g" info.lst

A tip:
You can add "/" at the begin or the end of the search keyword to restrict the search scope.
« Last Edit: July 30, 2014, 05:51:27 AM by littlebat »