You are not logged in.

#21 2024-06-14 05:47:15

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Re: Getting into Debian packages

workflow 3 - update changelog

We don't want to hit users with package upgrades every day, especially on the current released version, and especially if the package is a big download (like bunsen-images). OTOH bugfixes should go out promptly, and if a package has picked up some useful improvements then it's time to do a package upgrade.

That's done by adding a new entry to debian/changelog. Making a new changelog entry is saying "time to release a new package version". You don't have to write it by hand because there's a handy utility dch which comes with devscripts.
There's a long manpage which you can read at leasure, but for now I find 'dch -D carbon' (or boron etc) does it most of the time.

You still have to update the version number and add some change messages by hand though.

For message formatting, look at previous entries. It's usually [space][space]*[space]Then the message, but check out the variations.

The version number needs a little care.
BL package versions start with the release number, which follows Debian, so Debian 12 / Bookworm / Boron package versions start with 12.
You can read about Debian package versions, but for our purposes a typical Boron package version might be 12.1.2-1. The last number after the hyphen is the "debian_revision" and refers back to the upstream vs maintainer thing. Upstream provide the software version and the maintainer increases the debian_revision every time he/she changes something inside debian/ Here at BL we're usually changing the software, so the software version goes up and debian_revision stays at 1. An exception is the metapackages, where if nothing outside debian/ changes, but the dependecies in debian/control are edited, then the software version stays the same and debian_version goes up by one. Again, look at existing BL packages, you'll soon get the idea.

In order for dch to know your name email etc it helps to have an entry like this in your ~/.bashrc:

# for debian changelogs
export DEBEMAIL="*****@bunsenlabs.org"
export DEBFULLNAME="John Crawley"

(My name is anywhere in the BL code so pointless to hide it here.)
https://www.debian.org/doc/manuals/debm … 03.en.html

Here's an example, the last two changelog entries in bunsen-common:

bunsen-common (12.1.5-1) boron; urgency=medium

  * bl-includes: make apt error messages available for display to user.

 -- John Crawley <john@bunsenlabs.org>  Thu, 11 Jan 2024 15:43:38 +0900

bunsen-common (12.1.4-1) boron; urgency=medium

  * Apt functions: use a temporary file to capture stderr.
     This works round change in sudo behaviour in Debian bug #657784.

 -- John Crawley <john@bunsenlabs.org>  Thu, 28 Sep 2023 17:04:01 +0900

The version number will almost certainly need editing.
The maintainer's name and email are picked up automatically from the entries you put in ~/.bashrc.
The package checker "Lintian" will look to see if the name is the same as given in debian/control:

Maintainer: John Crawley <john@bunsenlabs.org>

In this case it is. (If even the email is different then a "non-maintainer upload" is assumed.)
The date is also automatically added.
"Urgency" can be left at default "medium" most of the time.
The actual messages should be written with users in mind, so only put in what you expect will be important to them.
Contrast with the git log which is for developers and covers every detail. Here's the git log covering those two package upgrades:

commit 1f382a84afb89fc738a53d976e5a0eb7906a480b (HEAD -> boron, origin/boron)
Author: John Crawley <john@bunsenlabs.org>
Date:   Thu Jan 11 15:49:16 2024 +0900

    Update changelog: ver. 12.1.5-1

commit 6147ec611da73090898eec01f97313ea73958b06
Author: John Crawley <john@bunsenlabs.org>
Date:   Thu Jan 11 15:43:34 2024 +0900

    Update copyright year

commit d73a9d1959db015133805624e5b8d85965a8a11f
Author: John Crawley <john@bunsenlabs.org>
Date:   Thu Jan 11 15:42:13 2024 +0900

    bl-includes: apt safe* functions: keep error message for display if wanted

commit 0f469af8443027cc54660e8a5f3209133e2dc2e0
Author: John Crawley <john@bunsenlabs.org>
Date:   Fri Dec 1 15:28:00 2023 +0900

    Update copyright year

