__package_apt to accept .dpk files directly #340

Open
fancsali wants to merge 1 commit from fancsali/cdist:package-apt-dpkg into master
3 changed files with 25 additions and 3 deletions
cdist/conf/type/__package_apt

View file

@ -101,10 +101,26 @@ if [ ! -f /var/cache/apt/pkgcache.bin ] || [ "\$( stat --format %Y /var/cache/ap
then echo apt-get $apt_opts update > /dev/null 2>&1 || true then echo apt-get $apt_opts update > /dev/null 2>&1 || true
fi fi
EOF EOF
if [ -n "$version" ]; then if [ -f "$__object/parameter/source" ]; then
name="${name}=${version}" source_path="$(cat "$__object/parameter/source")"
tempfile="$($__remote_exec $__target_host "mktemp -t cidst.XXXXX.${source_path##*/}")"
# IPv6 fix
if echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$'
then
my_target_host="[${__target_host}]"
else
my_target_host="${__target_host}"
fi
$__remote_copy "$source_path" "${my_target_host}:$tempfile"
echo "$aptget $recommendsparam install $tempfile"
Review

Interesting. And how is the tempfile removed eventually?

Interesting. And how is the tempfile removed eventually?
Review

Well, I reckon, the OS will remove it eventually; wouldn't it?

Well, I reckon, the OS will remove it eventually; wouldn't it?
Review

No, why would it? It's a file we copied and in case we use this type a lot, we will have a lot of leftovers. I don't think this is a clean implementation, TBH.

No, why would it? It's a file we copied and in case we use this type a lot, we will have a lot of leftovers. I don't think this is a clean implementation, TBH.
Review

Well, according to the FHS, it sortof does: "Programs must not assume that any files or directories in /tmp are preserved between invocations of the program." (https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#tmpTemporaryFiles)

Of course, the ones stored in /var/tmp are removed less frequently, as per "5.15. /var/tmp : Temporary files preserved between system reboots" (https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#vartmpTemporaryFilesPreservedBetwee).

I do recall, there was lots of debate around how cdist should clean up after itself, but I can't remember the outcome of that discussion - if it's been decided that this is the official policy now, I am happy to add that. It's just, looking at the other types, it didn't seem so...

Well, according to the FHS, it sortof does: "Programs must not assume that any files or directories in /tmp are preserved between invocations of the program." (https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#tmpTemporaryFiles) Of course, the ones stored in `/var/tmp` are removed less frequently, as per "5.15. /var/tmp : Temporary files preserved between system reboots" (https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#vartmpTemporaryFilesPreservedBetwee). I do recall, there was lots of debate around how `cdist` should clean up after itself, but I can't remember the outcome of that discussion - if it's been decided that this is the official policy now, I am happy to add that. It's just, looking at the other types, it didn't seem so...
Review

I would like to see this feature added.

If all it takes for @nico to accept it is to rm the tmp file, @fancsali, shall I add that?

I would like to see this feature added. If all it takes for @nico to accept it is to rm the tmp file, @fancsali, shall I add that?
Review

Go ahead, the pull request is already 2 years old. I'd also like to see a better comment than 'Fix IPv6' on line 108 - there's no bug, we just (re)format IPv6 addresses as needed.

Go ahead, the pull request is already 2 years old. I'd also like to see a better comment than 'Fix IPv6' on line 108 - there's no bug, we just (re)format IPv6 addresses as needed.
Review

I am somewhat snowed under atm, so feel free to adjust the code, ladies and gents...

I am somewhat snowed under atm, so feel free to adjust the code, ladies and gents...
else
if [ -n "$version" ]; then
name="${name}=${version}"
fi
echo "$aptget $recommendsparam install $target_release '$name'"
fi fi
echo "$aptget $recommendsparam install $target_release '$name'"
echo "installed" >> "$__messages_out" echo "installed" >> "$__messages_out"
;; ;;
absent) absent)

View file

@ -38,6 +38,11 @@ version
The version of the package to install. Default is to install the version The version of the package to install. Default is to install the version
chosen by the local package manager. chosen by the local package manager.
source
Source dpkg package to upload an install (instead of fetching
from the repositories). Dependencies will be collected and installed
from the usual sources though.
BOOLEAN PARAMETERS BOOLEAN PARAMETERS
------------------ ------------------

View file

@ -2,3 +2,4 @@ name
version version
state state
target-release target-release
source