# HG changeset patch # User Christopher Rogers # Date 1297115332 0 # Node ID 96231de1f61b9cd90c8a61b6fc66b8ddac41e760 # Parent ba5ba03929f9d67aa5ac877662de3ba0f722af85 Fixed check_for_trball to repack source if tarball if it exist. Made the if statement for WGET_URL to be shorter since not all receipt uses WGET_URL to download/get tarball. diff -r ba5ba03929f9 -r 96231de1f61b tazwok --- a/tazwok Sat Feb 05 16:07:26 2011 +0000 +++ b/tazwok Mon Feb 07 21:48:52 2011 +0000 @@ -461,92 +461,91 @@ report end-step return 1 fi + fi + fi + report end-step + + if [ -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ] && [ "$nounpack" ]; then + return + fi + + # Untaring source if necessary. We don't need to extract source if + # the package is built with a wanted source package. + if [ "$WANTED" ]; then + return + fi + + report step "Untaring source tarball" + if [ "$target" ]; then + src="$target" + else + set_src_path + fi + + # Log process. + echo "untaring source tarball" >> $LOG + tmp_src=$WOK/$PACKAGE/tmp-src-$$ + mkdir $tmp_src + if [ -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ]; then + lzma d $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma -so | \ + tar xf - -C $tmp_src + elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then + case "$TARBALL" in + *zip|*xpi) { cd $tmp_src; unzip -o $SOURCES_REPOSITORY/$TARBALL; };; + *bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;; + *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;; + *lzma) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;; + *xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;; + *Z) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;; + *) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;; + esac || return 1 + + # Check if uncompressed tarball is in a root dir or not. + if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ]; then + if check_for_var_modification src _pkg; then + mv $tmp_src $tmp_src-1 + mkdir $tmp_src + mv $tmp_src-1 $tmp_src/$PACKAGE-$VERSION + else + mv $tmp_src/* $WOK/$PACKAGE + repack_src=no + rm -r $tmp_src + fi + fi + + if [ "$repack_src" = yes ]; then + report step "Repacking sources in .tar.lzma format" + cd $tmp_src + tar -c * | lzma e $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma -si + rm $SOURCES_REPOSITORY/$TARBALL + prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY) + + # Remove previous tarball if it's not used either by + # incoming and legacy packages. + [ "$prev_VERSION" != "$(get_pkg_version $PACKAGES_REPOSITORY)" ] && \ + remove_previous_tarball + fi + fi + if [ "$nounpack" ]; then + [ -d "$tmp_src" ] && rm -r $tmp_src + return + fi + + if [ ! -d "$src" ]; then + if [ -d "$tmp_src" ]; then + if ! check_for_var_modification src _pkg; then + src="${src%/*}/$(ls $tmp_src)" + fi + mv $(echo $tmp_src/*) "$src" + rm -r $tmp_src + + # Permissions settings. + chown -R root.root "$src" fi report end-step - - if [ -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ] && [ "$nounpack" ]; then - return - fi - - # Untaring source if necessary. We don't need to extract source if - # the package is built with a wanted source package. - if [ "$WANTED" ]; then - return - fi - - report step "Untaring source tarball" - if [ "$target" ]; then - src="$target" - else - set_src_path - fi - - # Log process. - echo "untaring source tarball" >> $LOG - - tmp_src=$WOK/$PACKAGE/tmp-src-$$ - mkdir $tmp_src - if [ -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ]; then - lzma d $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma -so | \ - tar xf - -C $tmp_src - else - case "$TARBALL" in - *zip|*xpi) { cd $tmp_src; unzip -o $SOURCES_REPOSITORY/$TARBALL; };; - *bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;; - *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;; - *lzma) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;; - *xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;; - *Z) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;; - *) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;; - esac || return 1 - - # Check if uncompressed tarball is in a root dir or not. - if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ]; then - if check_for_var_modification src _pkg; then - mv $tmp_src $tmp_src-1 - mkdir $tmp_src - mv $tmp_src-1 $tmp_src/$PACKAGE-$VERSION - else - mv $tmp_src/* $WOK/$PACKAGE - repack_src=no - rm -r $tmp_src - fi - fi - - if [ "$repack_src" = yes ]; then - report step "Repacking sources in .tar.lzma format" - cd $tmp_src - tar -c * | lzma e $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma -si - rm $SOURCES_REPOSITORY/$TARBALL - prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY) - - # Remove previous tarball if it's not used either by - # incoming and legacy packages. - [ "$prev_VERSION" != "$(get_pkg_version $PACKAGES_REPOSITORY)" ] && \ - remove_previous_tarball - fi - fi - if [ "$nounpack" ]; then - [ -d "$tmp_src" ] && rm -r $tmp_src - return - fi - - if [ ! -d "$src" ]; then - if [ -d "$tmp_src" ]; then - if ! check_for_var_modification src _pkg; then - src="${src%/*}/$(ls $tmp_src)" - fi - mv $(echo $tmp_src/*) "$src" - rm -r $tmp_src - - # Permissions settings. - chown -R root.root "$src" - fi - else - echo "There's already something at $src. Abord." >&2 - fi - report end-step + else + echo "There's already something at $src. Abord." >&2 fi }