[gl-como] creazione cdrom di pacchetti deb

francesco francesco@brisa.homelinux.net
Dom 12 Nov 2006 01:19:36 CET


Ciao

stavo pensando al fatto che quando molti nuovi utenti Linux si 
presentano al GL-Como, per farsi installare un OS Libero, ci ritroviamo 
sempre senza alcuni pacchetti difficili da trovare in rete per i meno 
esperti.

Ho pensato quindi di creare un cdrom con tutti i pacchetti deb della mia 
cache della mia *ubuntu.
La mia cache contiene molti pacchetti non presenti nel dvd originale, ed 
in più gli ultimi aggiornamenti disponibili dei miei programmi installati.

Per poter creare questo cdrom, mi sono fatto lo script che ho incollato 
in questa email:


#!/bin/sh

# GPL
# UTILITY TO CREATE A ISO FILE FROM OUR PACKAGE LOCAL CACHE DIRECTORY
# WORKS FINE WITH BOTH DEBIAN AND *UBUNTU


############################################
#SETTING DEFAULT VALUES
############################################
CACHE_FOLDER=/var/cache/apt/
ISO_TO_CREATE=/tmp/iso_full_of_deb_files.iso

############################################
#TEMPORARY VALUES
############################################
TEMP_DIR=/tmp/debtmpdir
TEMP_PACKAGE_FILE="$TEMP_DIR/Packages"
TEMP_LIST_OF_LAST="$TEMP_DIR/list_of_last.txt"


############################################
#START
############################################

# CREATE TEMPORARY
# FOLDER TO COPY
# DEBS INTO
mkdir -p "$TEMP_DIR"
mkdir -p "$TEMP_DIR/binary"

# GOTO CACHE_FOLDER
cd "$CACHE_FOLDER"

# CREATE TEMPORARY PACKAGE,
# I DO THIS TO GET ONLY THE NAMES OF LAST
# VERSION OF EACH PACKAGE
echo "SCANNING FOR ALL FILES, this will take some minutes"
dpkg-scanpackages . /dev/null > "$TEMP_PACKAGE_FILE"

# NOW I GET THE FILENAME OF ONLY THE LATEST PACKAGES
# IN THE ARCHIVE
cat "$TEMP_PACKAGE_FILE" | grep ^Filename | sed s/^Filename:\ // > 
"$TEMP_LIST_OF_LAST"
rm -f "$TEMP_PACKAGE_FILE"

# VERY WELL, NOW I COPY THEM TO THE DEST FOLDER
for debfile in $(cat "$TEMP_LIST_OF_LAST")
do
	echo "COPYING $debfile"
	cp $debfile "$TEMP_DIR/binary"
done
rm -f "$TEMP_LIST_OF_LAST"


# NOW I RESTART FROM THIS ARCHIVE TO CREATE A GOOD INDEX FILE
cd "$TEMP_DIR"
echo "SCANNING FOR LAST FILES, this will take some minutes"
dpkg-scanpackages binary /dev/null | gzip -9c > "$TEMP_PACKAGE_FILE.gz"


# ADDING SOME EXTRA INFO FILE
echo "To use this cd as source, use the following command:" > 
"$TEMP_DIR/readme.txt"
echo "apt-cdrom add" >> "$TEMP_DIR/readme.txt"
echo "Or if you wish to copy the content to a local folder (i.e. 
/tmp/mydebs):" >> "$TEMP_DIR/readme.txt"
echo "Add the following line to /etc/apt/sources.list to use this 
folder" >> "$TEMP_DIR/readme.txt"
echo "deb file:/tmp/mydebs ./" >> "$TEMP_DIR/readme.txt"



# FINALLY I MAY CREATE THE ISO BASED FROM THIS DIRECTORY
mkisofs \
     -o "$ISO_TO_CREATE" \
     -r \
     -V "DEB PACKAGES" \
     -cache-inodes  \
     -J \
     -l \
     "$TEMP_DIR"











Comunque mercoledì prossimo portero il dvd già fatto.

Se qualcuno volesse provare lo script (Non serve essere root) e/o 
migliorarlo sarebbe ottimo, fatemi sapere poi.

ciao


-- 
Brisa Francesco
Via Gabelli 16
22077 Olgiate Comasco (CO)

http://brisa.homelinux.net
francesco@brisa.homelinux.net

       ________                ______
      / ____/ /               / ____/___  ____ ___  ____
     / / __/ /      ______   / /   / __ \/ __ `__ \/ __ \
    / /_/ / /___   /_____/  / /___/ /_/ / / / / / / /_/ /
    \____/_____/            \____/\____/_/ /_/ /_/\____/

http://www.gl-como.org


Maggiori informazioni sulla lista gl-como