Package: debirf
Version: 0.34
Severity: wishlist

Dear Maintainer,

I wonder if there is a recommended way to make use of local repositories
when building a debirf instance, and if it is worth mentioning in the
documentation.

The debootstrap step has some support for one local repository (a "file:///"
prefix in DEBIRF_MIRROR), but this doesn't work when running modules :

| W: Failed to fetch 
file:/home/me/my_local_repository/dists/jessie/main/binary-amd64/Packages  File 
not found

I use the two modules a0_prep-local-repository and z1_clean-local-repository
below, with two ancillary modules to set up /etc/apt/sources.list :

a0_add-local-repository :
| #!/bin/sh -e
| mv "$DEBIRF_ROOT"/etc/apt/sources.list "$DEBIRF_ROOT"/tmp/sources.list.bak
| echo "deb [ trusted=yes ] file:///home/me/my_local_repository jessie main" > 
"$DEBIRF_ROOT"/etc/apt/sources.list

and z1_remove-local-repository :
| #!/bin/sh -e
| mv -f "$DEBIRF_ROOT"/tmp/sources.list.bak "$DEBIRF_ROOT"/etc/apt/sources.list

Is there a better/easier way ?

Regards,
JH Chatenet

File : a0_prep-local-repository
-----------8<-------------------8<-------
#!/bin/sh -e

# debirf module: prep-local-repository
#
#  make copy or file uri in /etc/apt/sources.list* available
#

create_mountpoint() {
    target="$1"

    if [ "$ROOT_BUILD" = 'true' ]; then
        mkdir -p "${DEBIRF_ROOT}/tmp/debirf_temporary/mounts/$count"
        mount --bind "$target" 
"${DEBIRF_ROOT}/tmp/debirf_temporary/mounts/$count"
    else
        ln -s "$target" "${DEBIRF_ROOT}/tmp/debirf_temporary/mounts/$count"
    fi
}

count=0
mkdir -p "${DEBIRF_ROOT}/tmp/debirf_temporary/mounts"
mkdir -p "${DEBIRF_ROOT}/tmp/debirf_temporary/sources/sources.list.d"

for source_file in "${DEBIRF_ROOT}/etc/apt/sources.list" \
  $(find "${DEBIRF_ROOT}"/etc/apt/sources.list.d/ -type f -name '*.list'); do
    if ! $(grep -q  '^deb\s\+\(\[ .* \]\s\+\)*\(copy\|file\)' "$source_file"); 
then
        continue
    fi
    mv "$source_file" "${source_file}.original"

    while read deb_type other_fields; do
        old_target=

        if [ "$deb_type" = "deb" ]; then
            deb_option="$(echo $other_fields | grep -o '^\[.*\]')" || true
            after_option="$(echo $other_fields | sed 's|^\[.*\]\s\+||')"
            deb_uri="${after_option%% *}"
            rest_of_line="${after_option#${deb_uri} }"

            case "$deb_uri" in
                file:/*)
                    uri_type="file"
                    old_target="${deb_uri#file:}"
                    ;;
                copy:/*)
                    uri_type="copy"
                    old_target="${deb_uri#copy:}"
            esac
        fi

        if [ -z "$old_target" ]; then
            echo "${deb_type} ${other_fields}" >> "$source_file"
        else
            echo "$deb_type${deb_option:+ $deb_option} 
${uri_type}:/tmp/debirf_temporary/mounts/${count} $rest_of_line" >> 
"$source_file"
            create_mountpoint "$old_target"
            count=$(($count + 1))
        fi

    done < "${source_file}.original"

    mv "${source_file}.original" 
"${DEBIRF_ROOT}/tmp/debirf_temporary/sources/${source_file#${DEBIRF_ROOT}/etc/apt/}.original"
done
-----------8<-------------------8<-------

File : z1_clean-local-repository
-----------8<-------------------8<-------
#!/bin/sh -e

# debirf module: clean-local-repository
#
#  make copy or file uri in /etc/apt/sources.list* available
#

# clean sources.list

find "${DEBIRF_ROOT}/tmp/debirf_temporary/sources/" -type f -name 
'*.list.original' |\
  while read source_file;do
    dest="${source_file#${DEBIRF_ROOT}/tmp/debirf_temporary/sources/}"
    mv -f "$source_file" "${DEBIRF_ROOT}/etc/apt/${dest%.original}"
  done

# remove temporary mount points

if [ "$ROOT_BUILD" = 'true' ]; then
    find "${DEBIRF_ROOT}/tmp/debirf_temporary/mounts" -maxdepth 1 -type d 
-regex '.*/[0-9]+$' |\
      while read debirf_mountpoint;do umount "$debirf_mountpoint";done
else
    find "${DEBIRF_ROOT}/tmp/debirf_temporary/mounts" -maxdepth 1 -regex 
'.*/[0-9]+$' |\
      while read debirf_mountpoint;do
        if [ -h "$debirf_mountpoint" ];then
            rm -f "$debirf_mountpoint"
        fi
      done
fi

[ -d "${DEBIRF_ROOT}/tmp/debirf_temporary" ] && rm -rf 
"${DEBIRF_ROOT}/tmp/debirf_temporary"
-----------8<-------------------8<-------



-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages debirf depends on:
ii  apt          1.0.9.3
ii  cpio         2.11+dfsg-2
ii  debootstrap  1.0.64
ii  fakechroot   2.17.2-1
ii  fakeroot     1.20.2-1
ii  klibc-utils  2.0.4-2

Versions of packages debirf recommends:
ii  grub-common  2.02~beta2-15
ii  lsb-release  4.1+Debian13+nmu1
ii  xorriso      1.3.2-1.1

debirf suggests no packages.

-- no debconf information


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to