Zencafe Lokal Repositori
Kemaren waktu baca-baca di forum.linux.or.id, ada yang tanya bagaimana caranya membuat repositori lokal di Zencafe. Setelah semalaman bongkar-bongkar script netpkg akhirnya saya berhasil meng-edit script netpkg agar dapat digunakan untuk keperluan lokal repositori, jadi tidak perlu download-download lagi untuk proses instalasi programnya
Tahapan-tahapan yang perlu dilakukan untuk dapat menggunakan repositori secara lokal di Zencafe atau Zenwalk disini saya bagi menjadi 3 bagian yaitu :
- Pembuatan CD yang berisi kumpulan packages-packages
Proses pembuatan CD ini berfungsi untuk mempermudah penyebaran repositori dari Zencafe
(pernah dengar DVD Repositori-nya ubuntu kan ? Nah kita akan buat seperti itu) Untuk pembuatan CD Repositori ini tidak ada aturan-aturan khusus, tetapi yang perlu diperhatikan disini adalah file PACKAGES.TXT dan PACKAGES.TXT.gzOk, sekarang kita langsung saja ke langkah-langkah pembuatannya:
- Buatlah sebuah direktori untuk menampung packages-packages yang akan dijadikan sebagai repositori, sebagai contoh disini buatlah sebuah direktori OfflinePackages dan masukkanlah package-package yang ingin anda jadikan sebagai repositori kedalam direktori OfflinePackages hingga struktur direktorinya menjadi seperti dibawah ini:
123456789101112operatore[OfflinePackages]$ pwd/home/operatore/DATA_OPERATORE/Martinus/OfflinePackagesoperatore[OfflinePackages]$ ls -ltotal 0drwxr-xr-x 2 operatore users 216 2007-10-09 22:05 xapoperatore[OfflinePackages]$ ls -l xap/total 16600-rw-r--r-- 1 root root 107027 2007-06-20 02:09 bc-1.06-i486-46.1.tgz-rw-r--r-- 1 operatore users 4190618 2007-04-07 20:47 blogbridge-5.0.1.tgz-rwxr-xr-x 1 operatore users 4960683 2007-02-06 01:51 k3b-1.0rc5-i486-1kjz.tgz-rw-r--r-- 1 operatore users 7710157 2007-06-23 12:33 pidgin-2.0.0-i486-1zc1.tgzoperatore[OfflinePackages]$
Note: Anda dapat mengkategorikan packages-packages yang anda masukkan berdasarkan direktori-direktori standart Slackware, bisa juga tidak (tidak mengikuti aturan) - Setelah selesai, sekarang buatlah sebuah file bernama PACKAGES.TXT (ingat semuanya ditulis dalam huruf besar, tidak boleh tidak). File PACKAGES.TXT ini berfungsi sebagai metadata yang digunakan oleh netpkg untuk mendaftar packages-packages yang tersedia. Sedangkan isi dari file PACKAGES.TXT ini mempunyai aturan sebagai berikut:
PACKAGE NAME: Nama packages
PACKAGE LOCATION: Lokasi packages
PACKAGE SIZE (compressed): Ukuran packages dalam mode kompresi K
PACKAGE SIZE (uncompressed): Ukuran packages sebenarnya K
PACKAGE REQUIRED: Dependencies packages yang diperlukan jika ada
PACKAGE CONFLICTS: *Maap kurang tahu*
PACKAGE SUGGESTS: *Maap kurang tahu*
PACKAGE DESCRIPTION: Descripsi packages, taruh dibawah baris iniSedangkan contoh isi file PACKAGES.TXT punya saya adalah sebagai berikut :
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667PACKAGE NAME: bc-1.06-i486-46.1.tgzPACKAGE LOCATION: ./xapPACKAGE SIZE (compressed): ? KPACKAGE SIZE (uncompressed): ? KPACKAGE REQUIRED:PACKAGE CONFLICTS:PACKAGE SUGGESTS:PACKAGE DESCRIPTION:bc: bcbc:bc: This is sample configuration file for GNU/Linux Zencafebc: tutorial offline repository. Please use with your own riskbc: and don't complain to me if your data or your file is brokenbc:bc:bc:PACKAGE NAME: blogbridge-5.0.1.tgzPACKAGE LOCATION: ./xapPACKAGE SIZE (compressed): ? KPACKAGE SIZE (uncompressed): ? KPACKAGE REQUIRED:PACKAGE CONFLICTS:PACKAGE SUGGESTS:PACKAGE DESCRIPTION:blogbridge: blogbridgeblogbridge:blogbridge: This is sample configuration file for GNU/Linux Zencafeblogbridge: tutorial offline repository. Please use with your own riskblogbridge: and don't complain to me if your data or your file is brokenblogbridge:blogbridge:blogbridge:PACKAGE NAME: k3b-1.0rc5-i486-1kjz.tgzPACKAGE LOCATION: ./xapPACKAGE SIZE (compressed): ? KPACKAGE SIZE (uncompressed): ? KPACKAGE REQUIRED:PACKAGE CONFLICTS:PACKAGE SUGGESTS:PACKAGE DESCRIPTION:k3b: k3bk3b:k3b: This is sample configuration file for GNU/Linux Zencafek3b: tutorial offline repository. Please use with your own riskk3b: and don't complain to me if your data or your file is brokenk3b:k3b:k3b:PACKAGE NAME: pidgin-2.0.0-i486-1zc1.tgzPACKAGE LOCATION: ./xapPACKAGE SIZE (compressed): ? KPACKAGE SIZE (uncompressed): ? KPACKAGE REQUIRED:PACKAGE CONFLICTS:PACKAGE SUGGESTS:PACKAGE DESCRIPTION:pidgin: pidginpidgin:pidgin: This is sample configuration file for GNU/Linux Zencafepidgin: tutorial offline repository. Please use with your own riskpidgin: and don't complain to me if your data or your file is brokenpidgin:pidgin:pidgin:Untuk deskripsi package, bisa diambil di file slack-desc di setiap packages yang dimasukkan (Maap belum menemukan bagaimana cara meng-otomatisasi pembuatan file PACKAGES.TXT ini)
- Setelah itu simpanlah file PACKAGES.TXT diatas pada direktori OfflinePackages hingga struktur direktori OfflinePackages menjadi seperti dibawah ini:
1234567operatore[OfflinePackages]$ pwd/home/operatore/DATA_OPERATORE/Martinus/OfflinePackagesoperatore[OfflinePackages]$ ls -ltotal 4-rw-r--r-- 1 operatore users 1827 2007-10-10 23:59 PACKAGES.TXTdrwxr-xr-x 2 operatore users 216 2007-10-09 22:05 xapoperatore[OfflinePackages]$
- Setelah proses pembuatan file PACKAGES.TXT selesai, sekarang buatlah file PACKAGES.TXT.gz dengan cara seperti dibawah ini:
1234567891011operatore[OfflinePackages]$ lsPACKAGES.TXT xapoperatore[OfflinePackages]$ cp PACKAGES.TXT PACKAGES.TXT.1operatore[OfflinePackages]$ gzip -9 PACKAGES.TXToperatore[OfflinePackages]$ mv PACKAGES.TXT.1 PACKAGES.TXToperatore[OfflinePackages]$ ls -ltotal 8-rw-r--r-- 1 operatore users 1827 2007-10-11 00:59 PACKAGES.TXT-rw-r--r-- 1 operatore users 427 2007-10-10 23:59 PACKAGES.TXT.gzdrwxr-xr-x 2 operatore users 216 2007-10-09 22:05 xapoperatore[OfflinePackages]$
- Proses pembuatan CD repositori sudah hampir selesai, sekarang kita tinggal membuat file *.iso-nya kemudian mem-burningnya untuk kemudian disebarkan ke teman-teman atau kolega anda
Untuk membuat sebuah file *.iso, sekarang keluarlah dari direktori OfflinePackages dengan mengetikkan cd .. kemudian buatlah file iso dengan menjalankanlah perintah mkisofs -V ZC_OfflineRepository -J -r -o /home/operatore/DATA_OPERATORE/Martinus/Repos.iso /home/operatore/DATA_OPERATORE/Martinus/OfflinePackages/ seperti dibawah ini:
12345678910operatore[OfflinePackages]$ cd ..operatore[Martinus]$ mkisofs -V ZC_OfflineRepository -J -r -o /home/operatore/DATA_OPERATORE/Martinus/Repos.iso /home/operatore/DATA_OPERATORE/Martinus/OfflinePackages/59.08% done, estimate finish Thu Oct 11 01:08:02 2007Total translation table size: 0Total rockridge attributes bytes: 928Total directory bytes: 2048Path table size(bytes): 22Max brk space used 210008473 extents written (16 MB)operatore[Martinus]$
Nah sekarang file *.iso yang berisi kumpulan-kumpulan repository sudah siap untuk di burning ke dalam CD Blank atau CD kosong dan siap untuk di distribusikan
Sekarang mari kita lanjutkan ke proses berikutnya yaitu meng-konfigurasi agar netpkg dapat digunakan untuk keperluan offline
- Buatlah sebuah direktori untuk menampung packages-packages yang akan dijadikan sebagai repositori, sebagai contoh disini buatlah sebuah direktori OfflinePackages dan masukkanlah package-package yang ingin anda jadikan sebagai repositori kedalam direktori OfflinePackages hingga struktur direktorinya menjadi seperti dibawah ini:
- Konfigurasi netpkg untuk keperluan offline
Secara default, netpkg tidak di desain untuk dapat digunakan secara offline. Tetapi berhubung banyaknya teman-teman yang bertanya bagaimana agar netpkg bisa digunakan layaknya synaptic-nya ubuntu, maka sekarang mari kita mulai bermain-main dengan netpkg
Langkah-langkah yang perlu dilakukan agar netpkg dapat digunakan secara offline adalah :
- Konfigurasi pada file /etc/netpkg.conf
Untuk konfigurasi penggunaan repositori secara offline, penulisan pada file /etc/netpkg.conf ini saya menggunakan aturan sebagai berikut:1Internet_mirror = file:///mnt/cdromUntuk teman-teman yang tidak ingin terikat, bisa mengganti PATH-nya terserah keinginan sendiri asalkan harus menyertakan Internet_mirror = file:///
- Konfigurasi pada file /usr/libexec/netpkg-functions
Setelah konfigurasi pada file /etc/netpkg.conf selesai dilakukan, sekarang kita lakukan konfigurasi pada file /usr/libexec/netpkg-functions hingga menjadi seperti dibawah ini:123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595#!/bin/bash# Copyright Jean-Philippe Guillemin <jp.guillemin@free.fr>. This program is free software; you can redistribute# it and/or modify it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or (at your option)# any later version. Please take a look at http://www.gnu.org/copyleft/gpl.htm## Netpkg is a tool for easily install or upgrade packages via the network. With Netpkg,# you can make a minimal installation of Zenwalk Linux and install/upgrade just the# packages you need most.## Edited By Martinus Ady H <mrt.itnewbies@gmail.com>, for local repository usage.# Places this file in /usr/libexec/, before you do this please backup your# old netpkg-functions :)## ATTENTION...ATTENTION...ATTENTION...ATTENTION...# Please Read careffuly !!!# Please usage with your own risk and do not complain to me if your system# broken because this script.#################### Netpkg functions ###################### version="3.6"# fetch the packages list for available packagesgetpkglist(){cat $buffer/mainlist | sort | cut -d " " -f1}# fetch the packages list for package named $1findpackagebyname(){cut -d " " -f2 $buffer/pkglistfile | sed -n "s/^\($1-[^\-]*-[^\-]*-[^\-]*\.tgz\)$/\1/p"}# Get the category for package $1findcategorybypackage(){sed -n "s/^\([^ \t]*\)[ \t]*$1[ \t]*$/\1/p" $buffer/pkglistfile}# Build a list of installed packagesgetlocalpkglist(){ls $packagelogs | sed -n "s/^\(.*-[^\-]*-[^\-]*-[^\-]*\)$/\1\.tgz/p" 2>/dev/null > $buffer/localpkglist}# The main list <available> | <installed>getmainlist(){rm -f $buffer/mainlistlistbuilder -a $buffer/pkglistfile -i $buffer/localpkglist | sort > $buffer/mainlistselector="$(cat $buffer/last_selector)"selector="${selector:=a}"vfilter -${selector} -f $buffer/mainlist > $buffer/Ileftlist}# Download and process the meta filegetmeta(){mirror="$(cat $buffer/last_mirror)"echo "Cleaning cache"rm -f $buffer/descfilerm -f $buffer/pkglistfilerm -f $buffer/PACKAGES.TXT*echo "Connecting to mirror"# if mirror in local filesystem, use copy other than wget, because wget not# supported file:/// protocolif [ "$(echo $mirror | egrep 'file:///')" ] ; then# prepare one variabel to use offline repositorymartinrepo=`cat $buffer/last_mirror | awk -F:// '{ print $2 }'`echo "Offline mirror detected, switch to other process for getting offline packages metadata"echo "Checking offline repository metadata ......"if [ -f $martinrepo/PACKAGES.TXT ] ; thenecho "Pointing repository from $martinrepo"cp $martinrepo/PACKAGES.TXT $buffer/PACKAGES.TXTelseecho -en '\E[31m'"\033[1mMetadata not found in $mirror ..\033[0m\n"echo -en '\E[31m'"\033[1mPlease mounting first offline repository, then reconfigure your /etc/netpkg.conf\033[0m\n"echo -en '\E[31m'"\033[1mand running netpkg again. Quiting ... \033[0m\n"exit 1;fi # end ifelseneterror=$($WGET -O $buffer/PACKAGES.TXT.gz $mirror/PACKAGES.TXT.gz 2>&1 | grep -E "failed:|Not Found")if [ "$neterror" ] ; thenneterror=$($WGET -O $buffer/PACKAGES.TXT $mirror/PACKAGES.TXT 2>&1 | grep -E "failed:|Not Found")if [ "$neterror" ] ; thenecho "Unable to connect to $mirror, please check the network or choose another mirror"return 1fielseecho "Uncompressing meta information"if ! gunzip -f $buffer/PACKAGES.TXT.gz 2>/dev/null ; thenecho "Unable to extract meta information, please check the network or choose another mirror"return 1fi # end iffi # end elsefi # end elseecho "Computing packages dependencies"if [ "$dependencies" = "yes" ] ; thensed -n '/^PACKAGE NAME:.*/{N;N;N;Ns/,/ /gs/^PACKAGE NAME:[ \t]*\(.*\)-[^-]*-[^-]*-[^-]*\.tgz[ \t]*\n.*\nPACKAGE SIZE (compressed):[ \t]*\(.*\)\nPACKAGE SIZE (uncompressed):[ \t]*\(.*\)\nPACKAGE REQUIRED:[ \t]*\(.*\)/\1:\4/p}' \$buffer/PACKAGES.TXT > $buffer/depfilefiecho "Computing packages descriptions"sed -n '/^PACKAGE NAME:.*/{N;N;N;N;N;N;N;Ns/^PACKAGE NAME:[ \t]*\(.*\)-[^-]*-[^-]*-[^-]*\.tgz[ \t]*\n.*\nPACKAGE SIZE (compressed):[ \t]*\(.*\)\nPACKAGE SIZE (uncompressed):[ \t]*\(.*\)\nPACKAGE REQUIRED:[ \t]*\(.*\)\n.*\n.*\n.*\n[^ \t]*:[ \t]*\(.*\)/\1: Description : \5\n\1: Compressed : \2\n\1: Uncompressed : \3\n\1: Dependencies : \4/p}' $buffer/PACKAGES.TXT > $buffer/descfileecho "Creating packages list"sed -n '/^PACKAGE NAME:.*/{Ns/^PACKAGE NAME:[ \t]*\(.*\.tgz\)[ \t]*\nPACKAGE LOCATION:[ \t]*\(\.\/\)\?\(.*\)/\3 \1/p}' $buffer/PACKAGES.TXT > $buffer/pkglistfileecho "Getting local packages list"getlocalpkglistecho "Computing packages status"getmainlist# Generating a reportecho "Synchronization with $mirror successful"}# take a look at local packages list to see which version of the $1 package installedcheckinstalled(){sed -n "s/^\($1-[^\-]*-[^\-]*-[^\-]*\.tgz\)$/\1/p" $buffer/localpkglist}# Download ($category $package)download(){mirror="$(cat $buffer/last_mirror)"# change mirror into localif [ "$(echo $mirror | egrep 'file:///')" ] ; thenmartinrepo=`cat $buffer/last_mirror | awk -F:// '{ print $2 }'`mirror=$martinrepofiif [[ -e $local/$1/$2 && "$(gzip -tv $local/$1/$2 2>&1 | egrep -e OK$)" ]]; thenecho "Nothing to do, $2 is already in local cache"returnelsemkdir -p $local/$1 2>/dev/nullrm -f $local/$1/$2 2>/dev/null# Detect if mirror in local filesystemif [ ! "$( echo "$mirror" | egrep -e "ftp:.*|http:.*" )" ] ; thenecho "Copying $2"cp $mirror/$1/$2 $local/$1/$2echo "'$local/$1/$2' (saved)"elseecho "Downloading $2"# we need to get an encoded URL if anyurl=$($WGET -O- -q $mirror/$1/ \| grep ".*\.tgz<\/[a|A]>" \| grep "$2" \| sed -e "s/^.*<\(a\|A\) \(href\|HREF\)=\"\(.*\.tgz\)\">.*/\3/")# check if we have got an absolute URL :(if [ $( echo "$url" | egrep -e "ftp:.*|http:.*" ) ]; then$WGET -c -O $local/$1/$2 $urlelse$WGET -c -O $local/$1/$2 $mirror/$1/$urlfi # end iffi # end iffi # end if}# Checks for configuration files to update.checkdotnew() {actionlist="differences yes no remove"echo "Checking for configuration files to update..."dotnewlist="$(find /etc -name "*.new")"if [ "$dotnewlist" ] ; thenfor file in $dotnewlist ; doorigfile="$(echo $file|sed -e 's/.new//')"[ "$(echo $untouchable | grep $origfile)" ] && continueecho "Should we move $file to $origfile ?"select action in $actionlist ; docase $action indifferences)if [ -e $origfile ] ; thendiff -dU 1 $origfile $file | mostelseecho "$file is the only one, no $origfile yet"fi;;yes)mv -fi $file $origfilebreak;;no)break;;remove)rm -i $filebreak;;esacdonedoneelseecho "No \".new\" configuration files on the system"fi}# Choose a download location from mirrors available in config filechoosemirror(){echo "Please choose a mirror :"select newmirror in $mirrors_list ;do[ "$newmirror" ] && mirror="$newmirror"breakdone# Entry format checking NB: Edited n added file:/// protocol for local# repository. Use with your own risk :)if [ ! "$(echo $mirror | egrep 'http://|ftp://|file:///')" ] ; then[ "$mirror" ] && echo -en '\E[31m'"\033[1mBad syntax in url to mirror $mirror\033[0m"elseecho "$mirror" > $buffer/last_mirrormirrorhash="$(echo "$mirror" | md5sum | cut -d " " -f 1)"mkdir -p $bufferfiecho ""echo -en '\E[36m'"\033[1mFrom now current mirror is : $mirror\033[0m"echo ""# Refresh meta information databasegetmeta}# prompt for action (install / upgrade / reinstall / download) for a list of packages ($1) #########################promptaction(){echo# this variable will track for packages installed as dependeciesprocessedlist=''for pattern in $1; donetpkglist="$(getpkglist | grep "$pattern")"if [ ! "$netpkglist" ] ; thenecho "Package ~ $pattern : not found"continuefifor package in $netpkglist ; do# If we find the package in this list then it is already processed[ "$(echo "$processedlist" | grep "$package")" ] && continue# We need to find the category for $packagecategory=$(findcategorybypackage $package)# the software namesoftname=${package%-*}; softname=${softname%-*}; softname=${softname%-*}# take a look in pkgtool logs to see if we have got it installedinstalledpkg="$(checkinstalled $softname)"if [ -e $packagelogs/${package%%.tgz} ]; thenecho "[I][$category] Found installed $package on the repository"actionname="reinstall"elif [ "$installedpkg" ]; thenif [ "$(vfilter -u -f $buffer/mainlist -q $package)" ]; thenecho -en '\E[31m'"\033[1m[U][$category]\033[0m"echo -n " Found updated "echo -en '\E[31m'"\033[1m$package\033[0m"echo " on the repository : $installedpkg is installed"elif [ "$(vfilter -d -f $buffer/mainlist -q $package)" ]; thenecho -en '\E[32m'"\033[1m[D][$category]\033[0m"echo -n " Found downgraded "echo -en '\E[32m'"\033[1m$package\033[0m"echo " on the repository : $installedpkg is installed"fiactionname="upgrade"elseecho -en '\E[36m'"\033[1m[N][$category]\033[0m"echo -n " Found "echo -en '\E[36m'"\033[1m$package\033[0m"echo " on the repository : not installed"actionname="install"fiactionlist="$actionname download skip"echo " what should I do ?"select action in $actionlist ; docase $action in"install" | "reinstall" | "upgrade" )PROMPT=1autoinstall $packagePROMPT=0break;;download)download $category $packagebreak;;skip)echo "Skipping package [$category]$package"echobreakesacdonedonedone}# Check deps , then Install / Reinstall / Upgrade a list of packages# The full and exact package name MUST be providedautoinstall() {foundblacky="0"if [ "$1" ]; thenfinallist=''# We need an up to date list of installed packagesgetlocalpkglistfor package in $1 ; do# the software namesoftname=${package%-*}; softname=${softname%-*}; softname=${softname%-*}# This package has now been processedprocessedlist="${processedlist} $package"# take a look in the blacklistfor blacky in $blacklist ; doif [ "$blacky" = "$softname" ]; thenecho "$package is blacklisted : skipping"foundblacky="1"breakfidoneif [ "$foundblacky" = "1" ] ; thenfoundblacky="0"continuefifinallist="${finallist} $package"[ ! "$dependencies" = "yes" ] && continuedeps="$(grep "^$softname:.*$" $buffer/depfile | cut -s -d ":" -f 2-)"[ ! "$deps" ] && continuefor dep in $deps ; do# We need to find package for $dep ($dep is the short name)deppackage="$(sed -n "s/^.*[ \t]\($dep-[^\-]*-[^\-]*-[^\-]*.tgz\)[ \t]*$/\1/p" $buffer/pkglistfile)"[ ! "$deppackage" ] && continue# If it is already in the list, then skip[ "$(echo $finallist | grep "$deppackage" )" ] && continue# Do we have it installed ? then skip[ -e $packagelogs/${deppackage%%.tgz} ] && continue# Is it a downgrade ? then skip[ "$(vfilter -d -f $buffer/mainlist -q $deppackage)" ] && continue# This package has now been processedprocessedlist="${processedlist} $deppackage"# take a look in the blacklistfor blacky in $blacklist ; doif [ "$blacky" = "$dep" ]; thenfoundblacky="1"breakfidoneif [ "$foundblacky" = "1" ] ; thenfoundblacky="0"continuefiif [ "$PROMPT" = "1" ] ; thenecho "$deppackage is required by $package : do you want to install this dependency package ?"select action in yes skip ; docase $action inyes)finallist="${finallist} $deppackage"break;;skip)breakesacdonecontinuefifinallist="${finallist} $deppackage"donedonefor package in $finallist ; do# We need to find the category for $packagecategory=$(findcategorybypackage $package)# the software namesoftname=${package%-*}; softname=${softname%-*}; softname=${softname%-*}# take a look in pkgtool logs to see if we have got it installedinstalledpkg="$(checkinstalled $softname)"# download the package if neededdownload $category $package# check package integrityif [ ! "$(gzip -tv $local/$category/$package 2>&1 | egrep -e OK$)" ]; thenecho "$package is corrupted, please checkout another mirror : skipping"rm -f $local/$category/$package 2>/dev/nullcontinuefiif [ -e $packagelogs/${package%%.tgz} ]; thenecho -n "Reinstalling"echo -e '\E[36m'"\033[1m [$category]$package\033[0m"upgradepkg --reinstall $local/$category/$packageelif [ "$(vfilter -u -f $buffer/mainlist -q $package)" ]; thenecho -n "Upgrading"echo -e '\E[31m'"\033[1m [$category]$package\033[0m"upgradepkg $local/$category/$packageelif [ "$(vfilter -d -f $buffer/mainlist -q $package)" ]; thenecho -n "Downgrading"echo -e '\E[32m'"\033[1m [$category]$package\033[0m"upgradepkg $local/$category/$packageelseecho -n "Installing"echo -e '\E[36m'"\033[1m [$category]$package\033[0m"installpkg $local/$category/$packagefi# remove package if we don nott want to keep itif [ ! "$keepit" = "yes" ]; thenrm -f $local/$category/$package 2>/dev/nullfi# We need an up to date list of installed packagesgetlocalpkglistdonefi}# getall ###############################################getall() {echo "Connecting to the packages repository..."echofor package in $(getpkglist) ; doif [ "$package" ]; then# We need to find the category for $packagecategory=$(findcategorybypackage $package)download $category $packagefidone}# upgrade the whole system ###############################################upgradeall() {foundblacky="0"echo "You are about to upgrade the whole system : are you sure ?"select action in "yes" "abort" ; docase $action inyes)echo "Connecting to the packages repository..."echofor package in $(getpkglist) ; doif [ "$package" ]; then# We need to find the category for $packagecategory=$(findcategorybypackage $package)# the software namesoftname=${package%-*}; softname=${softname%-*}; softname=${softname%-*}# take a look in pkgtool logs to see if we have got it installedinstalledpkg="$(checkinstalled $softname)"if [ -e $packagelogs/${package%%.tgz} ]; thenecho "Found [$category]$package on the repository : already installed : skipping"continueelif [ -n "$installedpkg" ]; then# take a look in the blacklistfor blacky in $blacklist ; doif [ "$blacky" = "$softname" ]; thenecho "Found [$category]$package on the repository : blacklisted : skipping"foundblacky="1"breakfidoneif [ "$foundblacky" = "1" ] ; thenfoundblacky="0"continuefiif [ "$(vfilter -u -f $buffer/mainlist -q $package)" ]; then# If we reached this point then this package needs to be upgradedecho -n "Found "echo -en '\E[31m'"\033[1m[$category]$package\033[0m"echo " on the repository : $installedpkg is installed : upgrading"autoinstall $packagefielseecho "Found [$category]$package on the repository : not installed : skipping"fifidonebreak;;abort)exit 0esacdone}# list packages from repository #########################listall() {netpkglist="$(getpkglist)"[ ! "$netpkglist" ] && echo -e '\E[31m'"\033[1mFound no package on $mirror\033[0m"for package in $netpkglist ; do# We need to find the category for $packagecategory=$(findcategorybypackage $package)# the software namesoftname=${package%-*}; softname=${softname%-*}; softname=${softname%-*}# take a look in pkgtool logs to see if we have got it installedinstalledpkg="$(checkinstalled $softname)"if [ -e $packagelogs/${package%%.tgz} ]; thenif [ -n "$(echo "$1" | grep 'I')" ]; thenecho "[I][$category] Found installed $package on the repository"fielif [ -n "$installedpkg" ]; thenif [ -n "$(echo "$1" | grep 'U')" ]; thenif [ "$(vfilter -u -f $buffer/mainlist -q $package)" ]; thenecho -en '\E[31m'"\033[1m[U][$category]\033[0m"echo -n " Found updated "echo -en '\E[31m'"\033[1m$package\033[0m"echo " on the repository : $installedpkg is installed"fifiif [ -n "$(echo "$1" | grep 'D')" ]; thenif [ "$(vfilter -d -f $buffer/mainlist -q $package)" ]; thenecho -en '\E[32m'"\033[1m[D][$category]\033[0m"echo -n " Found downgraded "echo -en '\E[32m'"\033[1m$package\033[0m"echo " on the repository : $installedpkg is installed"fifielseif [ -n "$(echo "$1" | grep 'N')" ]; thenecho -en '\E[36m'"\033[1m[N][$category]\033[0m"echo -n " Found "echo -en '\E[36m'"\033[1m$package\033[0m"echo " on the repository : not installed"fifidone}
Setelah melakukan pengeditan pada file /usr/libexec/netpkg-functions selesai, simpanlah hasil editan tersebut kemudian sekarang waktunya untuk mulai menggunakan repositori lokal bikinan sendiri
- Konfigurasi pada file /etc/netpkg.conf
- Menggunakan lokal repositori bikinan sendiri
Hmm… semuanya sudah siap rasanya, sekarang untuk mengetesnya masukkanlah CD repositori yang telah dilakukan pada langkah diatas ke dalam cdrom. Jika file iso-nya belum diburning, buatlah dahulu mount-point pada direktori /mnt dengan mengetikkan perintahmkdir /mnt/cdrom kemudian jalankanlah perintah mount -t iso9660 -o loop Repos.iso /mnt/cdrom seperti dibawah ini agar Zencafe membaca isi file Repo.iso layaknya membaca dari CDROM:
12345root[Martinus]# mkdir /mnt/cdromroot[Martinus]# mount -t iso9660 -o loop Repos.iso /mnt/cdromroot[Martinus]# ls /mnt/cdromPACKAGES.TXT PACKAGES.TXT.gz xaproot[Martinus]#Setelah melakukan proses seperti diatas, sekarang jalankanlah netpkg mirror untuk memilih mirror lokal yang telah anda konfigurasi pada file /etc/netpkg.conf ( untuk lokal mirror ditandai dengan file:///path/mirror/) seperti dibawah ini:
12345678910111213141516171819202122232425262728293031323334root[Martinus]# netpkg mirrorPlease choose a mirror :1) http://slackware.linux.or.id/pub/zencafe/i486/zencafe-1.02) http://distro.ibiblio.org/pub/linux/distributions/zenwalk/i486/current3) http://zen-repo.meticul.eu/i486/current4) http://mirror.meleeweb.net/pub/linux/zenwalk/i486/current5) http://ftp.nux.ipb.pt/pub/dists/zenwalk/i486/current6) http://ftp.sh.cvut.cz/MIRRORS/zenwalk/i486/current7) file:///mnt/cdrom8) http://linuxpackages.telecoms.bg/Zenwalk9) http://mirrors.unixsol.org/linuxpackages//Zenwalk10) http://linuxpackages.inode.at/Zenwalk11) http://www.software-mirror.com/linuxpackages/Zenwalk12) http://ftp.scarlet.be/pub/linuxpackages/Zenwalk13) ftp://ftp.slackware.hu/linuxpackages/Zenwalk14) http://slackware.mirrors.tds.net/pub/slackware/slackware-current/slackware15) http://www.tuxgames.net/zenwalk16) http://users.zenwalk.org/packages#? 7From now current mirror is : file:///mnt/cdromCleaning cacheConnecting to mirrorOffline mirror detected, switch to other process for getting offline packages metadataChecking offline repository metadata ......Pointing repository from /mnt/cdromComputing packages dependenciesComputing packages descriptionsCreating packages listGetting local packages listComputing packages statusSynchronization with file:///mnt/cdrom successfulCleaning temporary files and saving meta informationroot[Martinus]#Ok proses sinkronisasi antara mirror lokal yang ada di CDROM dan netpkg telah berhasil dilakukan, sekarang mari kita cek packages-packages apa saja yang terdapat pada mirror lokal ini dengan cara mengetikkan perintah netpkg list seperti gambar dibawah ini:
123456root[Martinus]# netpkg list[N][xap] Found bc-1.06-i486-46.1.tgz on the repository : not installed[N][xap] Found k3b-1.0rc5-i486-1kjz.tgz on the repository : not installed[I][xap] Found installed pidgin-2.0.0-i486-1zc1.tgz on the repositoryCleaning temporary files and saving meta informationroot[Martinus]#Hurray.. semua packages yang terdapat pada file *.iso telah dikenali, sekarang mari kita coba instal salah satu packages dari repositori lokal yang telah kita buat dengan mengetikkan perintah netpkg nama_packages.tgz seperti dibawah ini:
123456789101112131415161718192021root[Martinus]# netpkg bc-1.06-i486-46.1.tgz[N][xap] Found bc-1.06-i486-46.1.tgz on the repository : not installedwhat should I do ?1) install2) download3) skip#? 1Nothing to do, bc-1.06-i486-46.1.tgz is already in local cacheInstalling [xap]bc-1.06-i486-46.1.tgzInstalling package bc-1.06-i486-46.1...PACKAGE DESCRIPTION:bc: bc is an arbitrary precision calculator language.bc:bc: It allows one to write and execute simple or complex programsbc: to do calculations using arbitrary precision real numbers.bc:bc:Cleaning temporary files and saving meta informationroot[Martinus]#Mari kita cek, apakah packages bc tersebut benar-benar telah terinstal pada sitem kita dengan mengetikkan perintah ls /var/log/packages dan untuk pembuktian kita coba jalankan perintah bc tersebut seperti dibawah ini:
12345678910111213root[Martinus]# ls /var/log/packages | grep bcbc-1.06-i486-46.1glibc-2.3.6-i486-2z40libcroco-0.6.1-i486-1z28root[Martinus]# bcbc 1.06Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.This is free software with ABSOLUTELY NO WARRANTY.For details type `warranty'.(interrupt) use quit to exit.quitroot[Martinus]#
Ihuiiiiiiii…. sukses sekarang kita dapat menggunakan repositori lokal seperti layaknya teman-teman komunitas ubuntu
Referensi:
- Download netpkg_repos_lokal.tar.bz2
- Manual Page Bash
- Manual Page AWK
- Manual Page Grep
|
1 2 3 4 5 6 7 8 9 |
# ATTENTION...ATTENTION...ATTENTION...ATTENTION... # Please Read careffuly !!! # Please usage with your own risk and do not complain to me if your system broken because this script. # This feature maybe available by default in GNU/Linux Zencafe next release ?? # but if you wanna use this script in Zencafe 1.0 or Zencafe 1.2, you can download the # netpkg_repos_lokal.tar.bz2 and uncompress the file in to your local directory then put netpkg-functions # in your /usr/libexec/ directory. # # Note: Please backup first your old netpkg-functions |
Om Martin
warnet saya udah upgrade to zencafe 2.0 tapi begitu mo pakai YM kok selalu disconnect ya..?
minta ilmunya dong
terima kacih..