commit b5e3b57d04a0c1618b9fb9024edb4c562b6671fe
Author: John Crawley <john@bunsenlabs.org>
Date:   Fri Sep 29 11:53:38 2023 +0900

    Update copyright year

commit b5e3b57d04a0c1618b9fb9024edb4c562b6671fe
Author: John Crawley <john@bunsenlabs.org>
Date:   Fri Sep 29 11:53:38 2023 +0900

    Update changelog: ver. 12.1.4-1

commit b16e52588de38e4b549a61f18d692072dcd301f4
Author: John Crawley <john@bunsenlabs.org>
Date:   Thu Sep 28 17:03:47 2023 +0900

    bl-includes: apt functions: use tempfile instead of redirection to capture stderr

commit 954d8baa666ba948ac8bbc2ea8cb2f294f85cec6
Author: John Crawley <john@bunsenlabs.org>
Date:   Thu Sep 28 15:35:19 2023 +0900

    bl-install: send_return(): return appropriate value if no file is available for writing

When the changelog is updated you'll want to commit it to git (try that gch alias?) and push it to the server. At that point the person responsible for building and uploading packages will take over.

The debian package building scripts pay a lot of attention to what's in debian/changelog so be sure to get it right!

Last edited by johnraff (2024-10-22 04:48:46)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#22 2024-06-14 06:58:21

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Re: Getting into Debian packages

workflow 4 - build the package

Right now I'm happy to go on doing this, just as @nobody used to do it for my packages, because it's automated and very little work.

But OTOH it's nice for anybody to be able to build their own Debian packages, eg for things like backports or packages they needed to tweak in order to install, so I'll post some details of what I do.

There are many ways to build packages, some basic and some complicated. I use pbuilder which might be in between. It builds in a chroot which is freshly created each time it's used. That means if the build works then it isn't because of some obscure package that you installed two years ago, but the source code is OK. Also it doesn't clog your personal system up with dozens of *-dev packages that you had to install just to build some package you've now forgotten about. The two worlds are kept separate. Other ways of doing the same thing might be to use a container like lxc or even a virtual machine...

I had to do a lot of manual reading to get this working - not just pbuilder but the tools it uses like debuild and dpkg-buildpackage. Finally I put it in a script so I wouldn't have to remember every time I built a package. If anyone felt like installing pbuilder with its recommends, then try running this script inside a package source directory (use the --unsigned option unless you want to upload to a repo and set up GPG):

#!/bin/bash

set -o nounset # do not accept unset variables

HELP="Script to build a Debian package from the directory tree,
in a clean chroot using pbuilder.

SUMMARY:    pbuild [options]

Architecture is amd64 by default, can be changed by option.

Distribution is determined from package changelog,
or set manually via -d option.
(supported: buster|bullseye|bookworm|trixie)

Package is signed by default, disabled by option.

OPTIONS:
            -a, --arch <arch>
Where <arch> is amd64 or i386

            -d, --dist <dist>
Where <dist> is buster, bullseye, bookworm or trixie

            -u, --unsigned
Do not sign the package.

            -n, --no-source
Build binary only, no source files.
(Use this option also when adding a second architecture or backport
 and source is already built.)

            -k, --keep-temp
Do not remove the temporary source directory after building.
(See NOTE below.)

            -b, --basefile <filepath>
Use custom <filepath> instead of the standard
/var/cache/pbuilder/base-<dist>-<arch>.tgz
This is for special modified pbuilder chroots.
Make sure <dist> and <arch> are set correctly!

            -h, --help
Output this message.

---
You might consider creating ~/.pbuilderrc for some customization.
Example:

MIRRORSITE=https://deb.debian.org/debian
COMPONENTS='main contrib non-free'
HOOKDIR='/var/cache/pbuilder/hooks'
export EDITOR='nano'
export DH_VERBOSE=1
SOURCE_ONLY_CHANGES=no

