[Lunar-commits] <lunar> Merge pull request #37 from cavalier38/xz

Auke Kok sofar+github at foo-projects.org
Wed Jan 16 22:23:51 CET 2013


commit 71ab44b60e87c3731077dd42f03f7e696b104845
Author: Auke Kok <sofar+github at foo-projects.org>
Date: Wed, 16 Jan 2013 13:23:51 -0800
URL: https://github.com/lunar-linux/lunar/commit/71ab44b60e87c3731077dd42f03f7e696b104845

Merge pull request #37 from cavalier38/xz

Xz
---
  libs/download.lunar              | +3/-0     
  libs/logging.lunar               | +5/-5     
  libs/main.lunar                  | +9/-9     
  libs/misc.lunar                  | +26/-6    
  libs/prune.lunar                 | +5/-4     
  libs/tracking.lunar              | +3/-3     
  libs/view.lunar                  | +1/-0     
  plugins/build-zpatches.plugin    | +2/-0     
  plugins/postbuild-generic.plugin | +1/-1     
  prog/lrm                         | +7/-4     
  prog/lunar                       | +4/-5     
  prog/lvu                         | +7/-6     
  12 files changed

--- a/libs/download.lunar
+++ b/libs/download.lunar
@@ -183,6 +183,9 @@ testpack () {
 			*.CAB|*.cab)
 				echo $FILEMAGIC | grep -qw "Cabinet"
 				;;
+			*.xz|*.XZ)
+				echo $FILEMAGIC | grep -qw "XZ"
+				;;
 			*)
 				# we don't know how to handle this type of file
 				true
--- a/libs/logging.lunar
+++ b/libs/logging.lunar
@@ -29,10 +29,10 @@ stop_logging() {
   echo > $C_FIFO
   echo "++ Mark Compile stop   : \"$MODULE\" \"$VERSION\" \"$(date -Ru)\"" >> $C_LOG
   message  "${MESSAGE_COLOR}Creating"                        \
-           "${FILE_COLOR}$COMPILE_LOGS/$MODULE-$VERSION.bz2"  \
+           "${FILE_COLOR}$COMPILE_LOGS/$MODULE-$VERSION.xz"  \
            "${DEFAULT_COLOR}"
 
-  bzip2 -9f < $C_LOG > $COMPILE_LOGS/$MODULE-$VERSION.bz2
+  xz -9f < $C_LOG > $COMPILE_LOGS/$MODULE-$VERSION.xz
   temp_destroy $C_LOG
   temp_destroy $C_FIFO
 }
