|
|
@ -12,7 +12,7 @@ KEEP_ONLY_PO="fr en de" |
|
|
|
|
|
|
|
include common |
|
|
|
include pretty |
|
|
|
|
|
|
|
ansi_color no |
|
|
|
usage="$exname COMPONENT MASTER_IMAGE_NAME BRANCH UPDATED_IMAGE_NAME" |
|
|
|
|
|
|
|
COMPONENT_NAME="$1" |
|
|
@ -43,12 +43,20 @@ if [ -e "$lock" ]; then |
|
|
|
fi |
|
|
|
touch "$lock" |
|
|
|
|
|
|
|
## This path is on the docker HOST ! |
|
|
|
AUFS_APPLY_PATH=${AUFS_APPLY_PATH:-/opt/apps/aufs_apply/bin/aufs_apply} |
|
|
|
|
|
|
|
md5() { |
|
|
|
find "$@" -type f -exec md5sum {} \; 2>/dev/null | md5sum | cut -f 1 -d " " |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
clean_all() { |
|
|
|
cd / |
|
|
|
mountpoint "$tmpdir_root" 2>/dev/null && umount "$tmpdir_root" |
|
|
|
[ -d "$tmpdir_root" ] && rmdir "$tmpdir_root" |
|
|
|
[ -d "$tmpdir_changes" ] && rm -rf "$tmpdir_changes" |
|
|
|
rm "$lock" |
|
|
|
} |
|
|
|
|
|
|
|
tmpdir="$DOCKER_UPDATE_PATH"/tmp |
|
|
@ -58,15 +66,16 @@ tmpdir_root=$(mktemp -d $tmpdir/$COMPONENT_NAME.root.XXXXXX) |
|
|
|
trap "clean_all" EXIT |
|
|
|
mount -t aufs -o br=$tmpdir_changes:$DOCKER_UPDATE_PATH/$COMPONENT_NAME -o udba=none none "$tmpdir_root" |
|
|
|
cd "$tmpdir_root" |
|
|
|
set -eux |
|
|
|
## XXXvlab: We probably would need to: |
|
|
|
## - fetch only the module concerned |
|
|
|
## - fetch only the ref concerned |
|
|
|
Wrap -d "Update source code" <<EOF |
|
|
|
git fetch origin "$BRANCH" |
|
|
|
git checkout "$BRANCH" |
|
|
|
git reset --hard origin/$BRANCH |
|
|
|
#git reset --hard "origin/$BRANCH" |
|
|
|
git sub update |
|
|
|
EOF |
|
|
|
|
|
|
|
cd / && |
|
|
|
umount "$tmpdir_root" && |
|
|
@ -77,28 +86,30 @@ if [ "$?" != 0 ]; then |
|
|
|
fi |
|
|
|
cd "$tmpdir_changes" |
|
|
|
|
|
|
|
echo "Cleaning the change layer." |
|
|
|
Wrap -d "Cleaning the change layer." <<EOF |
|
|
|
find . -name .git -type d -exec rm -rf {} \; -prune |
|
|
|
|
|
|
|
if [ "$KEEP_ONLY_PO" ]; then |
|
|
|
find_args="" |
|
|
|
for lang in $KEEP_ONLY_PO; do |
|
|
|
find_args="$find_args -not -name $lang.po" |
|
|
|
find_args="\$find_args -not -name \$lang.po" |
|
|
|
done |
|
|
|
|
|
|
|
find /opt/apps -name \*.po -type f $find_args -delete |
|
|
|
find /opt/apps -name \*.po -type f \$find_args -delete |
|
|
|
fi |
|
|
|
|
|
|
|
EOF |
|
|
|
|
|
|
|
## XXXvlab: if we produced it we shouldn't have to pull it |
|
|
|
# |
|
|
|
#echo "Pulling $MASTER_IMAGE_NAME" |
|
|
|
#docker pull "$MASTER_IMAGE_NAME" || exit 1 |
|
|
|
|
|
|
|
cat <<EOF | docker-update "$MASTER_IMAGE_NAME" -v "$tmpdir_changes:/mnt/changes" |
|
|
|
mkdir -p /srv/app/{root,changes} |
|
|
|
cp -a /mnt/changes /srv/app/changes/0000 |
|
|
|
ls /srv/app/changes/0000 |
|
|
|
docker tag "$MASTER_IMAGE_NAME" "$UPDATED_IMAGE_NAME" |
|
|
|
Elt "Updating $MASTER_IMAGE_NAME" |
|
|
|
print_info $(cat <<EOF | docker-update "$UPDATED_IMAGE_NAME" -v "$tmpdir_changes:/mnt/changes" -v "$AUFS_APPLY_PATH:/usr/bin/aufs_apply" |
|
|
|
## Applying changes: $(cd "$tmpdir_changes" ; md5 ".") |
|
|
|
/usr/bin/aufs_apply /opt/apps/0k-oe /mnt/changes |
|
|
|
EOF |
|
|
|
) |
|
|
|
Feedback || exit 1 |
|
|
|
|
|
|
|
docker push "$UPDATED_IMAGE_NAME" |
|
|
|
Wrap -d "Push new $YELLOW$UPDATED_IMAGE_NAME$NORMAL to registry" docker push "$UPDATED_IMAGE_NAME" |