[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: directory to deb



On Wed, Jul 23, 2008 at 10:16:20AM +0300, Eugene V. Lyubimkin wrote:
> T o n g wrote:
> > Apart from using checkinstall, if I've prepared a directory of folders and
> > files, can I make the directory into a .deb file?
> As I know, no. In your case checkinstall is better.

customizing the script which follows produces a .deb of the same
(usually low) quality of checkinstall. Sorry for the fact that comments
inside the script are not in english.

#!/bin/bash

test `id -u` -eq 0 || { echo "AVVISO: l'uid non è 0, bisognerebbe usare 'fakeroot ./.crea_deb.sh'!
" ; echo "Ora tento di rieseguire lo script dentro fakeroot:
" ; exec fakeroot "$0"; } 

echo 'Script per fare un .deb con tutti i files in una dir (e sottodir)'
echo 'NOTARE! da eseguirsi con `pwd`=la dir coi files'
echo 'NOTARE! la parte coi simlink funziona bene solo nelle ipotesi:'
echo 'la dir coi files ha la forma $BBASE/NN/$NOME'
echo 'I link sono in ../../bin=$BBASE/bin (files universalmente eseguibili)'
echo 'in ../../sbin=$BBASE/sbin (files eseguibili solo dal possessore, root)'

BASENOME=`/bin/pwd`
BASE="`dirname \"$BASENOME\"`"
NOME="`basename \"$BASENOME\"`"
NOMEPKG="$NOME"
VERSIONE="1.0.1-0.back.1"

BBASE=`dirname "$BASE"`
echo "
*** In questo momento BBASE vale $BBASE ***
"
test -d "../../bin" || { echo "AVVISO: ../../bin non dir! Male per i links!
" ; }
test -d "../../sbin" || { echo "AVVISO: ../../sbin non dir! Male per i links!
" ; }
which lintian>/dev/null || { echo "AVVISO: servirebbe avere lintian installato!
" ; }
which fakeroot>/dev/null || { echo "AVVISO: servirebbe avere fakeroot installato!
" ; }
which dpkg-shlibdeps>/dev/null || { echo "AVVISO: servirebbe avere dpkg-dev installato per usare dpkg-shlibdeps (dipendenze di un binario)!
" ; }
which ar>/dev/null || { echo "AVVISO: *OCCORRE* avere binutils installato! senza ar NON creo pacchetto .deb
" ; }
umask 0022

Crea_deb () {
TMPDIR="/tmp/$NOME.`date +%Y-%m-%d--%H-%M-%S`"
{
mkdir -p "$TMPDIR"
test -d "$TMPDIR" || { echo "ERRORE: $TMPDIR non dir!" ; exit 1 ; }
# "$BASENOME/lista" = lista files fuori da "$BASENOME" ma nel pkg
##### ATTENZIONE: NON SONO AMMESSI NOMI SIFULI (spazi nel path, ...)
test -e "$BASENOME/lista" || touch "$BASENOME/lista"
INST_SIZE=`du -sc "$BASENOME" $(cat "$BASENOME/lista")|tail -n 1|sed "s/[[:blank:]].*//"`
# crea data.tar.gz
find "$BBASE"/bin -lname "$BASENOME/*">"$TMPDIR/lista_bin"
find "$BBASE"/bin -lname "../NN/$NOME/*">>"$TMPDIR/lista_bin"
find "$BBASE"/sbin -lname "$BASENOME/*">"$TMPDIR/lista_sbin"
find "$BBASE"/sbin -lname "../NN/$NOME/*">>"$TMPDIR/lista_sbin"
cat "$TMPDIR/lista_sbin" "$TMPDIR/lista_bin" "$BASENOME/lista">"$TMPDIR/lista"
tar --numeric-owner \
   --files-from="$TMPDIR/lista" \
   -cvziSf "$TMPDIR/data.tar.gz" "$BASENOME"
##tolto numeric-owner, _MA_ allora nomi utenti devono essere "universali" ...
##tar -cvziSf "$TMPDIR/data.tar.gz" "$BASENOME"
# crea debian-binary
echo "2.0">"$TMPDIR/debian-binary"
# crea control.tar.gz
cat<<EOF>"$TMPDIR/control"
Package: $NOMEPKG
Version: $VERSIONE
Section: localscripts
Priority: optional
Architecture: all
Depends: bash (>= 2)
Recommends: screen, mc, ssh, rsync, bzip2, less, deborphan
Suggests: file, pinfo, telnet-ssl, lynx, mutt, wget, pdmenu, super, dpkg-repack, ntpdate, sash, e3
Installed-Size: $INST_SIZE
Maintainer: NN <nn@nohay.net>
Description: Una raccolta di scripts
 Dalla collezione di scripts di NN.
 ATTENZIONE: il pacchetto NON rispetta completamente la policy debian
EOF
find "$BASENOME" -type f -print0|xargs -0 md5sum|sed "s+ /+ +">"$TMPDIR/md5sums"
for F in `cat "$BASENOME/lista"` ; do \
    md5sum $F|sed "s+ /+ +">>"$TMPDIR/md5sums" ; done
#E: bho: control-file-has-bad-permissions md5sums 0664 != 0644
#E: bho: control-file-has-bad-owner md5sums 1000/1000 != root/root
##chmod 0644 "$TMPDIR/control" "$TMPDIR/md5sums" "$TMPDIR/debian-binary"
chown root:root "$TMPDIR/control" "$TMPDIR/md5sums" "$TMPDIR/debian-binary"
cd "$TMPDIR"
tar --numeric-owner -cvziSf "$TMPDIR/control.tar.gz" control md5sums
# crea pacchetto .deb
ar rucv "${NOME}_${VERSIONE}_all.deb" debian-binary control.tar.gz data.tar.gz
lintian "${NOME}_${VERSIONE}_all.deb" 2>&1 >"${NOME}_${VERSIONE}_all.deb.lintian" 2>&1
grep ^E: "${NOME}_${VERSIONE}_all.deb.lintian"
echo "ATTENZIONE: cercare di soddisfare lintian prima di installare il .deb !"
cd -
} 2>&1 | tee -a "$TMPDIR/LOG" 2>&1
} # fine funzione Crea_deb

Crea_links () {
# files "nascosti" ".*" NON vengono linkati in bin o sbin
# files non nascosti e eseguibili vengono linkati
cd $BASENOME
cd ../../bin
find ../NN/$NOME -type f -perm -111 ! -name ".*" -print0|xargs -0 \
	ln --target-directory=. -s
cd $BASENOME
cd ../../sbin
find ../NN/$NOME -type f -perm -100 ! -perm -1 ! -name ".*" -print0|xargs -0 \
	ln --target-directory=. -s
cd $BASENOME
}

Togli_links () {
cd $BASENOME
find ../../bin -lname "$BASENOME/*" -print0|xargs -0 rm
find ../../bin -lname "../NN/$NOME/*" -print0|xargs -0 rm
find ../../sbin -lname "$BASENOME/*" -print0|xargs -0 rm
find ../../sbin -lname "../NN/$NOME/*" -print0|xargs -0 rm
}

Controlla_permessi () {
cd $BASENOME
echo "Files (o dir...) con almeno uno dei tre bit speciali attivato: premere invio"
read DUMMY
find . -perm +7000 -ls|less
echo "Files (o dir...) x per l'utente ma non gruppo o altri: premere invio"
read DUMMY
find . -perm +100 ! -perm -11 -ls|less
echo "Files (o dir...) con uid non 0: premere invio"
read DUMMY
find . ! -uid 0 -ls|less
echo "Files (o dir...) con gid non 0: premere invio"
read DUMMY
find . ! -gid 0 -ls|less
}

Chown_root () {
cd $BASENOME
chown -R root:root .
}
 
Chmod_aXr () {
cd $BASENOME
find . -perm +111 -print0|xargs -0 chmod a+xr
find . -print0|xargs -0 chmod go-w,a+X
}

CercoDipendenze () {
mkdir -p debian
touch debian/substvars
find . -type f -perm +111 -print0|xargs -0  dpkg-shlibdeps
}

PRE=" **** Comandi disponibili: ****
"
PS3="
Digitare il numero del comando voluto e premere enter; Ctrl-D per uscire: "
echo "$PRE"
select COMANDO in \
Crea_links Togli_links Controlla_permessi Chown_root Chmod_aXr \
CercoDipendenze Crea_deb ; \
do $COMANDO ; echo "$PRE" ; done

-- 
Chi usa software non libero avvelena anche te. Digli di smettere.
Informatica=arsenico: minime dosi in rari casi patologici, altrimenti letale.
Informatica=bomba: intelligente solo per gli stupidi che ci credono.


Reply to: