Skip to content

Conversation

@mihai-stancu
Copy link

First step towards allowing apt-bundle to be used as a library is splitting the functions.

I've created this draft PR with functionality split -- not much attention to function names, I just wanted to get the ball rolling.

@mihai-stancu mihai-stancu force-pushed the split_main branch 6 times, most recently from fcf6fa0 to 65f315e Compare January 12, 2026 11:08
Comment on lines -26 to -28
Verbose=
DryRun=

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these may have been initialized here, empty, as documentation / for developer awareness of their existence.

LMK if you want them restored.

Comment on lines +54 to +56
initialize
main_prerequisites;
return
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user is sourcing apt-bundle then the temporary directory & files need to be present in order for any of the subsequent source / package statements to work.

Prerequisites are also obviously necessary.

Prerequisites leverage the same system for installing packages so they need the same temp directory & files.

Comment on lines +77 to +73
cat -- "$@" > "$TmpDir/Debfile"
. "$TmpDir/Debfile"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user is sourcing apt-bundle then the calling script is the Debfile (sort of).
Meaning we can't copy & source the entire (list of) Debfiles into the temp dir.

We have to let the user invoke source/package and eventually a "flush" function (not yet defined).

}

main() {
local opt file destdir filename dest tmpfile ppa
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variables within this declaration became unused after extraction.

Replaced with local varname= in their respective functions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: AFAIK sh doesn't have local variables, or even the keyword itself.

Most of the time sh is actually an aliased bash with a compatibility flag enabled and bash gives it the local keyword even though POSIX sh doesn't support it.

return
fi

set -e
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exit on first error can be enabled from the shebang #!/bin/sh -e, is this not useful?

@mihai-stancu mihai-stancu marked this pull request as ready for review January 13, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant