"Fossies" - the Fresh Open Source Software Archive

Member "libisoburn-1.5.4/releng/manual_isojigdo" (8 Jul 2020, 8602 Bytes) of package /linux/misc/libisoburn-1.5.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 
    3 # Copyright 2011, 2019 Thomas Schmitt <scdbackup@gmx.net>
    4 # Copyright 2011 George Danchev <danchev@spnet.net>
    5 # Licensed under GNU GPL version 2 or later
    6 
    7 set -e
    8 
    9 not_in_releng_exit() {
   10   printf "\nPlease execute the tests from releng directory.\n\n"
   11   exit 1
   12 }
   13 
   14 . inc/releng_getopts.inc || not_in_releng_exit
   15 
   16 print_specific_help() {
   17 cat << HLP
   18 Specific options:
   19        --md5     use MD5 checksums (default)
   20        --sha256  use SHA256 checksums
   21 Overview:
   22        Match the resulting ISO image representation
   23        against the jigdo representation.
   24 HLP
   25 }
   26 
   27 if test "$SPECIFIC_HELP" = 1; then
   28   print_specific_help
   29   exit 0
   30 fi
   31 
   32 # Set default values for specific option variables.
   33 checksum_type=md5
   34 # Interpret specific options, they begin after the first --.
   35 next_is=ignore
   36 for i in "$@"
   37 do
   38   if test "$next_is" = "ignore"
   39   then
   40        if test "$i" = "--"
   41        then
   42             next_is=""
   43        fi
   44   elif test "$i" = "--md5"
   45   then
   46        checksum_type=md5
   47   elif test "$i" = "--sha256"
   48   then
   49        checksum_type=sha256
   50   else
   51        echo >&2
   52        echo "Unknown test specific option: $i" >&2
   53        print_help
   54        print_specific_help
   55        exit 31
   56   fi
   57 done
   58 
   59 if [ ! -x $RELENG_XORRISO ]; then
   60  print_help
   61  printf "\n${SELF}: -x  absolute or relative path to binary to be run.\n\n"
   62  exit 30
   63 fi
   64 
   65 # check data dir, if any and after checking -x xorriso
   66 if [ -d "${GEN_DATA_DIR}" ]; then
   67  printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR}
   68  printf "\n${SELF}: use './${SELF} -c' to remove.\n"
   69  exit 1
   70 else
   71  mkdir "${GEN_DATA_DIR}"
   72 fi
   73 
   74 TMP_DATA_DIR=releng_generated_data
   75 IMG_EXTRACT_DIR=${GEN_DATA_DIR}/${SELF}_extracted_tree
   76 RELENG_DIR="${IMG_EXTRACT_DIR}"
   77 RELENG_ISOLINUX_BIN="isolinux/isolinux.bin"
   78 RELENG_BOOT_CAT="isolinux/boot.cat"
   79 RELENG_IMG=t1
   80 RES=""
   81 REMOTE_URL="http://cdimage.debian.org/cdimage/daily-builds/daily/arch-latest/i386/iso-cd"
   82 REMOTE_IMG="debian-testing-i386-netinst.iso"
   83 
   84 # check for required items
   85 if [ "${RELENG_XORRISO}" = "" -o "${RELENG_DIR}" = "" -o "${RELENG_IMG}" = "" ]; then
   86  echo -e "\n${SELF}: xorriso_cmd IN_dir and OUT_image are required\n"
   87  exit 2
   88 fi
   89 
   90 # All must be set at this point
   91 printf "${SELF}: Config items:"
   92 printf "\n\txorriso_cmd=${RELENG_XORRISO}\n\tIN_dir=${RELENG_DIR}\n\tOUT_image=${RELENG_IMG}.iso"
   93 printf "\n\tIN_isolinux=${RELENG_ISOLINUX_BIN}\n\tOUT_bootcat=${RELENG_BOOT_CAT}\n"
   94 RES="${RELENG_IMG}.iso ${RELENG_IMG}.new ${RELENG_IMG}.md5 ${RELENG_IMG}.jigdo ${RELENG_IMG}.template"
   95 
   96 # xorriso version details, incl. underlying libraries
   97 # "${RELENG_XORRISO}" -version
   98 
   99 # check whether the binary support JTE
  100 set +e
  101 RETSTR_VER_JTE=`"${RELENG_XORRISO}" --version 2>/dev/null | grep "libjte * in use"`
  102 RETCODE_VER_JTE="$?"
  103 set -e
  104 case ${RETCODE_VER_JTE} in
  105      0)
  106        printf "\n${SELF}: Found JTE support with ${RELENG_XORRISO} : ${RETSTR_VER_JTE}"
  107        ;;
  108      *)
  109        printf "\nFAIL : ${SELF} : Not found JTE support in ${RELENG_XORRISO}. Quit."
  110        printf "\n${SELF}: JTE not supported with this xorriso build. Install jigit >=1.18 and rebuild."
  111        printf "\n${SELF}: http://www.einval.com/~steve/software/JTE/\n"
  112        cleanup
  113        exit 4
  114        ;;
  115 esac
  116 
  117 # grab remote ISO image, to decompose
  118 if [ -L "${TMP_DATA_DIR}"/"${REMOTE_IMG}" ]; then
  119  printf "\n${SELF}: Found symbolic link ${TMP_DATA_DIR}"/"${REMOTE_IMG}\n"
  120  ls -ld ${TMP_DATA_DIR}"/"${REMOTE_IMG}
  121 elif [ ! -f "${TMP_DATA_DIR}"/"${REMOTE_IMG}" ]; then
  122  printf "\n${SELF}: Downloading ${REMOTE_URL}/${REMOTE_IMG}\n"
  123  if wget -V >/dev/null 2>&1
  124  then
  125    set +e
  126    wget --no-check-certificate -T20 -t3 \
  127         -O "${TMP_DATA_DIR}"/"${REMOTE_IMG}" "${REMOTE_URL}"/"${REMOTE_IMG}"
  128    WGET_RET="$?"
  129    set -e
  130  elif fetch -T 20 -o "${TMP_DATA_DIR}"/"${REMOTE_IMG}" \
  131             "${REMOTE_URL}"/"${REMOTE_IMG}"
  132  then
  133    WGET_RET=0
  134  else
  135    echo
  136    echo "FAIL: ${SELF} : Neither wget nor fetch are present and willing to work"
  137    cleanup
  138    exit 10
  139  fi
  140  case ${WGET_RET} in
  141      0)
  142       echo -e "\n${SELF}: Downloading successfully completed.\n"
  143      ;;
  144      *)
  145       echo -e "\nFAIL : ${SELF} : wget returned code: $WGET_RET\n"
  146       rm "${TMP_DATA_DIR}"/"${REMOTE_IMG}"
  147       cleanup
  148       exit 5
  149      ;;
  150  esac
  151 else
  152  printf "\n${SELF}: Found ISO image: ${TMP_DATA_DIR}/${REMOTE_IMG}\n"
  153 fi
  154 
  155 # check for extraction directory existence
  156 if [ -d "${IMG_EXTRACT_DIR}" ]; then
  157  printf "\n${SELF}: Found ${IMG_EXTRACT_DIR}. Please cleanup.\n"
  158  cleanup
  159  exit 6
  160 else
  161  mkdir "${IMG_EXTRACT_DIR}"
  162 fi
  163 
  164 # extract image content
  165 CMD_EXTRACT="${RELENG_XORRISO} -indev ${TMP_DATA_DIR}/${REMOTE_IMG} \
  166         -osirrox on:auto_chmod_on \
  167     -extract / ${IMG_EXTRACT_DIR} \
  168 "
  169 
  170 # TODO: drop set +e|-e block, catch exit code instead when 
  171 #       the boot catalog warnings get completely resolved.
  172 echo -e "${SELF}: Extracting ISO image:\n${CMD_EXTRACT}\n"
  173 set +e
  174 ${CMD_EXTRACT}
  175 set -e
  176 
  177 # grab an MBR
  178 ISOHYBRID_MBR="${GEN_DATA_DIR}/isohybrid.mbr"
  179 dd if="${TMP_DATA_DIR}/${REMOTE_IMG}" bs=1K count=32 of="${ISOHYBRID_MBR}"
  180 
  181 # create FAT partition
  182 APPEND_PART="${GEN_DATA_DIR}/fatpart.fat"
  183 MKFS_MSDOS="/sbin/mkfs.msdos"
  184 if [ -x "${MKFS_MSDOS}" ]; then
  185  "${MKFS_MSDOS}" -n Bla -C "${APPEND_PART}" 8192
  186  APPEND_PART_CMD="-append_partition 2 0x01 ${APPEND_PART}"
  187 else
  188  APPEND_PART_CMD=
  189 
  190 #  printf "\nFAIL : ${SELF} : Not found: ${MKFS_MSDOS}"
  191 #  printf "\n${SELF}: Not found: "${MKFS_MSDOS}". Install dosfstools."
  192 #  printf "\n${SELF}: http://www.daniel-baumann.ch/software/dosfstools/\n"
  193 #  cleanup
  194 #  exit 7
  195 fi
  196 
  197 # GENERAL section
  198 CMD="${RELENG_XORRISO} \
  199  -as mkisofs \
  200  -quiet \
  201  -o ${GEN_DATA_DIR}/${RELENG_IMG}.iso \
  202  -R \
  203  -V ISOJIGDO \
  204  -partition_offset 16 \
  205  -J -joliet-long \
  206 "
  207 
  208 # BOOT section
  209 if [ -f "${IMG_EXTRACT_DIR}"/"${RELENG_ISOLINUX_BIN}" -a -f "${ISOHYBRID_MBR}" ]
  210 then
  211 CMD="$CMD \
  212  -b ${RELENG_ISOLINUX_BIN} \
  213  -c ${RELENG_BOOT_CAT} \
  214  -no-emul-boot -boot-load-size 4 -boot-info-table \
  215  -isohybrid-mbr ${ISOHYBRID_MBR} \
  216  -partition_offset 16 \
  217 "
  218 else
  219  printf "\n${SELF}: FAIL to compose the boot section.\n"
  220  cleanup
  221  exit 8
  222 fi
  223 if [ -n "${APPEND_PART_CMD}" -a -f "${APPEND_PART}" ]; then
  224 CMD="$CMD \
  225  ${APPEND_PART_CMD} 
  226 "
  227 fi
  228 
  229 # JIGDO section
  230 JIGDO_JIGDO=${GEN_DATA_DIR}/${RELENG_IMG}.jigdo
  231 JIGDO_TEMPLATE=${GEN_DATA_DIR}/${RELENG_IMG}.template
  232 
  233 JIGDO_MAP_RHV=$(cd ${RELENG_DIR} 2>/dev/null && pwd)
  234 
  235 JIGDO_MAP="Debian=${JIGDO_MAP_RHV}/"
  236 
  237 # create jigdo MD5 list in base64 format
  238 JIGDO_GEN_MD5=${GEN_DATA_DIR}/${RELENG_IMG}.md5
  239 
  240 printf "${SELF}: Creating $checksum_type list in hex format in ${JIGDO_GEN_MD5}..."
  241 set +e
  242 ./jigdo-gen-md5-list "--""$checksum_type" ${RELENG_DIR} > ${JIGDO_GEN_MD5}
  243 ret=$?
  244 set -e
  245 
  246 if test "$ret" = 0
  247 then
  248   printf "Done.\n"
  249 else
  250   printf "\nFAIL : ${SELF}: ./jigdo-gen-md5-list returns $ret"
  251   cleanup
  252   exit 9
  253 fi
  254  
  255 
  256 CMD="$CMD \
  257  -jigdo-template-compress gzip \
  258  -jigdo-checksum-algorithm "$checksum_type" \
  259  -checksum_algorithm_iso md5,sha1,sha256,sha512 \
  260  -checksum_algorithm_template md5,sha1,sha256,sha512 \
  261  -jigdo-jigdo ${JIGDO_JIGDO} \
  262  -jigdo-template ${JIGDO_TEMPLATE} \
  263  -jigdo-map ${JIGDO_MAP} \
  264  -checksum-list ${JIGDO_GEN_MD5} \
  265  -jigdo-min-file-size 1024 \
  266 "
  267 
  268 CMD="$CMD ${RELENG_DIR}"
  269 
  270 # Run the whole compound command
  271 echo -e "${SELF}: Creating ISO and jigdo representations:\n$CMD\n"
  272 ${CMD}
  273 
  274 # Create another imange this time from jigdo files
  275 if which jigit-mkimage >/dev/null 2>&1; then
  276  printf "${SELF}: Creating new ISO from jigdo files..."
  277  jigit-mkimage \
  278   -t ${JIGDO_TEMPLATE} \
  279   -j ${JIGDO_JIGDO} \
  280   -m ${JIGDO_MAP} \
  281   -o ${GEN_DATA_DIR}/${RELENG_IMG}.new
  282  printf "Done.\n"
  283 else
  284  printf "\n${SELF}: Not found: jigit-mkimage. Install jigit."
  285  printf "\n${SELF}: http://www.einval.com/~steve/software/JTE/\n"
  286  cleanup
  287  exit 10
  288 fi
  289 
  290 # trap the exit code of diff and let the Universe explode
  291 diff ${GEN_DATA_DIR}/${RELENG_IMG}.iso ${GEN_DATA_DIR}/${RELENG_IMG}.new
  292 DIFF_RET="$?"
  293 case ${DIFF_RET} in
  294      0)
  295       echo -e "${SELF}: Match: diff ${GEN_DATA_DIR}/${RELENG_IMG}.iso ${GEN_DATA_DIR}/${RELENG_IMG}.new"
  296      ;;
  297      *)
  298       echo -e "FAIL : ${SELF} : diff returned code: $DIFF_RET\n"
  299      ;;
  300 esac
  301 
  302 # sort out the cruft
  303 cleanup
  304 
  305 # warn about downloaded image left behind
  306 if [ -f "${TMP_DATA_DIR}"/"${REMOTE_IMG}" ]; then
  307  printf "${SELF}: Leaving "
  308  ls -sh "${TMP_DATA_DIR}"/"${REMOTE_IMG}"
  309 fi
  310 
  311 # last hints
  312 if [ -d ${GEN_DATA_DIR} ]; then
  313  printf "\n${SELF}: HINT: manual checks remained to be done:\n"
  314  printf " * ${GEN_DATA_DIR}/${RELENG_IMG}.iso boots from USB stick and/or optical media.\n"
  315  printf " * appended FAT partition is mountable.\n"
  316  printf " * xorriso -indev ${GEN_DATA_DIR}/${RELENG_IMG}.iso -pvd_info\n"
  317  printf " * fdisk -lu ${GEN_DATA_DIR}/${RELENG_IMG}.iso\n"
  318 fi
  319 
  320 exit 0