NOTE: This script uses the pdebuild option --use-pdebuild-internal
which avoids interfering with the host system, but results in extra files
being added to the source directory during the build.
To keep the original source clean, it is copied to a temporary directory
and pdebuild is run from there.
Pass the --keep-temp option to avoid removing that directory after the build,
in case there might be something there you want to look at or use.
"
# Check over all these configuration options:

# fallbacks
dist=boron
arch=amd64

# pbuilder base file
# -${dist}-${arch}.tgz will be appended
# Make sure such files exist!
# e.g. sudo pbuilder create --distribution stretch --architecture amd64 --basetgz /var/cache/pbuilder/base-stretch-amd64.tgz --debootstrapopts --variant=buildd
base_stem='/var/cache/pbuilder/base'

# This script should be run inside a Debian source directory.
source_dir="${PWD}"

# where to put built files
# See lines 230~233 to set other dir based on package name, architecture, etc.
# Set logfile there too.
results_dir="${source_dir%/*}" # parent directory

# Source directory will be copied here so original source is not modified.
# ( pdebuild --use-pdebuild-internal adds a lot of extra files from the build process )
# can also use system /tmp
#temp_dir="${HOME}/tmp/pbuild"
#temp_dir=/tmp/pbuild
# EDIT THIS!
# (symlinks in path seem to break build, so use canonical path)
temp_dir=/bulk/john/tmp/pbuild
mkdir -p "$temp_dir"

########## end configuration options, except line 230 ##################
########################################################################

required_commands='pdebuild pbuilder debuild dpkg-parsechangelog lintian'

error_exit() {
    echo "$0 ERROR: $1" >&2
    [[ -n "${logfile-}" ]] && echo "ERROR: $1" >> "$logfile"
    echo "(You may have to clean up ${temp_dir})" >&2
    exit 1
}
warning() {
    echo "$0 WARNING: $1"$'\n' >&2
    [[ -n "$logfile" ]] && echo "WARNING: $1" >> "$logfile"
}

log() {
    echo "$1"$'\n'
    [[ -n "$logfile" ]] && echo "$1"$'\n' >> "$logfile"
}

confirm() {
    echo "$*"
    echo '(Enter to agree, any other key to decline.)'
    read -srn1
    [[ -n $REPLY ]] && {
        [[ -n "$logfile" ]] && echo "$*"$'\nUser declined.' >> "$logfile"
        return 1
    }
    [[ -n "$logfile" ]] && echo "$*"$'\nUser agreed.' >> "$logfile"
    return 0
}

missing_commands=
for i in $required_commands
do
    hash "$i" || missing_commands+=" $i"
done
[[ $missing_commands ]] && error_exit "This script requires the following commands: $missing_commands
Please install the packages containing the missing commands
and rerun the script."

dist_warning=false
pkg_dist=$(dpkg-parsechangelog --show-field Distribution)
case $pkg_dist in
lithium|buster)
    dist=buster
    ;;
beryllium|bullseye)
    dist=bullseye
    ;;
boron|bookworm)
    dist=bookworm
    ;;
carbon|trixie)
    dist=trixie
    ;;
*)
    dist_warning=true
    # but dist might be declared in command line option
    ;;
esac

sign_pkg=true
build_source=true
keep_temp=false
basefile=

while [[ -n ${1-} ]]
do
    case ${1-} in
    --dist|-d)
        dist=$2
        shift 2
        ;;
    --arch|-a)
        arch=$2
        shift 2
        ;;
    --unsigned|-u)
        sign_pkg=false
        shift
        ;;
    --no-source|-n)
        build_source=false
        shift
        ;;
    --keep-temp|-k)
        keep_temp=true
        shift
        ;;
    --basefile|-b)
        basefile=$2
        shift 2
        ;;
    --help|-h)
        echo "$HELP"
        exit
        ;;
    *)
        error_exit "${1}: no such option"$'\n'"$HELP"
        ;;
    esac
done

case $dist in
buster|bullseye|bookworm|trixie)
    :;;
*)
    error_exit "Distribution $dist not supported"
    ;;
esac

case $arch in
amd64|i386)
    :;;
*)
    error_exit "Architecture $arch not supported"
    ;;
esac

[[ -z $basefile ]] && basefile=${base_stem}-${dist}-${arch}.tgz

[[ -f "${basefile}" ]] || error_exit "basefile ${basefile} not found"

# in Debian source directory?
[[ -f debian/changelog ]] || error_exit 'No file debian/changelog (wrong directory?)'

pkg_name=$(dpkg-parsechangelog --show-field Source)
[[ "${PWD##*/}" = ${pkg_name}* ]] || error_exit "The parent directory (${PWD##*/})
is not named after the package (${pkg_name}).
Most Debian packaging tools expect this."

pkg_ver=$(dpkg-parsechangelog --show-field Version)

# SET RESULTS DIR
# alternative destination, eg:
#results_dir="${results_dir}/result-${arch}"
mkdir -p "$results_dir"

logfile="$results_dir/${pkg_name}_${pkg_ver}_${arch}.build"

[[ $dist_warning = true ]] && warning "Package declares unsupported distribution: $pkg_dist"

log "Building ${pkg_name} ${pkg_ver} on ${dist} for architecture ${arch}."

sign_arg='--auto-debsign'
if [[ $sign_pkg != true ]]
then
    sign_arg=
    warning 'Package will not be signed.'
fi

debbuildopts=('-sa')
if [[ $build_source != true ]]
then
    debbuildopts=('-b')
    warning 'Building binary only.'
fi

log "
Using pdebuild with ${basefile}...
"

echo "Press Enter to continue, any other key to exit:"
read -srn1
[[ -n $REPLY ]] && exit

echo "Would you like to refresh the pbuilder base archive first? (N/y)"
read -r
case ${REPLY^} in
Y)
    log "Updating ${basefile}..."
    sudo pbuilder update --distribution "${dist}" --architecture "${arch}" --basetgz "${basefile}" --debootstrapopts --variant=buildd
    ;;
esac

make_orig=true
log "creating orig.tar.gz..."$'\n'
origname="${pkg_name}_${pkg_ver%-*}.orig.tar.gz"
if [[ -f ../$origname ]]
then
    confirm "../$origname exists. Overwrite?" || make_orig=false
fi
[[ $make_orig = true ]] && tar -caf ../"${origname}" --exclude=debian --exclude-vcs --exclude-vcs-ignores .

temp_source_dir="${temp_dir}/${pkg_name}"

log "copying contents of $source_dir to $temp_source_dir ..."
rsync -ra --exclude=.git --exclude=.gitignore "${source_dir}"/ "$temp_source_dir"

log "copying ${origname} to ${temp_dir}"
cp ../"${origname}" "${temp_dir}"

log "moving to $temp_source_dir"
cd "$temp_source_dir" || error_exit "Failed to move to $temp_source_dir"

pdebuild --use-pdebuild-internal $sign_arg --architecture "${arch}" --buildresult "$results_dir" --logfile "${logfile}.pbuild" --debbuildopts "${debbuildopts[@]}" -- --basetgz "${basefile}" || error_exit "pdebuild failed"

log "returning to $source_dir"
cd "${source_dir}" || error_exit "Failed to move back to $source_dir"

cat "${logfile}.pbuild" >> "${logfile}" || error_exit "failed to merge ${logfile}.pbuild with ${logfile}"
rm "${logfile}.pbuild"

#log 'running debc'
#debc | tee -a "$logfile"

log 'running Lintian...'
lintian --pedantic --info "$results_dir/${pkg_name}_${pkg_ver}_${arch}.changes" | tee -a "$logfile"

if [[ $keep_temp = false ]]
then
    log "Removing temporary build directory ${temp_dir} (pass option --keep-temp to keep)."
    rm -rf "${temp_dir}"
else
    log "Temporary build directory ${temp_dir} remains."
fi

Last edited by johnraff (2024-06-14 07:02:15)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#23 2024-06-14 07:39:50

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Re: Getting into Debian packages

workflow 5 - put in the repository

Even more than building, I think this is something I should continue doing for now because the reprepro software needs to sign the repo after every addition, so that users' apts will recogize it as legit. Reprepro needs to have access to the signing key - this is simple when it's running on the computer of the owner of the key, but for two devs to be able to sign the repo means that reprepro has to have access to both keys. Dev B has to trust dev A with their signing key, or else both keys have to be uploaded to a server where the repo generation and signing take place. Complication.

Even so, if anyone wants to play with setting up a personal Debian repository, and putting built (and signed by the maintainer) packages into it, this is the script I use to add an upgraded package:

#!/bin/bash
# Script to add some .changes and .deb files
# to a local reprepro repository, then sync with publish-blng.sh or rsync
# to remote server.

# EDIT THIS!
local_repo_path='/data/john/git/blng-packages'

# EDIT THIS
# move local files here after upload
archive_dir_root='/data/john/projects'
# files will go in $archive_dir_root/$dist/packages-blng

# (dist now auto-detected if in debian tree, or override with cli option)
# default:
dist=boron

HELP="Add some .changes .deb and source files to a local reprepro repository.
Then sync with rsync to remote.

SUMMARY:    debup [options] file.changes [file...]
Takes a list of one or more signed .changes files.
The files listed therein will also be processed.

OPTIONS:
            --upload-only|-u
Perform 'reprepro export' in case signing failed last time,
then synchronize remote repo with local, via publish script or ssh.
Do not alter the local repository in any other way.

            --queue|-q
Do not upload, only add files to local repository.
This may be useful if processing multiple packages.

--upload-only and --queue are contradictory.
If both are passed, the script will exit with an error.

            --dist lithium [files...]
Put uploaded files in $archive_dir_root/lithium/packages-blng instead of ${dist}.

            -h | --help
Output this message.

If no arguments remain after processing the above options,
it will look for a .changes file in the parent directory.
"

########################################################################

# launch in terminal if one is not connected
terminal=x-terminal-emulator
[ -t 1 ] && [ -t 0 ] || {
    exec $terminal -e "$0" "$@"
    exit 1
}

required_commands='ssh scp gpg rsync reprepro'

trap 'echo "press any key to exit"; read -sn1;' EXIT
# see shoutcast_radionomy_search.sh for more

error_exit() {
    echo "$0 error: $1" >&2
    exit 1
}

confirm() {
    echo "$*"
    echo '(Enter to agree, any other key to decline.)'
    read -srn1
    [[ -n $REPLY ]] && {
        return 1
    }
    return 0
}

missing_commands=
for i in $required_commands
do
    hash "$i" || missing_commands+=" $i"
done
[[ $missing_commands ]] && error_exit "This script requires the following commands: $missing_commands
Please install the packages containing the missing commands
and rerun the script."

# passed .changes file, returns names of files under "Files:"
get_files(){
    awk 'BEGIN{
        FS="[ \t]+"
        pr=0
    }
    /Files:/{
        pr=1
        next
    }
    pr{
        if($1){
            exit
        }
        print $NF
    }' "$1"
}

upload_only=false
queue=false
xdist=

while [[ -n ${1} ]]
do
    case $1 in
    -u|--upload-only)
        upload_only=true
        shift
        ;;
    -q|--queue)
        queue=true
        shift
        ;;
    --dist)
        xdist="$2"
        shift 2
        ;;
    --help|-h)
        echo "$HELP"
        exit
        ;;
    -*)
        echo "${1}: no such option"
        exit 1
        ;;
    *)
        break
        ;;
    esac