@@ -40,13 +40,13 @@ stop_logging() {
 
 progress() {
   local OLDLOG OLDSZ S PC
-  OLDLOG=$(ls -1d $COMPILE_LOGS/$MODULE-*.bz2 2>&- | head -n 1)
+  OLDLOG=$(ls -1d $COMPILE_LOGS/$MODULE-*.{xz,bz2} 2>&- | head -n 1)
   STIME=$(date +%s)
   if [[ -f $OLDLOG ]]; then
     X="############################################################"
     Y="                                                            "
-    OLDSZ=$(bzcat $OLDLOG | wc -c)
-    OLDTIMES=($(bzcat $OLDLOG | grep 'Mark Compile ' | cut -d \" -f6 | while read TIME ; do date +%s -d "$TIME" ; done))
+    OLDSZ=$(xzbz -dc $OLDLOG | wc -c)
+    OLDTIMES=($(xzbz -dc $OLDLOG | grep 'Mark Compile ' | cut -d \" -f6 | while read TIME ; do date +%s -d "$TIME" ; done))
     CTIME=$((${OLDTIMES[1]} - ${OLDTIMES[0]}))
     echo "Last compile time: $((CTIME / 60))m$((CTIME % 60))s"
     while true ; do
--- a/libs/main.lunar
+++ b/libs/main.lunar
@@ -132,10 +132,10 @@ expand_cache_safe() {(
   export SOURCE_DIRECTORY=$BUILD_DIRECTORY/resurrect-$MODULE-$VERSION
   mk_source_dir $SOURCE_DIRECTORY
   # untar the file so we can compare first
-  tar -pkxjf $1 -C $SOURCE_DIRECTORY 1>/dev/null 2>&1
+  tar -pkxf $1 -C $SOURCE_DIRECTORY 1>/dev/null 2>&1
   # make a md5sum list of files
   TMP_TARGETS=$(temp_create "resurrect.targets.$MODULE")
-  tar j --list < $1 > $TMP_TARGETS
+  tar tf $1 > $TMP_TARGETS
   TMP_TARGETS_OK=$(temp_create "resurrect.targets_OK.$MODULE")
   # do directories: we don't care here
   # the sed trick is advanced: a non-greedy pattern that returns all
@@ -167,7 +167,7 @@ expand_cache_safe() {(
   done
 
   debug_msg "tar xjf $1 -P -k -T $TMP_TARGETS_OK"
-  tar xjf $1 -P -k -T $TMP_TARGETS_OK > /dev/null 2>&1
+  tar xf $1 -P -k -T $TMP_TARGETS_OK > /dev/null 2>&1
 
   temp_destroy $TMP_TARGETS
   temp_destroy $TMP_TARGETS_OK
@@ -198,11 +198,11 @@ resurrect()  {
     lrm --keepconfig $MODULE
   fi &&
 
-  CACHE_BZ="$INSTALL_CACHE/$MODULE-$VERSION-$BUILD.tar.bz2"
+  CACHE_XZ=$(xzbz_file "$INSTALL_CACHE/$MODULE-$VERSION-$BUILD.tar")
 
-  if [ -f "$CACHE_BZ" ] && bzip2 -tf $CACHE_BZ ; then
+  if [ -f "$CACHE_XZ" ] && xzbz -tf $CACHE_XZ ; then
     message  "${RESURRECT_COLOR}Resurrecting ${MODULE_COLOR}${MODULE}${DEFAULT_COLOR} ${MESSAGE_COLOR}version ${VERSION_COLOR}${VERSION}${DEFAULT_COLOR}"
-    expand_cache_safe $CACHE_BZ &&
+    expand_cache_safe $CACHE_XZ &&
     add_module $MODULE $STATUS $VERSION &&
     verbose_msg "running \"lunar fix $MODULE\"" &&
     if run_fix $MODULE ; then
@@ -316,7 +316,7 @@ lin_module()  {
       sound FAILURE
       message "${PROBLEM_COLOR}! Problem detected during ${FILE_COLOR}$LIN_ERROR${DEFAULT_COLOR}"
       rm -f $linING
-      report $COMPILE_LOGS/$MODULE-$VERSION.bz2 "compile log" $MODULE $VERSION
+      report $COMPILE_LOGS/$MODULE-$VERSION.xz "compile log" $MODULE $VERSION
       activity_log  "lin"  "$MODULE"  "$VERSION"  "failed" "Due to build errors during $LIN_ERROR"
       return 1
     fi
@@ -337,7 +337,7 @@ lin_module()  {
       sound FAILURE
       message "${PROBLEM_COLOR}! Problem detected during ${FILE_COLOR}$LIN_ERROR${DEFAULT_COLOR}"
       rm -f $linING
-      report $COMPILE_LOGS/$MODULE-$VERSION.bz2 "compile log" $MODULE $VERSION
+      report $COMPILE_LOGS/$MODULE-$VERSION.xz "compile log" $MODULE $VERSION
       activity_log  "lin"  "$MODULE"  "$VERSION"  "failed" "Due to build errors during $LIN_ERROR"
       return 1
     fi
@@ -352,7 +352,7 @@ lin_module()  {
       sound FAILURE
       message "${PROBLEM_COLOR}! Problem detected${DEFAULT_COLOR}"
       rm -f $linING
-      report $COMPILE_LOGS/$MODULE-$VERSION.bz2 "compile log" $MODULE $VERSION
+      report $COMPILE_LOGS/$MODULE-$VERSION.xz "compile log" $MODULE $VERSION
       activity_log  "lin"  "$MODULE"  "$VERSION"  "failed" "Due to build errors during or after $LIN_ERROR"
       return 1
     fi
--- a/libs/misc.lunar
+++ b/libs/misc.lunar
@@ -204,12 +204,6 @@ custom_filters()
 }
 
 
-source_basename()
-{
-	echo $1 | sed 's/.tar.\(bz2\|gz\)$//g'
-}
-
-
 last_kernel()
 {
 	if [ -f /usr/src/linux/include/linux/utsrelease.h ]; then
@@ -218,3 +212,29 @@ last_kernel()
 		grep UTS_RELEASE /usr/src/linux/include/linux/version.h | cut -d'"' -f2
 	fi
 }
+
+
+xzbz_file()
+{
+  local FILE FILE_BZ
+  FILE="$1.xz"
+  if [ ! -f $FILE ] ; then
+    FILE_BZ="$1.bz2"
+    if [ -f $FILE_BZ ] ; then
+      FILE="$FILE_BZ"
+    fi
+  fi
+  echo $FILE
+}
+
+xzbz()
+{
+  local XZBZ
+  case $(file -b $2 | cut -d' ' -f1) in
+    bzip2) XZBZ=bzip2 ;;
+     gzip) XZBZ=gzip ;;
+       XZ) XZBZ=xz ;;
+	*) XZBZ=xz ;;
+  esac
+  $XZBZ "$@"
+}
--- a/libs/prune.lunar
+++ b/libs/prune.lunar
@@ -33,6 +33,7 @@ prune() {
     # cache:
       VERSION=$(installed_version $MODULE)
     
+      echo "$MODULE-$VERSION-$BUILD.tar.xz" >> $TMP_CACHE_KEEP
       echo "$MODULE-$VERSION-$BUILD.tar.bz2" >> $TMP_CACHE_KEEP
     fi
   done
@@ -69,10 +70,10 @@ prune() {
   done
 
   verbose_msg "finding stale compile logs"
-  for FILE in $(ls -1 $COMPILE_LOGS | sed "s/\.bz2//") ; do
-    if ! echo -e "$LOGS" | grep -q $FILE ; then
-      message "Removing stale log: $COMPILE_LOGS/$FILE.bz2"
-      rm $COMPILE_LOGS/$FILE.bz2
+  for FILE in $(ls -1 $COMPILE_LOGS) ; do
+    if ! echo -e "$LOGS" | grep -q $(echo $FILE | sed "s/\.\(xz\|bz2\)$//") ; then
+      message "Removing stale log: $COMPILE_LOGS/$FILE"
+      rm $COMPILE_LOGS/$FILE
     fi
   done
 
--- a/libs/tracking.lunar
+++ b/libs/tracking.lunar
@@ -75,7 +75,7 @@ create_install_log() {
 
   parse_iw | sort | uniq | filter "$LOCAL_EXCLUDED" | custom_filters | exists > $TMP_INST_LOG
   echo "$INSTALL_LOGS/$MODULE-$VERSION"                 >> $TMP_INST_LOG
-  echo "$COMPILE_LOGS/$MODULE-$VERSION.bz2"             >> $TMP_INST_LOG
+  echo "$COMPILE_LOGS/$MODULE-$VERSION.xz"              >> $TMP_INST_LOG
   echo "$MD5SUM_LOGS/$MODULE-$VERSION"                  >> $TMP_INST_LOG
 
   MISOWNED_SYMLINKS=$(syms_not_owned  $TMP_INST_LOG
@@ -108,8 +108,8 @@ create_install_cache() {
     return
   fi
 
-  message "${MESSAGE_COLOR}Creating ${FILE_COLOR}$INSTALL_CACHE/$MODULE-$VERSION-$BUILD.tar.bz2${DEFAULT_COLOR}"
-  tar cPjf "$INSTALL_CACHE/$MODULE-$VERSION-$BUILD.tar.bz2" --no-recursion -T $INSTALL_LOGS/$MODULE-$VERSION
+  message "${MESSAGE_COLOR}Creating ${FILE_COLOR}$INSTALL_CACHE/$MODULE-$VERSION-$BUILD.tar.xz${DEFAULT_COLOR}"
+  tar cPJf "$INSTALL_CACHE/$MODULE-$VERSION-$BUILD.tar.xz" --no-recursion -T $INSTALL_LOGS/$MODULE-$VERSION
 
 }
 
--- a/libs/view.lunar
+++ b/libs/view.lunar
@@ -15,6 +15,7 @@ view_file()  {
     case $(file -b $1 | cut -d' ' -f1) in
       bzip2) bzcat $1 | ${PAGER:-less} ;;
        gzip) zcat $1  | ${PAGER:-less} ;;
+         XZ) xzcat $1 | ${PAGER:-less} ;;
           *)
              # default fallback
              cat "$1" | ${PAGER:-less} ;;
--- a/plugins/build-zpatches.plugin
+++ b/plugins/build-zpatches.plugin
@@ -39,6 +39,8 @@ plugin_zpatches_apply()
         GZCMD="bzcat"
       elif [[ -n `echo $PATCH | grep '\.gz$'` ]] ; then
         GZCMD="zcat"
+      elif [[ -n `echo $PATCH | grep '\.xz$'` ]] ; then
+        GZCMD="xzcat"
       else
         GZCMD="cat"
       fi
--- a/plugins/postbuild-generic.plugin
+++ b/plugins/postbuild-generic.plugin
@@ -104,7 +104,7 @@ plugin_archive_module()
   if [ ! -e /var/state/lunar/module_history ]; then
     mkdir -p /var/state/lunar/module_history
   fi
-  tar -cj --exclude=.svn -C $MOONBASE/$SECTION -f /var/state/lunar/module_history/$MODULE-$VERSION-$(date -u +%Y%m%d).tar.bz2 $MODULE
+  tar -cJ --exclude=.svn -C $MOONBASE/$SECTION -f /var/state/lunar/module_history/$MODULE-$VERSION-$(date -u +%Y%m%d).tar.xz $MODULE
   return 2
 }
 
--- a/prog/lrm
+++ b/prog/lrm
@@ -240,6 +240,8 @@ check_status() {
 
 
 downgrade() {
+  local CACHE_XZ
+
   # a local function for listing the contents of install cache
   list_available_cache() {
     ls -1 $INSTALL_CACHE/$MODULE-* | while read LINE ; do
@@ -258,7 +260,9 @@ downgrade() {
     list_available_cache   
   fi
 
-  if [ ! -s $INSTALL_CACHE/$MODULE-$1-$BUILD.tar.bz2 ] ; then 
+  CACHE_XZ=$(xzbz_file "$INSTALL_CACHE/$MODULE-$1-$BUILD.tar")
+
+  if [ ! -s $CACHE_XZ ] ; then 
     message "Desired version is not available. Here is the available files"
     list_available_cache
   fi
@@ -284,11 +288,10 @@ downgrade() {
   verbose_msg "installing \"$MODULE-$1\""
   verbose_msg "extracting cached install file..."
   
-  bzcat $INSTALL_CACHE/$MODULE-$1-$BUILD.tar.bz2 | tar -kt $TAR_P -C / >/dev/null
+  xzbz -dc $CACHE_XZ | tar -kt $TAR_P -C / >/dev/null
   verbose_msg "adding module to installed list"
 
-  bzcat $INSTALL_CACHE/$MODULE-$1-$BUILD.tar.bz2 | 
-  tar -kx $TAR_P -C / 2>/dev/null >/dev/null
+  xzbz -dc $CACHE_XZ | tar -kx $TAR_P -C / 2>/dev/null >/dev/null
   verbose_msg "adding module to installed list"
   add_module $MODULE installed  $1
   activity_log  "lrm downgrade"  "$MODULE"  "$1"  "success"
--- a/prog/lunar
+++ b/prog/lunar
@@ -136,11 +136,10 @@ add_pkgs()  { (
 
 show_file()	{
   if  [  -f  $1  ];  then
-    if  [  "`file  -b  $1  |  cut  -d ' '  -f1`"  == "bzip2" ];  then
-      bzcat  $1  |  view_file
-    else
-      $DIALOG  --textbox  $1  10  0
-    fi
+    case  `file  -b  $1  |  cut  -d ' '  -f1` in
+      bzip2|gzip|XZ)  view_file $1  ;;
+      *)  $DIALOG  --textbox  $1  10  0  ;;
+    esac
   else
     $DIALOG  --msgbox  "File not found."  0  0
     return  1
--- a/prog/lvu
+++ b/prog/lvu
@@ -123,7 +123,7 @@ EOF
 
 export_snapshot()  {
   SNAPSHOT=snapshot-$HOSTNAME-$(date -u +%Y%m%d)
-  tar cjfP "/root/$SNAPSHOT.tar.bz2" $CONFIG_CACHE $MODULE_STATUS
+  tar cJfP "/root/$SNAPSHOT.tar.xz" $CONFIG_CACHE $MODULE_STATUS
   message "${MESSAGE_COLOR}Snapshot ${DEFAULT_COLOR}${FILE_COLOR}$SNAPSHOT${DEFAULT_COLOR}${MESSAGE_COLOR} created.${DEFAULT_COLOR}"
 }
 
@@ -134,7 +134,7 @@ import_snapshot()  {
 
   if [ -f "$1" ] ; then
     ( mk_source_dir $SOURCE_DIRECTORY )
-    tar xj -C $SOURCE_DIRECTORY -f $SNAPSHOT 2> /dev/null
+    tar x -C $SOURCE_DIRECTORY -f $SNAPSHOT 2> /dev/null
     cd $SOURCE_DIRECTORY
 
 	message "${MESSAGE_COLOR}Restoring lunar configuration${DEFAULT_COLOR}"
@@ -1535,11 +1535,12 @@ main()  {
     compile)
       if [ ! -z "$2" ]; then
         if run_details $2 ; then
-          if [ -f $COMPILE_LOGS/$2-$(module_version $2).bz2 ] ; then
-            view_file "$COMPILE_LOGS/$2-$(module_version $2).bz2"
+          LOG_FILE=$(xzbz_file "$COMPILE_LOGS/$2-$(module_version $2)")
+          if [ -f "$LOG_FILE" ] ; then
+            view_file "$LOG_FILE"
           else
-            VERSION=$(installed_version $2)
-            view_file "$COMPILE_LOGS/$2-$(installed_version $2).bz2" \
+            LOG_FILE=$(xzbz_file "$COMPILE_LOGS/$2-$(installed_version $2)")
+            view_file "$LOG_FILE" \
               "Compile log for $2 does not exist"
           fi
         fi




More information about the Lunar-commits mailing list