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 :

  1. 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.gz

    Ok, 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:
      operatore[OfflinePackages]$ pwd
      /home/operatore/DATA_OPERATORE/Martinus/OfflinePackages
      operatore[OfflinePackages]$ ls -l
      total 0
      drwxr-xr-x 2 operatore users 216 2007-10-09 22:05 xap
      operatore[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.tgz
      operatore[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 ini

      Sedangkan contoh isi file PACKAGES.TXT punya saya adalah sebagai berikut :

      PACKAGE NAME:  bc-1.06-i486-46.1.tgz
      PACKAGE LOCATION:  ./xap
      PACKAGE SIZE (compressed):  ? K
      PACKAGE SIZE (uncompressed):  ? K
      PACKAGE REQUIRED:
      PACKAGE CONFLICTS:
      PACKAGE SUGGESTS:
      PACKAGE DESCRIPTION:
      bc: bc
      bc:
      bc: This is sample configuration file for GNU/Linux Zencafe
      bc: tutorial offline repository. Please use with your own risk
      bc: and don't complain to me if your data or your file is broken
      bc:
      bc:
      bc:
       
      PACKAGE NAME:  blogbridge-5.0.1.tgz
      PACKAGE LOCATION:  ./xap
      PACKAGE SIZE (compressed):  ? K
      PACKAGE SIZE (uncompressed):  ? K
      PACKAGE REQUIRED:
      PACKAGE CONFLICTS:
      PACKAGE SUGGESTS:
      PACKAGE DESCRIPTION:
      blogbridge: blogbridge
      blogbridge:
      blogbridge: This is sample configuration file for GNU/Linux Zencafe
      blogbridge: tutorial offline repository. Please use with your own risk
      blogbridge: and don't complain to me if your data or your file is broken
      blogbridge:
      blogbridge:
      blogbridge:
       
      PACKAGE NAME:  k3b-1.0rc5-i486-1kjz.tgz
      PACKAGE LOCATION:  ./xap
      PACKAGE SIZE (compressed):  ? K
      PACKAGE SIZE (uncompressed):  ? K
      PACKAGE REQUIRED:
      PACKAGE CONFLICTS:
      PACKAGE SUGGESTS:
      PACKAGE DESCRIPTION:
      k3b: k3b
      k3b:
      k3b: This is sample configuration file for GNU/Linux Zencafe
      k3b: tutorial offline repository. Please use with your own risk
      k3b: and don't complain to me if your data or your file is broken
      k3b:
      k3b:
      k3b:
       
      PACKAGE NAME:  pidgin-2.0.0-i486-1zc1.tgz
      PACKAGE LOCATION:  ./xap
      PACKAGE SIZE (compressed):  ? K
      PACKAGE SIZE (uncompressed):  ? K
      PACKAGE REQUIRED:
      PACKAGE CONFLICTS:
      PACKAGE SUGGESTS:
      PACKAGE DESCRIPTION:
      pidgin: pidgin
      pidgin:
      pidgin: This is sample configuration file for GNU/Linux Zencafe
      pidgin: tutorial offline repository. Please use with your own risk
      pidgin: and don't complain to me if your data or your file is broken
      pidgin:
      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:
      operatore[OfflinePackages]$ pwd
      /home/operatore/DATA_OPERATORE/Martinus/OfflinePackages
      operatore[OfflinePackages]$ ls -l
      total 4
      -rw-r--r-- 1 operatore users 1827 2007-10-10 23:59 PACKAGES.TXT
      drwxr-xr-x 2 operatore users  216 2007-10-09 22:05 xap
      operatore[OfflinePackages]$
      
    • Setelah proses pembuatan file PACKAGES.TXT selesai, sekarang buatlah file PACKAGES.TXT.gz dengan cara seperti dibawah ini:
      operatore[OfflinePackages]$ ls
      PACKAGES.TXT  xap
      operatore[OfflinePackages]$ cp PACKAGES.TXT PACKAGES.TXT.1
      operatore[OfflinePackages]$ gzip -9 PACKAGES.TXT
      operatore[OfflinePackages]$ mv PACKAGES.TXT.1 PACKAGES.TXT
      operatore[OfflinePackages]$ ls -l
      total 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.gz
      drwxr-xr-x 2 operatore users  216 2007-10-09 22:05 xap
      operatore[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:
      operatore[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 2007
      Total translation table size: 0
      Total rockridge attributes bytes: 928
      Total directory bytes: 2048
      Path table size(bytes): 22
      Max brk space used 21000
      8473 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 :)

  2. 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:

      Internet_mirror = file:///mnt/cdrom

      Untuk 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:

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      89
      90
      91
      92
      93
      94
      95
      96
      97
      98
      99
      100
      101
      102
      103
      104
      105
      106
      107
      108
      109
      110
      111
      112
      113
      114
      115
      116
      117
      118
      119
      120
      121
      122
      123
      124
      125
      126
      127
      128
      129
      130
      131
      132
      133
      134
      135
      136
      137
      138
      139
      140
      141
      142
      143
      144
      145
      146
      147
      148
      149
      150
      151
      152
      153
      154
      155
      156
      157
      158
      159
      160
      161
      162
      163
      164
      165
      166
      167
      168
      169
      170
      171
      172
      173
      174
      175
      176
      177
      178
      179
      180
      181
      182
      183
      184
      185
      186
      187
      188
      189
      190
      191
      192
      193
      194
      195
      196
      197
      198
      199
      200
      201
      202
      203
      204
      205
      206
      207
      208
      209
      210
      211
      212
      213
      214
      215
      216
      217
      218
      219
      220
      221
      222
      223
      224
      225
      226
      227
      228
      229
      230
      231
      232
      233
      234
      235
      236
      237
      238
      239
      240
      241
      242
      243
      244
      245
      246
      247
      248
      249
      250
      251
      252
      253
      254
      255
      256
      257
      258
      259
      260
      261
      262
      263
      264
      265
      266
      267
      268
      269
      270
      271
      272
      273
      274
      275
      276
      277
      278
      279
      280
      281
      282
      283
      284
      285
      286
      287
      288
      289
      290
      291
      292
      293
      294
      295
      296
      297
      298
      299
      300
      301
      302
      303
      304
      305
      306
      307
      308
      309
      310
      311
      312
      313
      314
      315
      316
      317
      318
      319
      320
      321
      322
      323
      324
      325
      326
      327
      328
      329
      330
      331
      332
      333
      334
      335
      336
      337
      338
      339
      340
      341
      342
      343
      344
      345
      346
      347
      348
      349
      350
      351
      352
      353
      354
      355
      356
      357
      358
      359
      360
      361
      362
      363
      364
      365
      366
      367
      368
      369
      370
      371
      372
      373
      374
      375
      376
      377
      378
      379
      380
      381
      382
      383
      384
      385
      386
      387
      388
      389
      390
      391
      392
      393
      394
      395
      396
      397
      398
      399
      400
      401
      402
      403
      404
      405
      406
      407
      408
      409
      410
      411
      412
      413
      414
      415
      416
      417
      418
      419
      420
      421
      422
      423
      424
      425
      426
      427
      428
      429
      430
      431
      432
      433
      434
      435
      436
      437
      438
      439
      440
      441
      442
      443
      444
      445
      446
      447
      448
      449
      450
      451
      452
      453
      454
      455
      456
      457
      458
      459
      460
      461
      462
      463
      464
      465
      466
      467
      468
      469
      470
      471
      472
      473
      474
      475
      476
      477
      478
      479
      480
      481
      482
      483
      484
      485
      486
      487
      488
      489
      490
      491
      492
      493
      494
      495
      496
      497
      498
      499
      500
      501
      502
      503
      504
      505
      506
      507
      508
      509
      510
      511
      512
      513
      514
      515
      516
      517
      518
      519
      520
      521
      522
      523
      524
      525
      526
      527
      528
      529
      530
      531
      532
      533
      534
      535
      536
      537
      538
      539
      540
      541
      542
      543
      544
      545
      546
      547
      548
      549
      550
      551
      552
      553
      554
      555
      556
      557
      558
      559
      560
      561
      562
      563
      564
      565
      566
      567
      568
      569
      570
      571
      572
      573
      574
      575
      576
      577
      578
      579
      580
      581
      582
      583
      584
      585
      586
      587
      588
      589
      590
      591
      592
      593
      594
      595
      
      #!/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 packages
      getpkglist(){
        cat $buffer/mainlist | sort | cut -d " " -f1
      }
       
      # fetch the packages list for package named $1
      findpackagebyname(){
        cut -d " " -f2 $buffer/pkglistfile | sed -n "s/^\($1-[^\-]*-[^\-]*-[^\-]*\.tgz\)$/\1/p"
      }
       
      # Get the category for package $1
      findcategorybypackage(){
        sed -n "s/^\([^ \t]*\)[ \t]*$1[ \t]*$/\1/p" $buffer/pkglistfile
      }
       
      # Build a list of installed packages
      getlocalpkglist(){
      	ls $packagelogs | sed -n "s/^\(.*-[^\-]*-[^\-]*-[^\-]*\)$/\1\.tgz/p"  2>/dev/null > $buffer/localpkglist
      }
       
      # The main list <available> | <installed>
      getmainlist(){
      	rm -f $buffer/mainlist
      	listbuilder -a $buffer/pkglistfile -i $buffer/localpkglist | sort > $buffer/mainlist
      	selector="$(cat $buffer/last_selector)"
      	selector="${selector:=a}"
      	vfilter -${selector} -f $buffer/mainlist > $buffer/Ileftlist
      }
       
      # Download and process the meta file
      getmeta(){
       
      	mirror="$(cat $buffer/last_mirror)"
      	echo "Cleaning cache"
      	rm -f $buffer/descfile
      	rm -f $buffer/pkglistfile
      	rm -f $buffer/PACKAGES.TXT*
       
      	echo "Connecting to mirror"
       
      	# if mirror in local filesystem, use copy other than wget, because wget not
      	# supported file:/// protocol
      	if [ "$(echo $mirror | egrep 'file:///')" ] ; then
      		# prepare one variabel to use offline repository
      		martinrepo=`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 ] ; then
      			echo "Pointing repository from $martinrepo"
      			cp $martinrepo/PACKAGES.TXT $buffer/PACKAGES.TXT
      		else
      			echo -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 if
      	else
      		neterror=$($WGET -O $buffer/PACKAGES.TXT.gz $mirror/PACKAGES.TXT.gz 2>&1 | grep -E "failed:|Not Found")
       
      		if [ "$neterror" ] ; then
      			neterror=$($WGET -O $buffer/PACKAGES.TXT $mirror/PACKAGES.TXT 2>&1 | grep -E "failed:|Not Found")
      			if [ "$neterror" ] ; then
      				echo "Unable to connect to $mirror, please check the network or choose another mirror"
      				return 1
      			fi
      		else
      			echo "Uncompressing meta information"
      			if ! gunzip -f $buffer/PACKAGES.TXT.gz 2>/dev/null ; then
      				echo "Unable to extract meta information, please check the network or choose another mirror"
      				return 1
      			fi # end if
      		fi # end else
      	fi # end else
       
      	echo "Computing packages dependencies"
      	if [ "$dependencies" = "yes" ] ; then
      		sed -n '
      		/^PACKAGE NAME:.*/{
      			N;N;N;N
      			s/,/ /g
      			s/^PACKAGE NAME:[ \t]*\(.*\)-[^-]*-[^-]*-[^-]*\.tgz[ \t]*\n.*\nPACKAGE SIZE (compressed):[ \t]*\(.*\)\nPACKAGE SIZE (uncompressed):[ \t]*\(.*\)\nPACKAGE REQUIRED:[ \t]*\(.*\)/\1:\4/p
      		}' \
      		$buffer/PACKAGES.TXT > $buffer/depfile
      	fi
       
      	echo "Computing packages descriptions"
      	sed -n '
      	/^PACKAGE NAME:.*/{
      		N;N;N;N;N;N;N;N
      		s/^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/descfile
       
      	echo "Creating packages list"
      	sed -n '
      	/^PACKAGE NAME:.*/{
      		N
      		s/^PACKAGE NAME:[ \t]*\(.*\.tgz\)[ \t]*\nPACKAGE LOCATION:[ \t]*\(\.\/\)\?\(.*\)/\3 \1/p
      	}' $buffer/PACKAGES.TXT > $buffer/pkglistfile
       
      	echo "Getting local packages list"
      	getlocalpkglist
       
      	echo "Computing packages status"
      	getmainlist
       
      	# Generating a report
      	echo "Synchronization with $mirror successful"
      }
       
      # take a look at local packages list to see which version of the $1 package installed
      checkinstalled(){
      	sed -n "s/^\($1-[^\-]*-[^\-]*-[^\-]*\.tgz\)$/\1/p" $buffer/localpkglist
      }
       
      # Download ($category $package)
      download(){
       
      	mirror="$(cat $buffer/last_mirror)"
       
      	# change mirror into local
      	if [ "$(echo $mirror | egrep 'file:///')" ] ; then
      		martinrepo=`cat $buffer/last_mirror | awk -F:// '{ print $2 }'`
      		mirror=$martinrepo
      	fi
       
      	if [[ -e $local/$1/$2 && "$(gzip -tv $local/$1/$2 2>&1 | egrep -e OK$)" ]]; then
      		echo "Nothing to do, $2 is already in local cache"
      		return
      	else
      		mkdir -p $local/$1 2>/dev/null
      		rm -f $local/$1/$2 2>/dev/null
       
      		# Detect if mirror in local filesystem
      		if [ ! "$( echo "$mirror" | egrep -e "ftp:.*|http:.*" )" ] ; then
      			echo "Copying $2"
      			cp $mirror/$1/$2  $local/$1/$2
      			echo "'$local/$1/$2' (saved)"
      		else
      			echo "Downloading $2"
       
      			# we need to get an encoded URL if any
      			url=$($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 $url
      			else
      				$WGET -c -O $local/$1/$2 $mirror/$1/$url
      			fi # end if
      		fi # end if
      	fi # 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" ] ; then
      		for file in $dotnewlist ; do
      			origfile="$(echo $file|sed -e 's/.new//')"
      			[ "$(echo $untouchable | grep $origfile)" ] && continue
      			echo "Should we move $file to $origfile ?"
      			select action in $actionlist ; do
      			case $action in
      				differences)
      					if [ -e $origfile ] ; then
      						diff -dU 1 $origfile $file | most
      					else
      						echo "$file is the only one, no $origfile yet"
      					fi
      					;;
      				yes)
      					mv -fi $file $origfile
      					break
      					;;
      				no)
      					break
      					;;
      				remove)
      					rm -i $file
      					break
      					;;
      				esac
      			done
      		done
      	else
      		echo "No \".new\" configuration files on the system"
      	fi
      }
       
      # Choose a download location from mirrors available in config file
      choosemirror(){
       
        echo "Please choose a mirror :"
        select newmirror in $mirrors_list ;do
          [ "$newmirror" ] && mirror="$newmirror"
          break
        done
       
        # 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"
        else
          echo "$mirror" > $buffer/last_mirror
          mirrorhash="$(echo "$mirror" | md5sum | cut -d " " -f 1)"
          mkdir -p $buffer
        fi
        echo ""
        echo -en '\E[36m'"\033[1mFrom now current mirror is : $mirror\033[0m"
        echo ""
       
        # Refresh meta information database
        getmeta
       
      }
       
      # prompt for action (install / upgrade / reinstall / download) for a list of packages ($1) #########################
      promptaction(){
      echo
       
      # this variable will track for packages installed as dependecies
      processedlist=''
       
      for pattern in $1; do
       
      	netpkglist="$(getpkglist | grep "$pattern")"
      	if [ ! "$netpkglist" ] ; then
      		echo "Package ~ $pattern : not found"
      		continue
      	fi
      	for 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 $package
          category=$(findcategorybypackage $package)
       
          # the software name
          softname=${package%-*}; softname=${softname%-*}; softname=${softname%-*}
       
          # take a look in pkgtool logs to see if we have got it installed
          installedpkg="$(checkinstalled $softname)"
       
          if [ -e $packagelogs/${package%%.tgz} ]; then
          	echo "[I][$category] Found installed $package on the repository"
          	actionname="reinstall"
          elif [ "$installedpkg" ]; then
          	if [ "$(vfilter -u -f $buffer/mainlist -q $package)" ]; then
          		echo -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)" ]; then
          		echo -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"
          	fi
       
          	actionname="upgrade"
          else
          	echo -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"
          fi
          actionlist="$actionname download skip"
          echo " what should I do ?"
       
          select action in $actionlist ; do
          case $action in
          	"install" | "reinstall" | "upgrade" )
          	PROMPT=1
          		autoinstall $package
          		PROMPT=0
          		break
          		;;
          	download)
          		download $category $package
          		break
          		;;
          	skip)
          		echo "Skipping package [$category]$package"
          		echo
          		break
          	esac
          done
         done
        done
      }
       
      # Check deps , then Install / Reinstall / Upgrade a list of packages
      # The full and exact package name MUST be provided
      autoinstall() {
       
        foundblacky="0"
       
      if [ "$1" ]; then
       
        finallist=''
       
        # We need an up to date list of installed packages
        getlocalpkglist
       
        for package in $1 ; do
       
          # the software name
          softname=${package%-*}; softname=${softname%-*}; softname=${softname%-*}
       
          # This package has now been processed
          processedlist="${processedlist} $package"
       
          # take a look in the blacklist
          for blacky in $blacklist ; do
            if [ "$blacky" = "$softname" ]; then
              echo "$package is blacklisted : skipping"
              foundblacky="1"
              break
            fi
          done
          if [ "$foundblacky" = "1" ] ; then
            foundblacky="0"
            continue
          fi
       
          finallist="${finallist} $package"
       
          [ ! "$dependencies" = "yes" ] && continue
       
          deps="$(grep "^$softname:.*$" $buffer/depfile | cut -s -d ":" -f 2-)"
          [ ! "$deps" ] && continue
       
          for 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 processed
            processedlist="${processedlist} $deppackage"
       
            # take a look in the blacklist
            for blacky in $blacklist ; do
              if [ "$blacky" = "$dep" ]; then
                foundblacky="1"
                break
              fi
            done
            if [ "$foundblacky" = "1" ] ; then
              foundblacky="0"
              continue
            fi
       
            if [ "$PROMPT" = "1" ] ; then
              echo "$deppackage is required by $package : do you want to install this dependency package ?"
              select action in yes skip ; do
                case $action in
                  yes)
                    finallist="${finallist} $deppackage"
                    break
                    ;;
                  skip)
                    break
                esac
              done
              continue
            fi
            finallist="${finallist} $deppackage"
          done
        done
       
        for package in $finallist ; do
       
          # We need to find the category for $package
          category=$(findcategorybypackage $package)
       
          # the software name
          softname=${package%-*}; softname=${softname%-*}; softname=${softname%-*}
       
          # take a look in pkgtool logs to see if we have got it installed
          installedpkg="$(checkinstalled $softname)"
       
          # download the package if needed
          download $category $package
       
          # check package integrity
          if [ ! "$(gzip -tv $local/$category/$package 2>&1 | egrep -e OK$)" ]; then
            echo "$package is corrupted, please checkout another mirror : skipping"
            rm -f $local/$category/$package 2>/dev/null
            continue
          fi
       
          if [ -e $packagelogs/${package%%.tgz} ]; then
            echo -n "Reinstalling"
            echo -e '\E[36m'"\033[1m [$category]$package\033[0m"
            upgradepkg --reinstall $local/$category/$package
          elif [ "$(vfilter -u -f $buffer/mainlist -q $package)" ]; then
            echo -n "Upgrading"
            echo -e '\E[31m'"\033[1m [$category]$package\033[0m"
            upgradepkg $local/$category/$package
          elif [ "$(vfilter -d -f $buffer/mainlist -q $package)" ]; then
            echo -n "Downgrading"
            echo -e '\E[32m'"\033[1m [$category]$package\033[0m"
            upgradepkg $local/$category/$package
          else
            echo -n "Installing"
            echo -e '\E[36m'"\033[1m [$category]$package\033[0m"
            installpkg $local/$category/$package
          fi
       
          # remove package if we don nott want to keep it
          if [ ! "$keepit" = "yes" ]; then
            rm -f $local/$category/$package 2>/dev/null
          fi
       
          # We need an up to date list of installed packages
          getlocalpkglist
       
        done
      fi
      }
       
      # getall ###############################################
      getall() {
        echo "Connecting to the packages repository..."
        echo
        for package in $(getpkglist) ; do
       
          if [ "$package" ]; then
       
            # We need to find the category for $package
            category=$(findcategorybypackage $package)
       
            download $category $package
       
          fi
        done
      }
       
      # upgrade the whole system ###############################################
      upgradeall() {
       
        foundblacky="0"
       
      echo "You are about to upgrade the whole system : are you sure ?"
      select action in "yes" "abort" ; do
        case $action in
          yes)
       
            echo "Connecting to the packages repository..."
            echo
            for package in $(getpkglist) ; do
       
              if [ "$package" ]; then
       
                # We need to find the category for $package
                category=$(findcategorybypackage $package)
                # the software name
                softname=${package%-*}; softname=${softname%-*}; softname=${softname%-*}
                # take a look in pkgtool logs to see if we have got it installed
                installedpkg="$(checkinstalled $softname)"
       
                if [ -e $packagelogs/${package%%.tgz} ]; then
                  echo "Found [$category]$package on the repository : already installed : skipping"
                  continue
       
                elif [ -n "$installedpkg" ]; then
       
                  # take a look in the blacklist
                  for blacky in $blacklist ; do
                    if [ "$blacky" = "$softname" ]; then
                      echo "Found [$category]$package on the repository : blacklisted : skipping"
                      foundblacky="1"
                      break
                    fi
                  done
                  if [ "$foundblacky" = "1" ] ; then
                    foundblacky="0"
                    continue
                  fi
       
                  if [ "$(vfilter -u -f $buffer/mainlist -q $package)" ]; then
                  # If we reached this point then this package needs to be upgraded
                    echo -n "Found "
                    echo -en '\E[31m'"\033[1m[$category]$package\033[0m"
                    echo " on the repository : $installedpkg is installed : upgrading"
       
                    autoinstall $package
       
                  fi
                else
                  echo "Found [$category]$package on the repository : not installed : skipping"
                fi
              fi
            done
       
          break
          ;;
        abort)
          exit 0
        esac
      done
      }
       
      # 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 $package
          category=$(findcategorybypackage $package)
       
          # the software name
          softname=${package%-*}; softname=${softname%-*}; softname=${softname%-*}
       
          # take a look in pkgtool logs to see if we have got it installed
          installedpkg="$(checkinstalled $softname)"
       
          if [ -e $packagelogs/${package%%.tgz} ]; then
            if [ -n "$(echo "$1" | grep 'I')" ]; then
              echo "[I][$category] Found installed $package on the repository"
            fi
          elif [ -n "$installedpkg" ]; then
            if [ -n "$(echo "$1" | grep 'U')" ]; then
              if [ "$(vfilter -u -f $buffer/mainlist -q $package)" ]; then
                echo -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"
              fi
            fi
            if [ -n "$(echo "$1" | grep 'D')" ]; then
              if [ "$(vfilter -d -f $buffer/mainlist -q $package)" ]; then
                echo -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"
              fi
            fi
          else
            if [ -n "$(echo "$1" | grep 'N')" ]; then
              echo -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"
            fi
          fi
        done
      }
    • Setelah melakukan pengeditan pada file /usr/libexec/netpkg-functions selesai, simpanlah hasil editan tersebut kemudian sekarang waktunya untuk mulai menggunakan repositori lokal bikinan sendiri :)

  3. 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:

    root[Martinus]# mkdir /mnt/cdrom
    root[Martinus]# mount -t iso9660 -o loop Repos.iso /mnt/cdrom
    root[Martinus]# ls /mnt/cdrom
    PACKAGES.TXT  PACKAGES.TXT.gz  xap
    root[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:

    root[Martinus]# netpkg mirror
    Please choose a mirror :
     1) http://slackware.linux.or.id/pub/zencafe/i486/zencafe-1.0
     2) http://distro.ibiblio.org/pub/linux/distributions/zenwalk/i486/current
     3) http://zen-repo.meticul.eu/i486/current
     4) http://mirror.meleeweb.net/pub/linux/zenwalk/i486/current
     5) http://ftp.nux.ipb.pt/pub/dists/zenwalk/i486/current
     6) http://ftp.sh.cvut.cz/MIRRORS/zenwalk/i486/current
     7) file:///mnt/cdrom
     8) http://linuxpackages.telecoms.bg/Zenwalk
     9) http://mirrors.unixsol.org/linuxpackages//Zenwalk
    10) http://linuxpackages.inode.at/Zenwalk
    11) http://www.software-mirror.com/linuxpackages/Zenwalk
    12) http://ftp.scarlet.be/pub/linuxpackages/Zenwalk
    13) ftp://ftp.slackware.hu/linuxpackages/Zenwalk
    14) http://slackware.mirrors.tds.net/pub/slackware/slackware-current/slackware
    15) http://www.tuxgames.net/zenwalk
    16) http://users.zenwalk.org/packages
    #? 7
    
    From now current mirror is : file:///mnt/cdrom
    Cleaning cache
    Connecting to mirror
    Offline mirror detected, switch to other process for getting offline packages metadata
    Checking offline repository metadata ......
    Pointing repository from /mnt/cdrom
    Computing packages dependencies
    Computing packages descriptions
    Creating packages list
    Getting local packages list
    Computing packages status
    Synchronization with file:///mnt/cdrom successful
    Cleaning temporary files and saving meta information
    root[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:

    root[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 repository
    Cleaning temporary files and saving meta information
    root[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:

    root[Martinus]# netpkg bc-1.06-i486-46.1.tgz
    
    [N][xap] Found bc-1.06-i486-46.1.tgz on the repository : not installed
     what should I do ?
    1) install
    2) download
    3) skip
    #? 1
    Nothing to do, bc-1.06-i486-46.1.tgz is already in local cache
    Installing [xap]bc-1.06-i486-46.1.tgz
    Installing 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 programs
    bc: to do calculations using arbitrary precision real numbers.
    bc:
    bc:
    
    Cleaning temporary files and saving meta information
    root[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:

    root[Martinus]# ls /var/log/packages | grep bc
    bc-1.06-i486-46.1
    glibc-2.3.6-i486-2z40
    libcroco-0.6.1-i486-1z28
    root[Martinus]# bc
    bc 1.06
    Copyright 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.
    quit
    root[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

# 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

13 Responses to “Zencafe Lokal Repositori”

  1. hamzah baradja / 11132007, 5:25:

    maap nih mas Martinus, saya nanyak-nya malah seputar instalasi (zenwalk).
    wong mau partisi di Axio note-book aja diputer-puter sekitar setup, katanya hurus partisi manual dulu (swap&boot)min 3Gb, gimana sih cara masuk kepartisi hd kayak slackware gitu.
    tapi emang katanya infolinux ya susah susah gampang, ba’nen ya susah tenenan tu !.
    satu lagi ya mas, boot disk punya slack 11 kebawah ga mempan di note-ku ini, maunya yang R 12 aja, selain yg 12 kernelnya panik.
    kira-kira kenapa ya mas and maap kalo kepanjangan nanya’nya juga bingung mau nanya ke siapa ? untung ada mas Martin

    Waduh om, saya jelasin se-ingat saya ya om. Maklum saya ga gitu hapalin step-step-nya :( . Kalau seingat saya begini:

    1. Boot CD Zencafe / Zenwalk, kemudian pilih tipe hdd anda. (ada di layar monitornya, sesuaikan dng tipe hdd yang anda pakai)
    2. Setelah proses boot dari CD, loginlah dahulu hingga anda mendapati prompt #
    3. Jangan ketik setup dulu, tapi mulai-lah partisi hdd anda menggunakan tool cfdisk. Langkah-nya adalah sbb (asumsi saya hdd anda dikenali di /dev/sda1) :
    3.a. Jalankan perintah cfdisk /dev/sda1 untuk mulai partisi hdd
    3.b. Pilih berapa partisi yang ingin anda bikin dan jangan lupa tambahakan partisi swap pada proses di cfdisk ini.
    4. Jika hdd anda sudah terpartisi, silahkan jalankan setup (atau install ya ? ) Sudah cuma itu ajah koq om ;)

    Klo boleh tahu pesan errornya apaan om ? Btw kalau om masih kesulitan dalam proses instalasi dan ingin bantuan saya secara live, mungkin om bisa masuk ke channel #awali[at]Dalnet dan tanya ke saya secara langsung :) ident saya biasanya ~pemalu@xxxx.xxx.xx :)
    Atau klo kesulitan mencari saya di irc, mungkin om bisa contact saya via yahoo messenger ;) id saya thundherbolth@yahoo.com

  2. maap nih mas Martinus, saya nanyak-nya malah seputar instalasi (zenwalk).
    wong mau partisi di Axio note-book aja diputer-puter sekitar setup, katanya hurus partisi manual dulu (swap&boot)min 3Gb, gimana sih cara masuk kepartisi hd kayak slackware gitu.
    tapi emang katanya infolinux ya susah susah gampang, ba’nen ya susah tenenan tu !.
    satu lagi ya mas, boot disk punya slack 11 kebawah ga mempan di note-ku ini, maunya yang R 12 aja, selain yg 12 kernelnya panik.
    kira-kira kenapa ya mas and maap kalo kepanjangan nanya’nya juga bingung mau nanya ke siapa ? untung ada mas Martin

  3. aa[N] says:

    hehehehe…. mantap

  4. @damn_it: Ga paham yang bagian mana om ?
    Bukannya itu cuman tinggal pakai doank, copy paste beres ;) Simple koq ;)

  5. damn_it says:

    rak mudeng om martin

  6. Eko^jombg says:

    Hi. Martinus
    Salut deh. boleh dicoba nih. moga berhasil yah.
    maklum udah tua masih ngoprek.
    sukses yah

Leave a Reply

[+] adsenseid emoticons by Martinus Ady H. Modified from nartzco source code.