done

upload() {
    [[ -n "$SSH_AUTH_SOCK" ]] || error_exit 'ssh-agent not running'
    echo 'Running publish-blng.sh...'
    # FIXME clean this up
    "${HOME}/scripts/publish-blng.sh" -l "$local_repo_path" || error_exit "publish-blng exited with error"
}

archive_pkgs_dir='packages-blng'

local_reprepro_base="${local_repo_path}/reprepro_base"
local_incoming_dir="${local_reprepro_base}/incoming"
# The "debian" directory holding the repo
local_repo_root="${local_repo_path}/debian"

[[ "$upload_only" = true && "$queue" = true ]] && error_exit "Incompatible options: --upload-only and --queue."

##### run actions #####

[[ "$upload_only" = true ]] && {
    confirm 'Is the signing key passphrase on the clipboard?'  || error_exit "Abandoned upload"
    reprepro -b "${local_reprepro_base}" export
    upload || error_exit "Upload failed"
    exit
}

upload_list=()

if [[ -n $* ]]
then
    for i in "$@"
    do
        [[ -f "$i" ]] || error_exit "${i}: not a file."
        [[ $i = *.changes ]] || {
            echo "${i}: not a .changes file, skipping."
            continue
        }
        upload_list+=("$i")
        dir="$(dirname "$i")"
        for file in $(get_files "$i")
        do
            [[ -f "${dir}/${file}" ]] || error_exit "listed file: ${file} not found in ${dir}."
            upload_list+=("${dir}/${file}")
        done
    done
else
    # in Debian source directory?
    [[ -f debian/changelog ]] || error_exit 'No file debian/changelog (wrong directory?)'
    dist=$(dpkg-parsechangelog --show-field Distribution)
    name=$(dpkg-parsechangelog --show-field Source)
    ver=$(dpkg-parsechangelog --show-field Version)
