Results 1 to 5 of 5

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: How to repack dpkgs?

  1. #1
    Question [SOLVED] How to repack dpkgs?
    Hi. I have a 3G with 3.0 on it. I want to save off all my dpkgs for reinstallation when I upgrade, because some of the packages are no longer in the repositories, and some repositories are no longer around.

    There is a script, dpkg-repack, that would do what I want, but it's Perl. Is there any other way to do it?

    Thanks,
    Buzz
    Last edited by buzzme; 2010-09-23 at 03:43 AM. Reason: problem solved

  2. #2
    I finally found my answer, and I post it here for future benefit.

    Code:
    # cat redeb.sh
    #! /bin/sh
    #
    # redeb.sh - Command line utility for rewrapping installed Debian-packages
    # Copyright (C) 2003 Tommi Saviranta <[email protected]>
    #
    # 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.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    #
    #
    # Version: redeb.sh v0.1.1  7-May-2003  [email protected]
    
    
    if [ $# -ne 1 ]; then
    	echo "Usage: $0 PACKAGE"
    	exit 0
    fi
    
    # See if such package is installed.
    if [ ! -f /var/lib/dpkg/info/$1.list ]; then
    	echo "No such package installed."
    	exit 1
    fi
    
    # Create temporary directory.
    mkdir "__"
    cd "__"
    
    # Get file list for this package.
    for FILE in `cat "/var/lib/dpkg/info/.list"`; do
    	test -f "" && echo "" >>filelist
    done
    
    # Copy files here.
    tar -cf - `cat filelist` | tar -xf -
    
    # Create package-info.
    mkdir DEBIAN
    cp /var/lib/dpkg/info/.* DEBIAN
    for FILE in `ls -1 DEBIAN`; do
    	REAL=`echo "" | cut -d '.' -f 2`
    	mv "DEBIAN/" "DEBIAN/"
    done
    test -f DEBIAN/list && rm -f DEBIAN/list
    BEGPOS=`grep -nx "Package: $1" /var/lib/dpkg/available | cut -d ':' -f 1`
    TOTLENGTH=`wc -l /var/lib/dpkg/available | cut -d ' ' -f 1`
    tail -n `expr  -  + 1` /var/lib/dpkg/available >_control_
    LENGTH=`grep -nx "" _control_ | cut -d ':' -f 1 | head -n 1`
    head -n  _control_ >DEBIAN/control
    
    # Get package info
    VERSION=`grep -E "^Version:" DEBIAN/control | cut -d ' ' -f 2 | cut -d ':' -f 2`
    ARCH=`grep -E "^Architecture:" DEBIAN/control | cut -d ' ' -f 2`
    
    # Clean up.
    rm -f _control_ filelist
    
    # Create package.
    cd ..
    dpkg-deb -b "__" "__.deb"
    
    # Clean up the rest.
    rm -rf "__"

  3. #3
    I liked your script.

    It had some errors/flaws. I fixed them.

    Hope you like them.

    Code:
    #!/bin/sh
    #
    # redeb.sh - Command line utility for rewrapping installed Debian-packages
    # Copyright (C) 2015 Ikem Krueger <[email protected]>
    # Copyright (C) 2003 Tommi Saviranta <[email protected]>
    #
    # 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.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    #
    #
    # Version: redeb.sh v1.0.0  15-January-2015  [email protected]
    
    BASENAME="${0##*/}"
    PWD_OLD="$PWD"
    PACKAGE="$1"
    TEMP="/tmp/$BASENAME-$$/$PACKAGE"
    
    if [ $# -ne 1 ]
    then
    	echo "Usage: $BASENAME <PACKAGE>"
    
    	exit 0
    fi
    
    # See if such package is installed.
    if [ ! -f "/var/lib/dpkg/info/$PACKAGE.list" ]
    then
    	echo "No such package installed."
    
    	exit 1
    fi
    
    # Create temporary directory.
    mkdir -p "$TEMP"
    cd "$TEMP"
    
    # Get file list for this package.
    for FILE in $(cat "/var/lib/dpkg/info/$PACKAGE.list")
    do
    	test -f "$FILE" && echo "$FILE">>filelist.tmp
    done
    
    # Copy files here.
    tar -cf - $(cat filelist.tmp)|tar -xf -
    
    # Create package-info.
    mkdir DEBIAN
    
    cp /var/lib/dpkg/info/$PACKAGE.* DEBIAN
    
    rm "DEBIAN/$PACKAGE.list"
    
    TOTAL=$(wc -l /var/lib/dpkg/available|cut -d ' ' -f 1)
    BEGIN=$(grep -nx "Package: $PACKAGE" /var/lib/dpkg/available|cut -d ':' -f 1)
    
    tail -n $(expr $TOTAL - $BEGIN + 1) /var/lib/dpkg/available>control.tmp
    
    LENGTH=$(grep -nx "" control.tmp|cut -d ':' -f 1|head -n 1)
    
    head -n $LENGTH control.tmp>DEBIAN/control
    
    # Get package info
    VERSION=$(grep -E "^Version:" DEBIAN/control|cut -d ' ' -f 2|cut -d ':' -f 2)
    ARCH=$(grep -E "^Architecture:" DEBIAN/control|cut -d ' ' -f 2)
    
    # Clean up.
    rm -f control.tmp filelist.tmp
    
    # Create package.
    cd ..
    dpkg-deb -b "$TEMP" "$PWD_OLD/${PACKAGE}_${VERSION}_${ARCH}.deb"
    
    # Clean up the rest.
    rm -rf "$TEMP"

  4. #4
    Thanks for the update. I hadn't noticed that the forum stripped a bunch of curly-brace-enclosed entities out of the script. Let's see if I can get the original to post unmodified...

    #! /bin/sh
    #
    # redeb.sh - Command line utility for rewrapping installed Debian-packages
    # Copyright (C) 2003 Tommi Saviranta <[email protected]>
    #
    # 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.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    #
    #
    # Version: redeb.sh v0.1.1 7-May-2003 [email protected]

    if [ $# -ne 1 ]; then
    echo "Usage: $0 PACKAGE"
    exit 0
    fi

    # See if such package is installed.
    if [ ! -f /var/lib/dpkg/info/$1.list ]; then
    echo "No such package installed."
    exit 1
    fi

    # Create temporary directory.
    mkdir "_${1}_"
    cd "_${1}_"

    # Get file list for this package.
    for FILE in `cat "/var/lib/dpkg/info/${1}.list"`; do
    test -f "$FILE" && echo "$FILE" >>filelist
    done

    # Copy files here.
    tar -cf - `cat filelist` | tar -xf -

    # Create package-info.
    mkdir DEBIAN
    cp /var/lib/dpkg/info/${1}.* DEBIAN
    for FILE in `ls -1 DEBIAN`; do
    REAL=`echo "$FILE" | cut -d '.' -f 2`
    mv "DEBIAN/$FILE" "DEBIAN/$REAL"
    done
    test -f DEBIAN/list && rm -f DEBIAN/list
    BEGPOS=`grep -nx "Package: $1" /var/lib/dpkg/available | cut -d ':' -f 1`
    TOTLENGTH=`wc -l /var/lib/dpkg/available | cut -d ' ' -f 1`
    tail -n `expr $TOTLENGTH - $BEGPOS + 1` /var/lib/dpkg/available >_control_
    LENGTH=`grep -nx "" _control_ | cut -d ':' -f 1 | head -n 1`
    head -n $LENGTH _control_ >DEBIAN/control

    # Get package info
    VERSION=`grep -E "^Version:" DEBIAN/control | cut -d ' ' -f 2 | cut -d ':' -f 2`
    ARCH=`grep -E "^Architecture:" DEBIAN/control | cut -d ' ' -f 2`

    # Clean up.
    rm -f _control_ filelist

    # Create package.
    cd ..
    dpkg-deb -b "_${1}_" "${1}_${VERSION}_${ARCH}.deb"

    # Clean up the rest.
    rm -rf "_${1}_"

  5. #5
    Yeah, that looks better.

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •