# HG changeset patch # User Antoine Bodin # Date 1296844617 -3600 # Node ID e05c35b39a9166c962e80b01d4df87510a9933c2 # Parent c1c9086a9e31f68f72808e70330efaee8b9ac541 Add nounpack option for get-src & SRC_WANTED variable support diff -r c1c9086a9e31 -r e05c35b39a91 tazwok --- a/tazwok Thu Feb 03 19:36:57 2011 +0000 +++ b/tazwok Fri Feb 04 19:36:57 2011 +0100 @@ -423,6 +423,10 @@ # Check for src tarball and wget if needed. check_for_tarball() { + if [ "$SRC_WANTED" ]; then + tazwok get-src "$SRC_WANTED" --target=$WOK/$PACKAGE/$PACKAGE-$VERSION || return 1 + return + fi if [ "$WGET_URL" ]; then report step "Checking for source tarball" @@ -456,81 +460,78 @@ # Untaring source if necessary. We don't need to extract source if # the package is built with a wanted source package. - if [ ! "$WANTED" ]; then - report step "Untaring source tarball" - if [ "$target" ]; then - src="$target" + if [ "$WANTED" ] || [ "$nounpack" ]; then + return + fi + + report step "Untaring source tarball" + if [ "$target" ]; then + src="$target" + else + set_src_path + fi + if [ ! -d "$src" ]; then + + # 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 - set_src_path - fi - if [ ! -d "$src" ]; 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 - # 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 [ "$1" = "get-src" ]; then - if [ -d "$tmp_src" ]; then + # 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 [ -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" + + 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 - else - echo "There's already something at $src. Abord." >&2 fi - report end-step + 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 fi } @@ -2604,7 +2605,7 @@ ;; get-src) check_root - get_options_list="target" + get_options_list="target nounpack" get_tazwok_config check_for_package_on_cmdline check_for_receipt @@ -2612,7 +2613,7 @@ if [ "$WGET_URL" ];then source_lib report report start - check_for_tarball get-src + check_for_tarball else echo "No tarball to download for $PACKAGE" fi