#    namestring=$(dpkg-parsechangelog | awk '/Source:/{src=$2};/Version:/{ver=$2; print src"_"ver;exit}')
    # look for changes file in parent directory
    chfiles=(../"${name}_${ver}"*.changes)
    [[ -f  ${chfiles[0]} ]] || error_exit 'No changes file found in parent directory.'
    [[ ${#chfiles[@]} -eq 1 ]] || error_exit 'More than one changes file found in parent directory.'
    upload_list+=("${chfiles[0]}")
    for file in $(get_files "${chfiles[0]}")
    do
        [[ -f "../${file}" ]] || error_exit "listed file: ${file} not found in parent directory."
        upload_list+=("../${file}")
    done
fi

[[ ${#upload_list[@]} -eq 0 ]] && error_exit 'Upload list is empty!'

echo "Upload list: ${upload_list[*]}
"
echo "Running Lintian..."
for i in "${upload_list[@]}"
do
    [[ $i = *.changes ]] || continue
    lintian --pedantic --fail-on error "$i" || confirm "Lintian rejected $i
Continue anyway?" || error_exit "Abandoned upload"
done

confirm 'Everything OK?
Is the signing key passphrase on the clipboard?' || error_exit "Abandoned upload"

cp "${upload_list[@]}"  "${local_incoming_dir}"

export GPG_TTY=$(tty)
echo 'reprepro: processing incoming files...'
reprepro -b "${local_reprepro_base}" processincoming default || error_exit 'Reprepro error'

if [[ "$queue" = false ]]
then
    echo "Uploading files to server."
    upload || error_exit "Upload failed"
else
    echo "
Reprepro is updated, but files not yet uploaded to server.
Run 'debup --upload-only' to upload reprepro to remote server.
"
fi

[[ -n $xdist ]] && dist=$xdist # cli option overwrites auto-detection or default
archive_dir="${archive_dir_root}/${dist}/${archive_pkgs_dir}"
mkdir -p "$archive_dir"
echo "Moving files to ${archive_dir}..."
mv "${upload_list[@]}" "$archive_dir" || error_exit 'Failed to move uploaded files to archive'

remaining_files=( ../"${name}_${ver%-*}"* ) # omit debian revision number for orig.tar.gz

for i in "${!remaining_files[@]}"
do
    if [[ ${remaining_files[i]} = *.build ]]; then
        mv "${remaining_files[i]}" "$archive_dir" || error_exit "Failed to move build log ${remaining_files[i]} to archive"
        unset 'remaining_files[i]'
    fi
done

(( ${#remaining_files[@]} >= 1 )) && {
    if confirm "Some files remain from the build:
${remaining_files[*]}
Delete them?"
    then
        rm "${remaining_files[@]}"
    else
        echo "files left in parent directory"
    fi
}

exit

But it still might get stuck in corner cases.
And uses yet another script publish-blng.sh to actually publish the repository to our server. I'd better obfuscate the actual file paths in the server, just in case:

#!/usr/bin/env bash

#
# Publishes the repo to the new bl server. This works by keeping an
# incrementally synced copy of the /debian package pool on the server in
# /path/to/file, which is then pushed into the
# 'container' container to the correct location.
#
# This is the publish script which is called by debup.sh
# rather than the one in ~/git/blng-packages/

set -e
set -u

# ssh alias in ~/.ssh/config
HOST=blng
HOST_PATH=/path/to/file
CONTAINER=container
CONTAINER_PATH=/path/to/place

# expect to find 'debian' and 'reprepro_base' directories here
LOCAL_REPO='.'

while getopts "h:c:p:l:" OPT; do
  case "$OPT" in
    h) HOST=$OPTARG ;;
    c) CONTAINER=$OPTARG ;;
    p) CONTAINER_PATH=$OPTARG ;;
    l) LOCAL_REPO=$OPTARG ;;
    *) echo "Unknown option: $OPT"; exit 1; ;;
  esac
done

set -x

reprepro --basedir "$LOCAL_REPO"/reprepro_base check
reprepro --basedir "$LOCAL_REPO"/reprepro_base checkpool

if ! ssh "$HOST" mountpoint /path/to; then
  echo "ERR: LXD place on host seems not to be mounted"
  exit 1
fi

if ! ssh "$HOST" test -d "$HOST_PATH"; then
  echo "INFO: Remote $HOST_PATH does not seem to exist, creating"
  ssh "$HOST" mkdir "$HOST_PATH"
  ssh "$HOST" chmod 0700 "$HOST_PATH"
fi

echo "Uploading /debian/dists..."
rsync --delete --recursive --progress --update "$LOCAL_REPO"/debian/dists "$HOST:$HOST_PATH/debian/"
echo "Uploading /debian/pool..."
rsync --delete --recursive --progress --update "$LOCAL_REPO"/debian/pool "$HOST:$HOST_PATH/debian/"

echo "Copying data into container..."
container_tempdir=$(ssh "$HOST" lxc exec "$CONTAINER" -- mktemp -d)
ssh "$HOST" lxc file push -r -q "$HOST_PATH"/debian "${CONTAINER}$container_tempdir/"
echo "Updating repo from temporary directory..."
ssh "$HOST" lxc exec "$CONTAINER" -- rsync --recursive --checksum --progress --delete --chmod=F644,D755 "${container_tempdir}/debian" "$CONTAINER_PATH"

# Clean up temporary directory.
ssh "$HOST" lxc exec "$CONTAINER" -- rm -rf -- "$container_tempdir"

...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#24 2024-06-16 16:57:00

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,032
Website

Re: Getting into Debian packages

Just wanted to say thanks for the excellent guide, I'll be delving into it this week. smile


No, he can't sleep on the floor. What do you think I'm yelling for?!!!

Offline

Board footer

Powered by FluxBB